Class: ReactionInterpreter

ReactionInterpreter

A reaction command interpreter

new ReactionInterpreter (sender, reaction, object, state, parameters, event, command)

Name Type Default Description
sender MapObject Current event sender (null for system events)
reaction SystemReaction Current reaction excecuted (only one per state)
object MapObject Current map object
state number Current state of map object reaction
parameters Array.<SystemParameter> All the parameters coming with this reaction
event Array.<number> The current time events
command EventCommand reaction.getFirstCommand() optional The current command (by default the first reaction command)
Properties:
Name Type Description
currentSender MapObject Current event sender (null for system events)
currentReaction SystemReaction Current reaction excecuted (only one per state)
currentMapObject MapObject Current map object
currentState number Current state of map object reaction
currentParameters Array.<SystemParameter> All the parameters coming with this reaction
currentCommand Node A node of a command reaction
currentCommandState Object Current state of the current command
currentTimeState Array.<number> The current time events
isInMainMenu boolean Indicate if this reaction was executed in main menu

Methods

isFinished ()boolean

Check if the current reaction is finished (no more commands to excecute)
Returns:
Type Description
boolean

canExecute ()boolean

Check if the command can be executed
Returns:
Type Description
boolean

updateObjectParameters ()

Update current object and parameters (for variables)

updateFinish ()

Update if finished

update ()

Update the current commands

updateCommand ()Node

Update a command and return the next command to excecute (if finished)
Returns:
Type Description
Node

endOfBlock (command, value)Node

Update a command that corresponds to the end of a block and return the next command to excecute (if finished)
Name Type Description
command Node The command before updating
value Node The next command after updating
Returns:
Type Description
Node

goToNextCommand (command)Node

After the end of a block, go to the next command
Name Type Description
command Node The command before updating
Returns:
Type Description
Node

onKeyPressed (key)

First key press handle for the current command
Name Type Description
key number The key ID pressed

onKeyReleased (key)

First key release handle for the current command
Name Type Description
key number The key ID released

onKeyPressedRepeat (key)boolean

Key pressed repeat handle for the current command
Name Type Description
key number The key ID pressed
Returns:
Type Description
boolean false if the other keys are blocked after it

onKeyPressedAndRepeat (key)boolean

Key pressed repeat handle for the current command, but with a small wait after the first pressure (generally used for menus)
Name Type Description
key number The key ID pressed
Returns:
Type Description
boolean false if the other keys are blocked after it

drawHUD ()

Draw HUD for the current command