Class EventManager
java.lang.Object
gaiasky.event.EventManager
- All Implemented Interfaces:
IObserver
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidDispatches any telegrams with a timestamp that has expired.booleanhasSubscriptors(Event event) booleanisSubscribedTo(IObserver o, Event event) voidEvent notification call.voidRegister a new data-less event with the given source.voidRegister a new event with the given source and with the given data.voidpostDelayed(Event event, Object source, long delayMs, EventManager.TimeFrame frame, Object... data) Register a new event with the given type, data, delay and time frame.voidpostDelayed(Event event, Object source, long delayMs, Object... data) Register a new delayed event with the given type, data, delay and the default time frame.voidpostWaitUntilConsumer(Event event, Object source, Object... data) Register a new event with the given source and with the given data.static voidRegister a new event to the default event manager instance with the given source and data.static voidpublishDelayed(Event event, Object source, long delayMs, Object... data) Register a new delayed event in the default manager with the given type, data, delay and the default time frame.static voidpublishWaitUntilConsumer(Event event, Object source, Object... data) Register a new event with the given source and with the given data.voidremoveAllSubscriptions(IObserver listener) Unregister all the subscriptions of the given listener.voidremoveAllSubscriptions(IObserver... listeners) Unregister all the subscriptions of the given listeners.voidremoveRadioSubscriptions(com.badlogic.ashley.core.Entity entity) Remove all subscriptions ofEntityRadiofor the given entity.voidRegister a listener for the specified message code.voidSubscribe the given observer to the given event types.voidunsubscribe(IObserver listener, Event event) Unregister the specified listener for the specified message code.voidunsubscribe(IObserver listener, Event... events)
-
Field Details
-
instance
Singleton pattern
-
-
Constructor Details
-
EventManager
public EventManager()
-
-
Method Details
-
publish
-
publishDelayed
Register a new delayed event in the default manager with the given type, data, delay and the default time frame. The default time frame can be changed using the eventEvent.EVENT_TIME_FRAME_CMD. The event will be passed along after the specified delay time [ms] in the given time frame has passed.- Parameters:
event- The event.source- The source object, if any.delayMs- Milliseconds of delay in the given time frame.data- The event data.
-
publishWaitUntilConsumer
Register a new event with the given source and with the given data. The message is automatically dispatched if at least one consumer is present. Otherwise, it waits until a consumer is available.- Parameters:
event- The event.source- The source object, if any.data- The event data.
-
subscribe
-
subscribe
-
unsubscribe
-
unsubscribe
-
removeAllSubscriptions
Unregister all the subscriptions of the given listener.- Parameters:
listener- The listener to remove.
-
removeAllSubscriptions
Unregister all the subscriptions of the given listeners.- Parameters:
listeners- The listeners to remove.
-
removeRadioSubscriptions
public void removeRadioSubscriptions(com.badlogic.ashley.core.Entity entity) Remove all subscriptions ofEntityRadiofor the given entity.- Parameters:
entity- The entity.
-
clearAllSubscriptions
public void clearAllSubscriptions() -
post
-
post
-
postWaitUntilConsumer
Register a new event with the given source and with the given data. The message is automatically dispatched if at least one consumer is present. Otherwise, it waits until a consumer is available.- Parameters:
event- The event.source- The source object, if any.data- The event data.
-
postDelayed
Register a new delayed event with the given type, data, delay and the default time frame. The default time frame can be changed using the eventEvent.EVENT_TIME_FRAME_CMD. The event will be passed along after the specified delay time [ms] in the given time frame has passed.- Parameters:
event- The event.source- The source object, if any.delayMs- Milliseconds of delay in the given time frame.data- The event data.
-
postDelayed
public void postDelayed(Event event, Object source, long delayMs, EventManager.TimeFrame frame, Object... data) Register a new event with the given type, data, delay and time frame. The event will be passed along after the specified delay time [ms] in the given time frame has passed.- Parameters:
event- The event.source- The source object, if any.delayMs- Milliseconds of delay in the given time frame.frame- The time frame, either real time (user) or simulation time (simulation clock time).data- The event data.
-
dispatchDelayedMessages
public void dispatchDelayedMessages()Dispatches any telegrams with a timestamp that has expired. Any dispatched telegrams are removed from the queue.This method must be called each time through the main loop.
-
hasSubscriptors
-
isSubscribedTo
-
notify
-