Class l2df.class.component.states

Last updated 2021-05-28 15:24:22

States component.

Inherited from l2df.class.Component class.

Info:

Functions

States:added(obj[, kwargs]) Component was added to Entity event.
States:removed(obj) Component was removed from Entity event.
States:add(obj, state, id[, use_constate=false]) Add new state to the collection.
States:remove(obj, id[, use_constate=false]) Remove previously added state by ID.
States:clear(obj[, use_constate=false]) Clears all added states (or constant states).
States:update(obj, dt) Component update event handler.

Tables

State State description table.
ConstantState Constant state description table.


Functions

Methods
States:added(obj[, kwargs])
Component was added to Entity event. Adds "states" key to the Entity.C table.

Parameters:

States:removed(obj)
Component was removed from Entity event. Removes "states" key from Entity.C table.

Parameters:

States:add(obj, state, id[, use_constate=false])
Add new state to the collection.

Parameters:

Returns:

    number ID of the state added in a local storage.
States:remove(obj, id[, use_constate=false])
Remove previously added state by ID.

Parameters:

  • obj l2df.class.entity Entity's instance.
  • id number ID of the state to remove.
  • use_constate boolean Set to true if you are removing constant state. (default false)
States:clear(obj[, use_constate=false])
Clears all added states (or constant states).

Parameters:

  • obj l2df.class.entity Entity's instance.
  • use_constate boolean Set to true to clear all constant states. (default false)
States:update(obj, dt)
Component update event handler. Executes all added states and constant states. All added states are removed after processing (except for constant states, they can be removed manually only).

Parameters:

  • obj l2df.class.entity Entity's instance.
  • dt number Delta-time since last game tick.

Tables

State
State description table.

Fields:

  • ... There're may be any amount of the <key:value> pairs. All of them can be accessed from the 3rd table argument passed to the state's function. For more info see StatesManager:run().
ConstantState
Constant state description table. Currently it is absolutely similar with State.

Fields:

  • ... There're may be any amount of the <key:value> pairs. All of them can be accessed from the 3rd table argument passed to the state's function. For more info see StatesManager:run().