Skip to content

Class: MockActionBase

Mock of the X-Ray engine GOAP action base class.

Extends

Implements

  • action_base

Accessors

__name

Get Signature

ts
get __name(): string;
Returns

string

Implementation of

ts
action_base.__name

Inherited from

MockLuabindClass.__name


__name

Get Signature

ts
get static __name(): string;
Returns

string

Inherited from

MockLuabindClass.__name

Constructors

Constructor

ts
new MockActionBase(object: game_object, name?: string): MockActionBase;

Parameters

ParameterType
objectgame_object
name?string

Returns

MockActionBase

Overrides

MockLuabindClass.constructor

Methods

add_effect()

ts
add_effect(property: MockWorldProperty): void;

Add action effect. Describes what target world state is expected to be if action is completed.

Parameters

ParameterTypeDescription
propertyMockWorldPropertyWorld 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.

Implementation of

ts
action_base.add_effect

add_precondition()

ts
add_precondition(property: MockWorldProperty): void;

Add action execution precondition. When building logics graph, action will be considered blocked by some preconditions.

Parameters

ParameterTypeDescription
propertyMockWorldPropertyWorld 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.

Implementation of

ts
action_base.add_precondition

execute()

ts
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.

Implementation of

ts
action_base.execute

finalize()

ts
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.

Implementation of

ts
action_base.finalize

getEffect()

ts
getEffect(id: number): MockWorldProperty | null;

Parameters

ParameterType
idnumber

Returns

MockWorldProperty | null


getPrecondition()

ts
getPrecondition(id: number): MockWorldProperty | null;

Parameters

ParameterType
idnumber

Returns

MockWorldProperty | null


initialize()

ts
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.

Implementation of

ts
action_base.initialize

remove_effect()

ts
remove_effect(id: number): void;

Remove action effect. Action will be not considered as property changing for id anymore.

Parameters

ParameterTypeDescription
idnumberWorld state property id.

Returns

void

Remarks

Do not mutate effects while the owner planner is updating; the engine asserts on graph changes during solving.

Implementation of

ts
action_base.remove_effect

remove_precondition()

ts
remove_precondition(id: number): void;

Remove precondition for action. When building logics graph, action will not be considered blocked by evaluator id states.

Parameters

ParameterTypeDescription
idnumberWorld state property id.

Returns

void

Remarks

Do not mutate preconditions while the owner planner is updating; the engine asserts on graph changes during solving.

Implementation of

ts
action_base.remove_precondition

set_weight()

ts
set_weight(weight: number): void;

Set weight of current action execution.

Parameters

ParameterTypeDescription
weightnumberWeight value to express how prioritized action is.

Returns

void

Implementation of

ts
action_base.set_weight

setup()

ts
setup(object: game_object): void;

Handle setup of the action and binding to a specific object.

Parameters

ParameterTypeDescription
objectgame_objectTarget client object to work with.

Returns

void

Remarks

Called by the planner when the action is registered. Call it manually only for standalone action tests.

Implementation of

ts
action_base.setup

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

Returns

void

Implementation of

ts
action_base.show

create()

ts
static create(object: game_object, name?: string): MockActionBase;

Parameters

ParameterType
objectgame_object
name?string

Returns

MockActionBase

Overrides

MockLuabindClass.create


mock()

ts
static mock(object: game_object, name?: string): action_base;

Parameters

ParameterType
objectgame_object
name?string

Returns

action_base

Overrides

MockLuabindClass.mock

Properties

effects

ts
effects: MockWorldProperty[] = [];

name

ts
name: string;

object

ts
object: game_object;

Game object that is handled by current action instance.

Implementation of

ts
action_base.object

preconditions

ts
preconditions: MockWorldProperty[] = [];

storage

ts
storage: property_storage;

Container reference with state of action preconditions.

Implementation of

ts
action_base.storage