Class: planner_action
GOAP action class implementing both action base and action planner. Captures execution as action and plans its internal logic with separate logics graph.
Examples: combat planner, anomaly planner, items looting planner, alife planner, state planner.
Source
C++ class planner_action : action_planner,action_base
Custom Constructor
planner_action
Extends
Constructors
Constructor
new planner_action(): planner_action;Default constructor.
Returns
planner_action
Overrides
Constructor
new planner_action(object?: Nillable<game_object>): planner_action;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
planner_action
Overrides
action_planner.constructorConstructor
new planner_action(object: Nillable<game_object>, name: string): planner_action;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
planner_action
Overrides
action_planner.constructorMethods
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.
Inherited from
actual()
actual(): boolean;Returns
boolean
Whether state of current planner is actual.
Inherited from
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.
Inherited from
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_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.
Inherited from
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.
clear()
clear(): void;Clear state of current action planner.
Returns
void
Inherited from
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.
Inherited from
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.
Inherited from
action_planner.current_action_id
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.
Inherited from
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 outer 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 outer planner. Direct calls are only useful when driving the planner 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 outer planner. Direct calls are only useful when driving the planner action manually in tests or tools.
initialized()
initialized(): boolean;Returns
boolean
Whether object action planner is already initialized.
Inherited from
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.
Inherited from
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_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.
Inherited from
action_planner.remove_evaluator
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_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
Inherited from
action_planner.set_goal_world_state
set_weight()
set_weight(weight: number): void;Set weight of planner action switch.
Parameters
| Parameter | Type | Description |
|---|---|---|
weight | number | Weight value to express how prioritized action is. |
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.
Inherited from
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
Inherited from
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.
Inherited from
weight()
weight(first: world_state, second: world_state): number;Comparator to check weight of switching one state to another.
Parameters
| Parameter | Type | Description |
|---|---|---|
first | world_state | First state. |
second | world_state | Second state. |
Returns
number
Transition weight.
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.
Inherited from
storage
readonly storage: property_storage;Container reference with state of planner preconditions.
Inherited from
__name
readonly static __name: string;LuaBind class constructor name.