Skip to content

Class: action_planner

Script action planner binding for GOAP evaluators and actions.

Source

C++ class action_planner

Custom Constructor

action_planner

Extends

Extended by

Constructors

Constructor

ts
new action_planner(): action_planner;

Default constructor.

Returns

action_planner

Overrides

EngineBinding.constructor

Methods

action()

ts
action(id: number): action_base;

Get action instance by unique id.

Parameters

ParameterTypeDescription
idnumberUnique identifier of the action to get.

Returns

action_base

Registered action instance.


actual()

ts
actual(): boolean;

Returns

boolean

Whether state of current planner is actual.


add_action()

ts
add_action(id: number, action: action_base): void;

Add generic action by id for planner execution.

Parameters

ParameterTypeDescription
idnumberUnique identifier of new action.
actionaction_baseAction implementation containing preconditions, logics, effects and other meta infos.

Returns

void

Remarks

Do not add actions from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.


add_evaluator()

ts
add_evaluator(id: number, evaluator: property_evaluator): void;

Add evaluator instance for current action planner.

Parameters

ParameterTypeDescription
idnumberUnique identifier of the evaluator.
evaluatorproperty_evaluatorInstance of evaluator linked to the id.

Returns

void

Remarks

Do not add evaluators from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.


clear()

ts
clear(): void;

Clear state of current action planner.

Returns

void


current_action()

ts
current_action(): action_base;

Get currently active action being executed.

Returns

action_base

Current action instance reference.

Remarks

Requires the planner to be initialized, usually after a successful update.


current_action_id()

ts
current_action_id(): number;

Get currently active action identifier.

Returns

number

Unique identifier of current action.

Throws

If the planner is not initialized yet.


evaluator()

ts
evaluator(id: number): property_evaluator;

Get evaluator instance by id.

Parameters

ParameterTypeDescription
idnumberUnique identifier of the evaluator to get.

Returns

property_evaluator

Registered property evaluator.


initialized()

ts
initialized(): boolean;

Returns

boolean

Whether object action planner is already initialized.


remove_action()

ts
remove_action(id: number): void;

Remove action by unique id.

Parameters

ParameterTypeDescription
idnumberUnique identifier of the action to remove.

Returns

void

Remarks

Do not remove actions from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.


remove_evaluator()

ts
remove_evaluator(id: number): void;

Remove evaluator instance from current action planner.

Parameters

ParameterTypeDescription
idnumberUnique identifier of the evaluator for removal.

Returns

void

Remarks

Do not remove evaluators from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.


set_goal_world_state()

ts
set_goal_world_state(state: world_state): void;

Set target world state to try to reach with all the graph logics. All graphs will be built from current state to goal world state with the shortest possible path.

Parameters

ParameterTypeDescription
stateworld_stateTarget world state to reach with planner.

Returns

void


setup()

ts
setup(object: game_object): void;

Setup planner for game object.

Parameters

ParameterTypeDescription
objectgame_objectClient game object to setup planner for.

Returns

void

Throws

If object is missing.


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
prefixstringString prefix to display current action state in logs.

Returns

void


update()

ts
update(): void;

Lifecycle method to handle generic game loop updates.

Returns

void

Throws

If the planner cannot build a non-empty action sequence to the target world state.

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 planner instance.


storage

ts
readonly storage: property_storage;

Container reference with state of planner preconditions.


__name

ts
readonly static __name: string;

LuaBind class constructor name.

Inherited from

EngineBinding.__name