Abstract Class: action_base
Abstract class for implementation of GOAP planner actions.
Source
C++ class action_base
Custom Constructor
action_base
Extends
Constructors
Constructor
new action_base(): action_base;Default constructor.
Returns
action_base
Overrides
Constructor
new action_base(object?: Nillable<game_object>): action_base;Parameters
| Parameter | Type | Description |
|---|---|---|
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
EngineBinding.constructorConstructor
new action_base(object: Nillable<game_object>, name: string): action_base;Parameters
| Parameter | Type | Description |
|---|---|---|
object | Nillable<game_object> | Target game object to work with, null is OK since correct object will be injected on setup. |
name | string | Name of the action, used for debug purposes mainly. |
Returns
action_base
Overrides
EngineBinding.constructorMethods
add_effect()
add_effect(property: world_property): void;Add action effect. Describes what target world state is expected to be if action is completed.
Parameters
| Parameter | Type | Description |
|---|---|---|
property | world_property | World 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()
add_precondition(property: world_property): void;Add action execution precondition. When building logics graph, action will be considered blocked by some preconditions.
Parameters
| Parameter | Type | Description |
|---|---|---|
property | world_property | World 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()
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()
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()
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()
remove_effect(id: number): void;Remove action effect. Action will be not considered as property changing for id anymore.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | World 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()
remove_precondition(id: number): void;Remove precondition for action. When building logics graph, action will not be considered blocked by evaluator id states.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | number | World 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()
set_weight(weight: number): void;Set weight of current action execution.
Parameters
| Parameter | Type | Description |
|---|---|---|
weight | number | Weight value to express how prioritized action is. |
Returns
void
setup()
setup(object: game_object, storage: property_storage): void;Handle setup of the action and binding to a specific object.
Parameters
| Parameter | Type | Description |
|---|---|---|
object | game_object | Target client object to work with. |
storage | property_storage | Action 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()
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
Properties
__name
readonly __name: string;LuaBind instance constructor name.
Inherited from
object
readonly object: game_object;Game object that is handled by current action instance.
storage
readonly storage: property_storage;Container reference with state of action preconditions.
__name
readonly static __name: string;LuaBind class constructor name.