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.

Prerequisites
Quick Start steps 1 to 5 (plugin enabled, a manager on the PlayerState, a routing component on the PlayerController).

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.

Verify
Drag off the result and call Get Entry Views; it returns an array (possibly empty) rather than failing.

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.

Verify
Returns a valid component on both the listen server and a Play As Client window.

3. Read the project settings

Get Class Defaults with class CrimsonInventorySettings, or open Project Settings -> Crimson -> Crimson Inventory in the editor.

SettingWhat it does
ItemDefinitionScanPathsFolders registered with the asset manager as CrimsonInventoryItemDefinition primary assets. Required for discovery and cooking.
CurrencyDefinitionTablesData tables (row type FCrimsonCurrencyDefinition) every manager loads on InitializeComponent.
ConstraintDefinitionTableOptional data table (row type FCrimsonConstraintDefinition) mapping constraint tags to classes and display names.
SorterMappingsSort tag -> UCrimsonInventorySorter class. ByName, ByStackSize, ByItemType are pre-registered.
MaxContainerInteractionDistanceServer-side distance check (cm) while a container session is open. 0 disables it.
ItemInstanceClassThe UCrimsonInventoryItemInstance subclass every item instance is created as (empty = the base class). See How-To: Add Context Actions.
bVerboseLoggingLog operational events (add, remove, sort, currency, pickup) at Info verbosity.
Verify
Project Settings -> Crimson -> Crimson Inventory shows all seven settings under the categories Item Discovery, Currency, Constraints, Sorting, Access Control, Context Menu, and Debug.

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.

Verify
With 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.

Verify
Play As Client: calling Add Item Definition from a client widget logs a warning and changes nothing; calling Move Item on the routing component changes the server's inventory.

See also

  • Quick Start
  • How-To: Route UI Requests
  • How-To: React to Inventory Messages
  • Concept: Multiplayer