EVENT - public abstract class ObjectEventReact<OBJECT extends IWorldObject,EVENT extends IWorldObjectEvent<OBJECT>> extends Object
IWorldObjectEvent for you and calls react(IWorldObjectEvent)
method automatically.
If you need to react only once to the event, use ObjectEventReactOnce.
Use enable() and 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 static int |
LEVEL_B_EVENT |
protected static int |
LEVEL_C_EVENT |
protected static int |
LEVEL_D_EVENT |
protected static int |
LEVEL_E_EVENT |
protected Class |
reactEventClass |
protected IWorldObjectEventListener<OBJECT,EVENT> |
reactListener |
protected Class |
reactObjectClass |
protected int |
reactObjectEventType |
protected WorldObjectId |
reactObjectId |
protected IWorldView |
reactWorldView |
| Constructor and Description |
|---|
ObjectEventReact(Class<?> objectClass,
Class<?> eventClass,
IWorldView worldView) |
ObjectEventReact(Class<?> objectClass,
IWorldView worldView) |
ObjectEventReact(WorldObjectId objectId,
Class<?> eventClass,
IWorldView worldView) |
ObjectEventReact(WorldObjectId objectId,
IWorldView worldView) |
| Modifier and Type | Method and Description |
|---|---|
void |
disable()
Disables the reaction.
|
void |
enable()
Enables the reaction.
|
protected void |
postReact(EVENT event)
post-
ObjectEventReact#react(IWorldEvent) hook allowing you to do additional work after the react method. |
protected void |
preReact(EVENT event)
pre-
ObjectEventReact#react(IWorldEvent) hook allowing you to do additional work before the react method. |
protected abstract void |
react(EVENT event)
React upon event notification.
|
protected static final int LEVEL_B_EVENT
protected static final int LEVEL_C_EVENT
protected static final int LEVEL_D_EVENT
protected static final int LEVEL_E_EVENT
protected IWorldObjectEventListener<OBJECT extends IWorldObject,EVENT extends IWorldObjectEvent<OBJECT>> reactListener
protected IWorldView reactWorldView
protected Class reactEventClass
protected Class reactObjectClass
protected WorldObjectId reactObjectId
protected final int reactObjectEventType
public ObjectEventReact(Class<?> objectClass, IWorldView worldView)
public ObjectEventReact(Class<?> objectClass, Class<?> eventClass, IWorldView worldView)
public ObjectEventReact(WorldObjectId objectId, IWorldView worldView)
public ObjectEventReact(WorldObjectId objectId, Class<?> eventClass, IWorldView worldView)
public void disable()
public void enable()
protected void preReact(EVENT event)
ObjectEventReact#react(IWorldEvent) hook allowing you to do additional work before the react method.event - protected abstract void react(EVENT event)
event - protected void postReact(EVENT event)
ObjectEventReact#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.