How-To: Get the Building Blocks
Goal: obtain every object the other How-To pages assume you already have - the inventory manager, the routing component, the project settings, the message subsystem - and know which side of the network you are on.
1. Find the inventory manager
UCrimsonInventoryStatics::FindInventoryManager takes any actor. For a pawn or controller it also looks at the PlayerState, so you can pass whatever you have.
Find Inventory Manager (Context Actor = Get Owning Player -> Player State, or any actor that carries the component). Returns Crimson Inventory Manager Component or None.
2. Find the routing component
Find Routing Component (Context Actor = Get Owning Player). Every client-side request goes through this object. On a server-only actor (GameMode) there is no routing component - call the manager directly there.
3. Read the project settings
Get Class Defaults with class CrimsonInventorySettings, or open Project Settings -> Crimson -> Crimson Inventory in the editor.
| Setting | What it does |
|---|---|
ItemDefinitionScanPaths | Folders registered with the asset manager as CrimsonInventoryItemDefinition primary assets. Required for discovery and cooking. |
CurrencyDefinitionTables | Data tables (row type FCrimsonCurrencyDefinition) every manager loads on InitializeComponent. |
ConstraintDefinitionTable | Optional data table (row type FCrimsonConstraintDefinition) mapping constraint tags to classes and display names. |
SorterMappings | Sort tag -> UCrimsonInventorySorter class. ByName, ByStackSize, ByItemType are pre-registered. |
MaxContainerInteractionDistance | Server-side distance check (cm) while a container session is open. 0 disables it. |
ItemInstanceClass | The UCrimsonInventoryItemInstance subclass every item instance is created as (empty = the base class). See How-To: Add Context Actions. |
bVerboseLogging | Log operational events (add, remove, sort, currency, pickup) at Info verbosity. |
4. Reach the message subsystem
Every inventory event is a delegate on the manager or the routing component (native ...Native plus a Blueprint event). How-To: React to Inventory Messages lists them.
Bind Event to On Inventory Updated (or any other event) on the manager component.
bVerboseLogging on, adding an item prints a LogCrimsonInventory line and the Messages tab of the dev tools shows a StackChanged row.5. Know your authority
The manager's mutators are BlueprintAuthorityOnly; calling one on a client is a no-op with a log warning. The routing component's functions are client-callable and forward to the server.
Has Authority on the owning actor before any manager mutator. Is Local Player Controller before any routing call.
See also
- Quick Start
- How-To: Route UI Requests
- How-To: React to Inventory Messages
- Concept: Multiplayer