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
| Member | Type | Description |
current | PlayerInventory | The persistent inventory shared across all level runs. Do not modify from inside Tick() — use context.inventory instead. |
CreateExecutionInstance() | PlayerInventory | Creates a deep copy of current for use during a level run. Called automatically by the engine at execution start. |
Deserialize(InventoryData data) | PlayerInventory | Reconstructs a PlayerInventory from a saved snapshot. Returns null if the data is invalid. |
Properties
| Property | Type | Description |
equipment | IReadOnlyDictionary<Equipment.Type, Equipment> | Read-only view of all five equipment slots. Slots with no item map to null. |
Item Methods
| Method | Returns | Description |
TryAddItem(Item item) | bool | Adds 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) | bool | Adds amount units. Returns false if no slot is available. |
TryRemoveItem(Item item) | bool | Removes the entire slot containing item. Returns false if not present. Prefer TryUseItem for stackable consumables. |
TryUseItem(Item item) | bool | Decrements the stack count by one; removes the slot when it reaches zero. Returns false if the item is not present. |
ContainsItem(Item item) | bool | Returns true if at least one slot holds item. |
GetItemAtIndex(int index, out Item item, out int amount) | void | Outputs the item and stack count at the given slot index. item is null for an empty slot. |
Equipment Methods
| Method | Returns | Description |
Equip(Equipment equipment) | void | Places equipment in its designated slot, replacing any existing item of the same type. |
Unequip(Equipment.Type type, out Equipment equipped) | void | Removes and returns the item in type slot. equipped is null if the slot was empty. |
GetEquipment(Equipment.Type type) | Equipment | Returns the equipment in type slot, or null if empty. |
Equipped(Equipment equipment) | bool | Returns true if equipment currently occupies its slot. |
GetStatValue(Stat stat) | int | Sums the bonus contributed to stat by all currently equipped items and returns the total. |
Serialization
| Method | Returns | Description |
Serialize() | InventoryData | Converts 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
| Property | Type | Description |
inventoryCapacity | int | Total number of item slots available to the player. |
startingItems | IReadOnlyList<Item> | Items added to the inventory at the start of the first run. |
equipment | IReadOnlyList<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
| Field | Type | Description |
slots | SlotData[] | One entry per inventory slot. Empty slots have an empty itemId. |
equipment | EquipmentSlotData[] | One entry per equipment type. Empty slots have an empty equipmentId. |
InventoryData.SlotData
| Field | Type | Description |
itemId | string | Asset ID of the item in this slot, or empty string if the slot is empty. |
amount | int | Stack count for this slot. |
InventoryData.EquipmentSlotData
| Field | Type | Description |
type | Equipment.Type | The equipment slot this entry represents. |
equipmentId | string | Asset ID of the equipped item, or empty string if the slot is empty. |