Skip to content

OpenContainerTask ​

Inherits: BehaviorTask < Resource

Open a specific container and optionally take/deposit items Enhanced with proper signal-based movement handling

Properties ​

intcontainer_id0
booldesired_open_statetrue
boolmove_to_containertrue
floatinteraction_distance2.0
inttake_item_id0
inttake_quantity1
intdeposit_item_id0
intdeposit_quantity1
boolcreate_new_itemsfalse

Variables ​

InteractableObjecttarget_containernull
boolinitial_container_statefalse
boolcontainer_was_opened_by_usfalse
boolitems_processedfalse
Vector3container_positionVector3.ZERO
floatinteraction_range2.0
boolmovement_completedfalse
boolcontainer_interaction_completedfalse

Methods ​

voidexecute_task_start()
voidexecute_task_interrupt()
voidexecute_task_fail()
InteractableObjectget_target_container()
boolis_container_accessible()
floatget_distance_to_container()
boolis_in_container_interaction_range()
voidset_container_id( new_id: int )
voidset_create_new_items( create_new: bool )
voidset_deposit_item( item_id: int, quantity: int = 1 )
voidclear_deposit_item()
voidset_take_item( item_id: int, quantity: int = 1 )
voidclear_take_item()
voidset_interaction_distance( distance: float )

Property descriptions ​

Target

int container_id = 0 ​

The unique ID of the container to interact with

bool desired_open_state = true ​

Desired container state (true = open, false = close)

bool move_to_container = true ​

Whether to move to container before interacting

float interaction_distance = 2.0 ​

Interaction distance from container

Items

int take_item_id = 0 ​

Item ID to take from container (0 = don't take anything)

int take_quantity = 1 ​

Quantity to take (defaults to 1)

int deposit_item_id = 0 ​

Item ID to deposit into container (0 = don't deposit anything)

int deposit_quantity = 1 ​

Quantity to deposit (defaults to 1)

bool create_new_items = false ​

If true, creates new items instead of taking from entity inventory

Variable descriptions ​

InteractableObject target_container = null ​

The container the entity opens.

bool initial_container_state = false ​

Whether the container was open when the task began.

bool container_was_opened_by_us = false ​

True when the task opened it (so it closes it again).

bool items_processed = false ​

True once the items were taken or put.

Vector3 container_position = Vector3.ZERO ​

The position of the container.

float interaction_range = 2.0 ​

How close the entity must be to open the container.

bool movement_completed = false ​

True once the entity arrived.

bool container_interaction_completed = false ​

True once the container was used.

Method descriptions ​

void execute_task_start() ​

Starts the task.

void execute_task_interrupt() ​

Called when something interrupts the task.

void execute_task_fail() ​

Called when the task fails.

InteractableObject get_target_container() ​

The container the entity opens.

bool is_container_accessible() ​

Can the container be opened now?

float get_distance_to_container() ​

The distance to the container (-1 when there is none).

bool is_in_container_interaction_range() ​

Is the entity close enough to open the container?

void set_container_id( new_id: int ) ​

Set the target container ID dynamically

void set_create_new_items( create_new: bool ) ​

Set whether to create new items instead of transferring from inventory

void set_deposit_item( item_id: int, quantity: int = 1 ) ​

Set the item to deposit with quantity dynamically

void clear_deposit_item() ​

Clear deposit item

void set_take_item( item_id: int, quantity: int = 1 ) ​

Set the item to take with quantity dynamically

void clear_take_item() ​

Clear take item

void set_interaction_distance( distance: float ) ​

Set interaction distance dynamically