Skip to content

SlotInstance ​

Inherits: RefCounted

Inherited by: EquipmentSlotInstance, InventorySlotInstance

Base class for all slot types - provides common interface for item storage

Description ​

This is the foundation for all slot-based storage including:

  • Inventory slots (with stacking support)
  • Equipment slots (single item only)
  • Any other specialized slot types

Handles basic slot state, locking, and item assignment while allowing child classes to override behavior for their specific needs.

Variables ​

ItemInstance:item_instance
boolis_lockedfalse:

Methods ​

intget_quantity()
voidset_quantity( new_quantity: int )
boolsupports_stacking()
intget_max_stack_size()
boolcan_accept_item( item: ItemInstance )
boolis_empty()
boolis_occupied()
boolis_full()
intget_remaining_space()
voidset_locked_state( locked: bool )
ItemInstanceclear()
boolset_item( new_item_instance: ItemInstance )
ItemDefinitionget_item_definition()
Stringget_item_display_name()
Texture2Dget_item_icon()

Signals ​

slot_data_changed() ​

Emitted whenever slot data changes (item added/removed/modified)

slot_lock_state_changed( is_locked: bool ) ​

Emitted when slot lock state changes

Variable descriptions ​

ItemInstance: item_instance ​

The item instance currently stored in this slot (null if empty)

bool is_locked = false: ​

Whether this slot is locked and cannot accept new items

Method descriptions ​

int get_quantity() ​

Get the current quantity of items in this slot

void set_quantity( new_quantity: int ) ​

Set the quantity of items in this slot

bool supports_stacking() ​

Whether this slot type supports stacking multiple items

int get_max_stack_size() ​

Get the maximum stack size for items in this slot

bool can_accept_item( item: ItemInstance ) ​

Check if this slot can accept a specific item instance

bool is_empty() ​

Check if slot is empty (no item or zero quantity)

bool is_occupied() ​

Check if slot has an item (opposite of is_empty)

bool is_full() ​

Check if slot is at maximum capacity

int get_remaining_space() ​

Get remaining space in this slot

void set_locked_state( locked: bool ) ​

Set lock state of this slot

ItemInstance clear() ​

Clear the slot and return the item that was in it

bool set_item( new_item_instance: ItemInstance ) ​

Set item instance in this slot

ItemDefinition get_item_definition() ​

Get the item definition from the current item instance

String get_item_display_name() ​

Get display name of the item in this slot

Texture2D get_item_icon() ​

Get icon of the item in this slot