Skip to content

InstanceUtility ​

Inherits: Node

Utility script to help item/ability creation anywhere.

Variables ​

GameHost.SystemHubsystem_hub

Methods ​

voidinitialize( p_system_hub: GameHost.SystemHub ) static
voidwarn_player( text: String ) static
voidtell_player( channel_id: String, text: String, data: Dictionary = {} ) static
ItemInstancecreate_item_instance( item_id: int ) static
ItemInstancecreate_item_instance_from_definition( item_def: ItemDefinition ) static
Array[ItemInstance]create_item_instances( item_id: int, quantity: int ) static
InventoryComponentget_current_player_inventory() static
booladd_item_to_inventory( inventory: InventoryComponent, item_id: int, quantity: int = 1 ) static
boolremove_item_from_inventory( inventory: InventoryComponent, item_id: int, quantity: int = 1 ) static
AbilityInstancecreate_ability_instance( definition: AbilityDefinition, user: Entity ) static

Variable descriptions ​

GameHost.SystemHub system_hub ​

The hub of the game systems.

Method descriptions ​

void initialize( p_system_hub: GameHost.SystemHub ) ​

Initialize the utility Call this from GameHost on startup

void warn_player( text: String ) ​

Tells the player something in the message area (a reward that does not fit, a craft without room). Does nothing without a UI

void tell_player( channel_id: String, text: String, data: Dictionary = {} ) ​

Writes a line in the chat, on a channel of the message manager (Loot, Trade, Discovery ...). Does nothing without a chat

ItemInstance create_item_instance( item_id: int ) ​

Create a new item instance from a definition ID

ItemInstance create_item_instance_from_definition( item_def: ItemDefinition ) ​

Create a new item instance from a definition

Array[ItemInstance] create_item_instances( item_id: int, quantity: int ) ​

Create multiple item instances (for stacking items)

InventoryComponent get_current_player_inventory() ​

The inventory of the current player, or null.

bool add_item_to_inventory( inventory: InventoryComponent, item_id: int, quantity: int = 1 ) ​

Add item by ID to any inventory (creates ItemInstance automatically)

bool remove_item_from_inventory( inventory: InventoryComponent, item_id: int, quantity: int = 1 ) ​

Remove item by ID from any inventory (finds and removes instances)

AbilityInstance create_ability_instance( definition: AbilityDefinition, user: Entity ) ​

Makes an ability instance of a definition for a user.