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
new action_planner(): action_planner;Default constructor.
Returns
action_planner
Overrides
Methods
action()
action(id: number): action_base;Get action instance by unique id.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | Unique identifier of the action to get. |
Returns
Registered action instance.
actual()
actual(): boolean;Returns
boolean
Whether state of current planner is actual.
add_action()
add_action(id: number, action: action_base): void;Add generic action by id for planner execution.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | Unique identifier of new action. |
action | action_base | Action 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()
add_evaluator(id: number, evaluator: property_evaluator): void;Add evaluator instance for current action planner.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | Unique identifier of the evaluator. |
evaluator | property_evaluator | Instance 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()
clear(): void;Clear state of current action planner.
Returns
void
current_action()
current_action(): action_base;Get currently active action being executed.
Returns
Current action instance reference.
Remarks
Requires the planner to be initialized, usually after a successful update.
current_action_id()
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()
evaluator(id: number): property_evaluator;Get evaluator instance by id.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | Unique identifier of the evaluator to get. |
Returns
Registered property evaluator.
initialized()
initialized(): boolean;Returns
boolean
Whether object action planner is already initialized.
remove_action()
remove_action(id: number): void;Remove action by unique id.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | Unique 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()
remove_evaluator(id: number): void;Remove evaluator instance from current action planner.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | Unique 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()
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
| Parameter | Type | Description |
|---|---|---|
state | world_state | Target world state to reach with planner. |
Returns
void
setup()
setup(object: game_object): void;Setup planner for game object.
Parameters
| Parameter | Type | Description |
|---|---|---|
object | game_object | Client game object to setup planner for. |
Returns
void
Throws
If object is missing.
show()
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
| Parameter | Type | Description |
|---|---|---|
prefix | string | String prefix to display current action state in logs. |
Returns
void
update()
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
readonly __name: string;LuaBind instance constructor name.
Inherited from
object
readonly object: game_object;Game object that is handled by current planner instance.
storage
readonly storage: property_storage;Container reference with state of planner preconditions.
__name
readonly static __name: string;LuaBind class constructor name.