How-To: React to Inventory Messages

Goal: refresh UI, play a sound or update a stat when an inventory changes, on the machine that shows it.

Prerequisites
How-To: Get the Building Blocks (how to reach the manager and the routing component).

1. Pick the event

Every event is a delegate on the object that owns it, fired on the server and on the owning client. Each has a BlueprintAssignable form and a native ...Native twin with the signature (FGameplayTag Channel, const Payload&); the channel is the Crimson.Inventory.Message.* tag the event always used.

Event (on the manager)PayloadFires when
OnStackChangedFCrimsonInventoryChangeMessageAn entry's count changes
OnInventoryUpdatedFCrimsonInventory_Message_InventoryUpdatedAnything in the inventory changed - rebuild your view
OnLayoutGroupsChangedFCrimsonInventory_Message_LayoutGroupsChangedBags opened, closed or moved
OnConstraintFailureFCrimsonInventoryConstraintFailureMessageA rule refused an add or move
OnConstraintChangedFCrimsonInventory_Message_ConstraintChangedA capacity counter or cap changed (once per tag)
OnItemDropped / OnCurrencyDroppedFCrimsonInventory_Message_ItemDropped / ..._CurrencyDroppedSomething left the inventory into the world
OnCurrencyChangedFCrimsonInventoryCurrencyChangeMessageA currency amount changed
OnItemHostChangedFCrimsonItemHostChangedMessageAn item-host transaction applied
OnOperationResult (on the routing component)FCrimsonInventoryOperationResultA routed request succeeded or failed
Verify
Bind a print to On Inventory Updated, grant an item on the server: it prints in the server window and in the owning client's window.

2. Bind it

Event Construct -> Find Inventory Manager (your PlayerState) -> Bind Event to On Inventory Updated; rebuild the view in the event. Unbind in Event Destruct.

Bind the objects you care about
Events are per object. A widget that shows two inventories (a bag and an open chest) binds both managers; one that reports routed failures binds the player's routing component.
Verify
Play As Client, 2 players: each client's widget updates only for its own inventory.
Want one global message bus?
The plugin does not publish on CrimsonCommon's message bus. To get one global channel tree, bind the ...Native delegate and re-broadcast it yourself - see CrimsonCommon -> Concept: Connecting Crimson Plugins.

See also

  • How-To: Route UI Requests
  • API Reference