How-To: Bridge to Equipment

Goal: equip an inventory item on a character and keep the inventory's view of it (the Equipped lock, the slot it sits in) correct across equips, forced unequips and save/load.

Prerequisites
How-To: Author an Item Definition and a character with an equipment system of your choice. This plugin never talks to an equipment system itself; it only keeps the bookkeeping.

1. Name the equipment on the item

Add UCrimsonInventoryItemFragment_Equippable to the item definition and set its equipment definition class. The fragment is data: whatever code performs the equip reads it.

Verify
Find Item Definition Fragment (Equippable) on the item returns the fragment with your class.

2. Equip, then report the result

On the server, hand the item to your equipment system. When it succeeds, call SetEntryEquipped(EntryId, true, SlotTag, SlotIndex) on the manager; when the item comes off, call it with false. The entry gets the Equipped lock flag and leaves the layout (unless bEquippedItemsOccupyLayout is set).

Switch Has Authority (Authority) -> <your equip call> -> Branch (success) -> Set Entry Equipped (Entry Id = the item's entry, b Equipped = true, Slot Tag / Slot Index = where it landed).

Verify
Play As Client: after the equip the entry shows the Equipped lock on the client, and Get Entry Equipped Slot returns the slot.

3. Re-equip after a load

ApplySaveData restores which entries were equipped but cannot equip them (it knows no equipment system). It queues them: read GetPendingEquips() (FCrimsonInventoryEquippedSlot per entry), equip each through your system, and call ClearPendingEquip(EntryId) as you go. HasPendingEquips tells you whether anything is waiting.

Verify
Save with a sword equipped, load: the sword is back on the character and no entry is left pending.
(CrimsonCore - requires all Crimson plugins)
CrimsonCore joins this plugin to CrimsonEquipment: UCrimsonInventoryEquipmentStatics (CanEquipItem, IsItemEquipped, EquipItem, UnequipItem, HasRoomToUnequip, FlushPendingEquips) and UCrimsonInventoryIntegrationSubsystem, which keeps the Equipped flag in sync when equipment is removed by other code. They are a complete reference for steps 2 and 3.

See also

  • How-To: Save and Restore
  • API Reference