Action

Action

Base class for Visual State Machine actions that allows the action to also
be used in a script. This class will be removed after FSM is updated to
so that it can run script actions directly. New script actions should extend
api.common.Action instead of this class.

Constructor

new Action(idopt, optionsopt)

Initialize a new Action object. Two modes are supported: an "old" mode
which is used by MachineHandler when loading a behavior and by old script
code that manually builds FSM states; and a "new" mode which is used by
new script code. The "old" mode is selected if an id parameter is provided
otherwise the "new" mode is selected.

In the "old" mode, the options object is expected to have a "transitions"
property containing a property for each connected transition. The value of
the property is a transition id. In the "new" mode, the options object does
not contain a "transitions" property. Instead it may contain a property that
provides a signal handler for each of its supported transitions. This property
is named "onFoo" where "foo" is the name of the transition.

Also in the "old" mode, the options object is expected to contain a
property for each of the acton's parameters initialized with the default
value for that parameter, or with the used specified value for that
parameter. In the "new" mode, the options object will not contain the
properties with the default values and they will be added automatically.

Parameters:
Name Type Attributes Description
id string <optional>

the action's unique identifier. When this parameter
is omitted and the "new" mode is selected, an unique id for the action is
generated.

options Object <optional>

the action's configuration options.

Members

(static) _SCRIPT_RUNTIME_MACHINE_ID :string

Id used for the script runtime machine in a state machine component.

(static) _SCRIPT_RUNTIME_STATE_ID :string

Id used for the script runtime state in a script runtime machine.

Methods

(protected, static) register(optionsopt)

Registers an action class.

Parameters:
Name Type Attributes Description
options object <optional>

registration options

Properties
Name Type Attributes Description
aliases Array.<string> <optional>

other class names used when add the
class to the sumerian global.

_getScriptRuntimeState(publicEntity) → {ScriptRuntimeState}

Get the FSM State object used for actions started by scripts. A state
machine component, machine, and state are added as needed.

Parameters:
Name Type Description
publicEntity Entity

The public api entity object.

(protected) cleanup(ctx)

Called when the world stops playing, or the action is removed while the
world playing or paused.

Override when extending the Action class.

Parameters:
Name Type Description
ctx Context

Provides access to the state that contains this action.

(protected) configure(settings)

Called by the constructor and by the handlers when new options are loaded.

Parameters:
Name Type Description
settings object

The actions configuration options.

(protected) enter(ctx)

Called when the state that contains the action is entered. This function is
never called when the action is added, even if the action is being added to
an active state, unless the State#addAction enterIfActive option is
set.

Override when extending the Action class.

Parameters:
Name Type Description
ctx Context

Provides access to the state that contains this action.

(protected) exit(ctx)

Called when the state that contains the action is exited. This function is
never called when the action is removed, even if the action is being removed
from an active state.

Override when extending the Action class.

Parameters:
Name Type Description
ctx Context

Provides access to the state that contains this action.

(protected) setup(ctx)

Called when the world beings to play, or when an action is added while the
world is playing or paused.

Override when extending the Action class.

Parameters:
Name Type Description
ctx Context

Provides access to the state that contains this action.

(protected) start(ctx)

Call by the script system when the action is started. The default
implementation adds the action to a special script runtime state on
the entity.

Parameters:
Name Type Description
ctx Context

a script runtime context object.

(protected) update(ctx)

Called once on every frame.

Override when extending the Action class.

Parameters:
Name Type Description
ctx Context

Provides access to the state that contains this action.