Zum Hauptinhalt springen

Inventory Invariants

The technical PDF presents these as strong invariants. In the current code, they are rules the integration must preserve and test, not guarantees of every low-level path.

Intended invariantCurrent enforcement or limit
Each entry has a unique valid SlotIDNormal adds generate GUIDs; AddToArray does not reject duplicates
ItemID resolves to a registered definitionManager lookups check it; low-level helpers can bypass registration
0 < StackSize ≤ MaxStackSize for live entriesAdd helpers clamp; removal leaves zero until component removes the entry
MaxStackSize > 0AddToArray guards it; capacity calculations require valid asset data
Quantity conserved during transfersExternal transfer assumes successful target add; general rollback absent
Failed operation leaves state unchangedOver-removal and multi-step paths can mutate before failure
Capacity is never exceededManager checks cover normal adds; direct SplitSlot has no slot-capacity check
Carry weight matches entriesMost component mutations recompute it; AddItemToSlot omits refresh
Only server mutates authoritative stateCommon helpers check authority; low-level split/merge/component paths do not consistently guard it

SlotID is stable for an entry's lifetime. Deleting and recreating a stack produces a new entry identity; it is not a persistent per-unit item GUID. Store additional instance identities separately if a weapon or unique item needs one.

Avoid direct write access to InventoryData even though it is BlueprintReadWrite/EditAnywhere in the current header. Changing replicated fields without dirty marking, capacity checks and carry-weight maintenance breaks the intended model. See Implementation Limits.