mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 22:54:34 +00:00
Event manager priority chaining
listeners can register with a priority to get an event into an ordered stream of listeners
This commit is contained in:
parent
562756a306
commit
299d358d0b
2 changed files with 63 additions and 42 deletions
|
|
@ -47,11 +47,13 @@ class EventManagerListener : public Dispatcher::IMessageListener
|
|||
/// Stores subscription information for a subscriber.
|
||||
struct Subscriber
|
||||
{
|
||||
SimObjectPtr< SimObject > listener; ///< The listener object.
|
||||
StringTableEntry callback; ///< The callback to execute when the event is triggered.
|
||||
StringTableEntry event; ///< The event being listened for.
|
||||
U32 callDepth;
|
||||
bool removeFlag;
|
||||
SimObjectPtr< SimObject > listener; ///< The listener object.
|
||||
StringTableEntry callback; ///< The callback to execute when the event is triggered.
|
||||
StringTableEntry event; ///< The event being listened for.
|
||||
|
||||
S32 priority;
|
||||
U32 callDepth;
|
||||
bool removeFlag;
|
||||
};
|
||||
|
||||
/// Subscriber table hashed by event name.
|
||||
|
|
@ -154,7 +156,7 @@ public:
|
|||
/// Triggers an event.
|
||||
bool postEvent( const char* eventName, const char* data );
|
||||
/// Adds a subscription to an event.
|
||||
bool subscribe( SimObject *callbackObj, const char* event, const char* callback = NULL );
|
||||
bool subscribe( SimObject *callbackObj, const char* event, const char* callback = NULL, S32 priority = 0 );
|
||||
/// Remove a subscriber from an event.
|
||||
void remove( SimObject *cbObj, const char* event );
|
||||
void removeAll( SimObject *cbObj );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue