Inherits: ItemSlotBase
Holds a reference to an inventory item.
inventory_path: NodePath
- Path to anInventory
node. Sets theinventory
property.inventory: Inventory
- Reference to anInventory
node.
equip(item: InventoryItem) -> bool
- Equips the given inventory item in the slot. If the slot already holds an item,clear()
will be called first. Returnsfalse
if theclear
call fails, the slot can't hold the given item, or already holds the given item. Returnstrue
otherwise.clear() -> bool
- Clears the item slot.get_item() -> InventoryItem
- Returns the equipped item.can_hold_item(new_item: InventoryItem) -> bool
- Checks if the slot can hold the given item, i.e.inventory
contains the given item and the item is notnull
. This method can be overridden to implement item slots that can only hold specific items.reset()
- Clears the item slot.serialize() -> Dictionary
- Serializes the item slot into a dictionary.deserialize(source: Dictionary) -> bool
- Loads the item slot data from the given dictionary.Note:
inventory
must be set prior to thedeserialize
call!
item_equipped()
- Emitted when an item is placed in the slot.item_cleared()
- Emitted when the slot is cleared.