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) | Payload | Fires when |
|---|---|---|
OnStackChanged | FCrimsonInventoryChangeMessage | An entry's count changes |
OnInventoryUpdated | FCrimsonInventory_Message_InventoryUpdated | Anything in the inventory changed - rebuild your view |
OnLayoutGroupsChanged | FCrimsonInventory_Message_LayoutGroupsChanged | Bags opened, closed or moved |
OnConstraintFailure | FCrimsonInventoryConstraintFailureMessage | A rule refused an add or move |
OnConstraintChanged | FCrimsonInventory_Message_ConstraintChanged | A capacity counter or cap changed (once per tag) |
OnItemDropped / OnCurrencyDropped | FCrimsonInventory_Message_ItemDropped / ..._CurrencyDropped | Something left the inventory into the world |
OnCurrencyChanged | FCrimsonInventoryCurrencyChangeMessage | A currency amount changed |
OnItemHostChanged | FCrimsonItemHostChangedMessage | An item-host transaction applied |
OnOperationResult (on the routing component) | FCrimsonInventoryOperationResult | A 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