ActionBarSlotData ​
Inherits: RefCounted
Data structure for storing action bar slot content Can reference either abilities or items REFACTORED: Now stores direct item instance references instead of inventory indices
Variables ​
ContentType | content_type | ContentType.EMPTY |
AbilityInstance | ability_instance | null |
ItemInstance | item_instance | null |
int | quantity | 1 |
Methods ​
ActionBarSlotData | for_ability( ability: AbilityInstance ) static |
ActionBarSlotData | for_item( item: ItemInstance, quantity: int = 1 ) static |
Variant | get_content( player: Player ) |
bool | is_empty() |
void | clear() |
Dictionary | to_dict() |
ActionBarSlotData | from_dict( data: Dictionary, player: Player = null ) static |
bool | restore_ability_reference( player: Player, ability_definition_id: int ) |
bool | restore_item_reference( player: Player, item_instance_id: String ) |
bool | is_valid_for_player( player: Player ) |
int | get_current_stack_size() |
bool | has_sufficient_quantity() |
Enumerations ​
enum ContentType ​
The options of content type: empty, ability, item.
- EMPTY =
0 - ABILITY =
1 - ITEM =
2
Variable descriptions ​
ContentType content_type = ContentType.EMPTY ​
What the slot holds: nothing, an ability or an item.
AbilityInstance ability_instance = null ​
For abilities: direct reference to the ability instance
ItemInstance item_instance = null ​
For items: direct reference to the item instance
int quantity = 1 ​
For items that consume multiple per use
Method descriptions ​
ActionBarSlotData for_ability( ability: AbilityInstance ) ​
Create slot data for an ability
ActionBarSlotData for_item( item: ItemInstance, quantity: int = 1 ) ​
Create slot data for an item - now takes direct item instance
Variant get_content( player: Player ) ​
Get the actual content (ability or item) from this slot data
bool is_empty() ​
Check if this slot is empty
void clear() ​
Clear this slot
Dictionary to_dict() ​
Convert to dictionary for save/load
ActionBarSlotData from_dict( data: Dictionary, player: Player = null ) ​
Create from dictionary for save/load NOTE: This will need to be paired with a restoration system that rebuilds ability and item instance references from IDs after player data is loaded
bool restore_ability_reference( player: Player, ability_definition_id: int ) ​
Restore ability instance reference from player (call after loading)
bool restore_item_reference( player: Player, item_instance_id: String ) ​
Restore item instance reference from inventory (call after loading)
bool is_valid_for_player( player: Player ) ​
Check if this slot data is valid for the given player
int get_current_stack_size() ​
Get the current stack size for item in this slot (for display)
bool has_sufficient_quantity() ​
Check if the referenced item has enough quantity/charges for usage