User Tools


AnnEventManager

Annwvyn's Event System permit you to declare and register “event listeners” that will permit you to react to user inputs and multiple types of event happening in-engine

Event system presentation

AnnEngine will instantiate an AnnEventManager object. AnnEventManager receive user's inputs, spatial triggers and timers timeouts and send them as convinient AnnEvent object to EventListeners

Put a diagram showing the observer desing pattern used, and the AnnEvent inheritance

Event Listeners

Event Listeners are custom classes you have to write to get the event. They are pretty easy to declare

#include <Annwvyn.h>
 
using namespace Annwvyn;
 
class MyEventListener : LISTENER
{
    public:
    MyEventListener();
};
 
MyEventListener::MyEventListener(): constructListener()
{
}

You can override any of the AnnEventListener methods you want. They will be called when the said type of event is going through.

Explain AnnUserSpaceEvent particularities

Registering Event Listeners

AnnEventManager keeps a list of weak_ptr to all AnnEventListener “registered” via AnnEventManager::addListener();

This means that you keep ownership of your listener object. You should “unregistered” the listener before letting it go out of scope, this will prevent AnnEventManager to pointlessly try to lock the dangling weak pointer.