PlayerInventory

Holds a fixed-size array of item slots and a dictionary of equipment slots. The engine maintains two instances simultaneously: PlayerInventory.current (persistent, survives scene loads) and the execution copy accessed via context.inventory (cloned per level run, committed on success). Always use context.inventory inside Tick().

Static Members

MemberTypeDescription
currentPlayerInventoryThe persistent inventory shared across all level runs. Do not modify from inside Tick() — use context.inventory instead.
CreateExecutionInstance()PlayerInventoryCreates a deep copy of current for use during a level run. Called automatically by the engine at execution start.
Deserialize(InventoryData data)PlayerInventoryReconstructs a PlayerInventory from a saved snapshot. Returns null if the data is invalid.

Properties

PropertyTypeDescription
equipmentIReadOnlyDictionary<Equipment.Type, Equipment>Read-only view of all five equipment slots. Slots with no item map to null.

Item Methods

MethodReturnsDescription
TryAddItem(Item item)boolAdds one unit of item. Stacks into an existing slot if item.stackable is true. Returns false if all slots are full.
TryAddItem(Item item, int amount)boolAdds amount units. Returns false if no slot is available.
TryRemoveItem(Item item)boolRemoves the entire slot containing item. Returns false if not present. Prefer TryUseItem for stackable consumables.
TryUseItem(Item item)boolDecrements the stack count by one; removes the slot when it reaches zero. Returns false if the item is not present.
ContainsItem(Item item)boolReturns true if at least one slot holds item.
GetItemAtIndex(int index, out Item item, out int amount)voidOutputs the item and stack count at the given slot index. item is null for an empty slot.

Equipment Methods

MethodReturnsDescription
Equip(Equipment equipment)voidPlaces equipment in its designated slot, replacing any existing item of the same type.
Unequip(Equipment.Type type, out Equipment equipped)voidRemoves and returns the item in type slot. equipped is null if the slot was empty.
GetEquipment(Equipment.Type type)EquipmentReturns the equipment in type slot, or null if empty.
Equipped(Equipment equipment)boolReturns true if equipment currently occupies its slot.
GetStatValue(Stat stat)intSums the bonus contributed to stat by all currently equipped items and returns the total.

Serialization

MethodReturnsDescription
Serialize()InventoryDataConverts this inventory to a JSON-serializable snapshot. Items and equipment are stored by their asset IDs.

InventoryPreset

Defines the player's starting loadout for a new game session. Assigned in the game configuration. Create instances with Create → Loop Adventure → Inventory → Inventory Preset.

Properties

PropertyTypeDescription
inventoryCapacityintTotal number of item slots available to the player.
startingItemsIReadOnlyList<Item>Items added to the inventory at the start of the first run.
equipmentIReadOnlyList<Equipment>Equipment pre-equipped in the order Weapon → Shield → Helmet → Armor → Boots.

InventoryData

JSON-serializable snapshot of a PlayerInventory. Items and equipment are stored by their asset ID strings. Used internally by the save system — you typically do not interact with this class directly.

Fields

FieldTypeDescription
slotsSlotData[]One entry per inventory slot. Empty slots have an empty itemId.
equipmentEquipmentSlotData[]One entry per equipment type. Empty slots have an empty equipmentId.

InventoryData.SlotData

FieldTypeDescription
itemIdstringAsset ID of the item in this slot, or empty string if the slot is empty.
amountintStack count for this slot.

InventoryData.EquipmentSlotData

FieldTypeDescription
typeEquipment.TypeThe equipment slot this entry represents.
equipmentIdstringAsset ID of the equipped item, or empty string if the slot is empty.