Skip to content

Abstract Class: action_base ​

Abstract class for implementation of GOAP planner actions.

Source ​

C++ class action_base

Custom Constructor ​

action_base

Extends ​

Constructors ​

Constructor ​

ts
new action_base(): action_base;

Default constructor.

Returns ​

action_base

Overrides ​

EngineBinding.constructor

Constructor ​

ts
new action_base(object?: Nillable<game_object>): action_base;

Parameters ​

ParameterTypeDescription
object?Nillable<game_object>Target game object to work with, null is OK since correct object will be injected on setup.

Returns ​

action_base

Overrides ​

ts
EngineBinding.constructor

Constructor ​

ts
new action_base(object: Nillable<game_object>, name: string): action_base;

Parameters ​

ParameterTypeDescription
objectNillable<game_object>Target game object to work with, null is OK since correct object will be injected on setup.
namestringName of the action, used for debug purposes mainly.

Returns ​

action_base

Overrides ​

ts
EngineBinding.constructor

Methods ​

add_effect() ​

ts
add_effect(property: world_property): void;

Add action effect. Describes what target world state is expected to be if action is completed.

Parameters ​

ParameterTypeDescription
propertyworld_propertyWorld state property describing a pair of evaluator ID and value.

Returns ​

void

Remarks ​

Do not mutate effects while the owner planner is updating; the engine asserts on graph changes during solving.


add_precondition() ​

ts
add_precondition(property: world_property): void;

Add action execution precondition. When building logics graph, action will be considered blocked by some preconditions.

Parameters ​

ParameterTypeDescription
propertyworld_propertyWorld state property describing a pair of evaluator ID and value.

Returns ​

void

Remarks ​

Do not mutate preconditions while the owner planner is updating; the engine asserts on graph changes during solving.


execute() ​

ts
execute(): void;

Lifecycle method. Execution tick of the action, called from object logics update cycle when current action is active.

Returns ​

void

Remarks ​

Called by the owning planner after initialize. Direct calls bypass planner state.


finalize() ​

ts
finalize(): void;

Lifecycle method called once on action execution stop. Means that action is finished / preconditions are not met anymore.

Returns ​

void

Remarks ​

Called by the owning planner. Direct calls are only useful when driving an action manually in tests or tools.


initialize() ​

ts
initialize(): void;

Lifecycle method called once on action execution start. Means that lifecycle of the action begun.

Returns ​

void

Remarks ​

Called by the owning planner. Direct calls are only useful when driving an action manually in tests or tools.


remove_effect() ​

ts
remove_effect(id: number): void;

Remove action effect. Action will be not considered as property changing for id anymore.

Parameters ​

ParameterTypeDescription
idnumberWorld state property id.

Returns ​

void

Remarks ​

Do not mutate effects while the owner planner is updating; the engine asserts on graph changes during solving.


remove_precondition() ​

ts
remove_precondition(id: number): void;

Remove precondition for action. When building logics graph, action will not be considered blocked by evaluator id states.

Parameters ​

ParameterTypeDescription
idnumberWorld state property id.

Returns ​

void

Remarks ​

Do not mutate preconditions while the owner planner is updating; the engine asserts on graph changes during solving.


set_weight() ​

ts
set_weight(weight: number): void;

Set weight of current action execution.

Parameters ​

ParameterTypeDescription
weightnumberWeight value to express how prioritized action is.

Returns ​

void


setup() ​

ts
setup(object: game_object, storage: property_storage): void;

Handle setup of the action and binding to a specific object.

Parameters ​

ParameterTypeDescription
objectgame_objectTarget client object to work with.
storageproperty_storageAction instance storage with preconditions and state.

Returns ​

void

Remarks ​

Called by the planner when the action is registered. Call it manually only for standalone action tests.


show() ​

ts
show(prefix?: string): void;

Debug method. With mixed / debug build allows investigation of evaluators and actions matches. Helps to debug custom actions and actions pre-conditions with state printing in log files.

Note: Available only in mixed / debug engine builds, not for direct usage from lua.

Parameters ​

ParameterTypeDescription
prefix?stringString prefix to display current action state in logs.

Returns ​

void

Properties ​

__name ​

ts
readonly __name: string;

LuaBind instance constructor name.

Inherited from ​

EngineBinding.__name


object ​

ts
readonly object: game_object;

Game object that is handled by current action instance.


storage ​

ts
readonly storage: property_storage;

Container reference with state of action preconditions.


__name ​

ts
readonly static __name: string;

LuaBind class constructor name.

Inherited from ​

EngineBinding.__name