Class: MockActionPlanner
Mock of the X-Ray engine GOAP action planner.
Extends
Implements
action_planner
Accessors
__name
Get Signature
get __name(): string;Returns
string
Implementation of
action_planner.__nameInherited from
__name
Get Signature
get static __name(): string;Returns
string
Inherited from
Constructors
Constructor
new MockActionPlanner(): MockActionPlanner;Returns
MockActionPlanner
Inherited from
Methods
actual()
actual(): boolean;Returns
boolean
Whether state of current planner is actual.
Implementation of
action_planner.actualasMock()
asMock(): action_planner;Returns
action_planner
clear()
clear(): void;Clear state of current action planner.
Returns
void
Implementation of
action_planner.clearcurrent_action()
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.
Implementation of
action_planner.current_actioncurrent_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.
Implementation of
action_planner.current_action_idinitialized()
initialized(): boolean;Returns
boolean
Whether object action planner is already initialized.
Implementation of
action_planner.initializedset_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
Implementation of
action_planner.set_goal_world_statesetup()
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.
Implementation of
action_planner.setupupdate()
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.
Implementation of
action_planner.updatecreate()
static create(): MockActionPlanner;Returns
MockActionPlanner
Overrides
mock()
static mock(): action_planner;Returns
action_planner
Overrides
mockDefault()
static mockDefault(object: game_object | MockGameObject): action_planner;Parameters
| Parameter | Type |
|---|---|
object | game_object | MockGameObject |
Returns
action_planner
Properties
action
action: Mock<(id: number) => action_base>;Get action instance by unique id.
Param
id
Unique identifier of the action to get.
Returns
Registered action instance.
Implementation of
action_planner.actionactions
actions: Record<number, action_base> = {};add_action
add_action: Mock<(id: number, actionBase: action_base) => void>;Add generic action by id for planner execution.
Remarks
Do not add actions from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.
Param
id
Unique identifier of new action.
Param
action
Action implementation containing preconditions, logics, effects and other meta infos.
Implementation of
action_planner.add_actionadd_evaluator
add_evaluator: Mock<(id: number, evaluator: property_evaluator) => void>;Add evaluator instance for current action planner.
Remarks
Do not add evaluators from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.
Param
id
Unique identifier of the evaluator.
Param
evaluator
Instance of evaluator linked to the id.
Implementation of
action_planner.add_evaluatorcurrentActionId
currentActionId: number | null = null;evaluator
evaluator: Mock<(id: number) => property_evaluator>;Get evaluator instance by id.
Param
id
Unique identifier of the evaluator to get.
Returns
Registered property evaluator.
Implementation of
action_planner.evaluatorevaluators
evaluators: Record<number, property_evaluator> = {};goalWorldState
goalWorldState: world_state | null = null;isInitialized
isInitialized: boolean = false;object
object: game_object;Game object that is handled by current planner instance.
Implementation of
action_planner.objectremove_action
remove_action: Mock<(id: number) => void>;Remove action by unique id.
Remarks
Do not remove actions from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.
Param
id
Unique identifier of the action to remove.
Implementation of
action_planner.remove_actionremove_evaluator
remove_evaluator: Mock<(id: number) => void>;Remove evaluator instance from current action planner.
Remarks
Do not remove evaluators from evaluator/action callbacks running inside update; the engine asserts on planner graph changes during solving.
Param
id
Unique identifier of the evaluator for removal.
Implementation of
action_planner.remove_evaluatorshow
show: Mock<UnknownFunction>;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.
Param
prefix
String prefix to display current action state in logs.
Implementation of
action_planner.showstorage
storage: property_storage;Container reference with state of planner preconditions.
Implementation of
action_planner.storage