EVENT
- public abstract class CommandReact<COMMAND extends CommandMessage> extends Object
CommandMessage
for you and calls react(CommandMessage)
method automatically.
If you need to react only once to the event, use EventReactOnce
.
Use EventReact.enable()
and EventReact.disable()
to enable react / disable react. The reaction is enabled
as default.
WARNING:Use as anonymous class, but save it as a field of your class! Note, that we're using weak-references to listeners and if you do not save pointer to the object, it will be gc()ed!
Modifier and Type | Field and Description |
---|---|
protected IAct |
reactAct |
protected Class<COMMAND> |
reactCommandClass |
protected ICommandListener<COMMAND> |
reactListener |
Constructor and Description |
---|
CommandReact(Class<COMMAND> commandClass,
IAct worldView) |
Modifier and Type | Method and Description |
---|---|
void |
disable()
Disables the reaction.
|
void |
enable()
Enables the reaction.
|
protected void |
postReact(COMMAND event)
post-
EventReact.react(IWorldEvent) hook allowing you to do additional work after the react method. |
protected void |
preReact(COMMAND event)
pre-
EventReact.react(IWorldEvent) hook allowing you to do additional work before the react method. |
protected abstract void |
react(COMMAND event)
React upon event notification.
|
protected ICommandListener<COMMAND extends CommandMessage> reactListener
protected IAct reactAct
protected Class<COMMAND extends CommandMessage> reactCommandClass
public void disable()
public void enable()
protected void preReact(COMMAND event)
EventReact.react(IWorldEvent)
hook allowing you to do additional work before the react method.event
- protected abstract void react(COMMAND event)
event
- protected void postReact(COMMAND event)
EventReact.react(IWorldEvent)
hook allowing you to do additional work after the react method.event
- Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.