Nimbus
0.2
A game... with arrows... which should be clouds
|
#include <EventSystem.h>
Classes | |
class | GlobalListener |
Public Member Functions | |
EventSystem (GameEntityId owner=0) | |
virtual | ~EventSystem (void) |
bool | registerListener (EventListener *listener, EventType type, filtermap filter=filtermap()) |
void | unregisterListener (EventListener *listener, EventType type, filtermap filter=filtermap()) |
void | fireEvent (EventType type, const payloadmap &payload=payloadmap(), EventListener *responder=NULL) |
Static Public Member Functions | |
static EventSystem * | initializeSingleton () |
static EventSystem * | getSingleton () |
The EventSystem framework handles the receving and dispatching of events to registered EventListeners.
The EventSystem is responsible for dispatching and allowing the firing of events to the registered EventListeners. EventListeners are registered and deregistered via their appropriate commands. When an EventListener is registered it will be registered to a specific type of event that that listener is built to handle.
The Events will be fired using EventSystem's functions. These events will be evaluated and distributed to their registered events.
All hail the glorious helix fossil.
EventType represents the type of event being fired or handled. These enumerations will be added to as the application expands.
Enumerator | |
---|---|
SHUTDOWN |
The shutdown event is fired when a system asks the program to exit. The event will be handled by the main application and will proceed to cleanly shutdown all subsystems. Payload: NONE |
TICK |
An event which fires at a given rate so that more expensive operations may be spaced out. Payload: NONE |
MOUSE_DOWN |
An event fired whenever a button on the mouse is pressed down. Payload: "ButtonPressed" => OIS::MouseButtonID "ScreenPosition" => Ogre::Vector2 |
MOUSE_UP |
An event fired whenever a button on the mouse is released. Payload: "ButtonPressed" => OIS::MouseButtonID "ScreenPosition" => Ogre::Vector2 |
MOUSE_UPDATE |
An event fired whenever the mouse moves. Payload: "ScreenPosition" => Ogre::Vector2 |
MOUSE_POSITION_UPDATE |
An event fired whenever the mouse moves. Payload: "Context" => std::string "ScreenPosition" => Ogre::Vector2 "WorldRay" => Ogre::Ray |
MOUSE_POSITION_START |
An event fired whenever the mouse moves. May not include a payload Payload: "Context" => std::string "ScreenPosition" => Ogre::Vector2 "WorldRay" => Ogre::Ray |
MOUSE_POSITION_END |
An event fired whenever the mouse moves. May not include a payload Payload: "Context" => std::string "ScreenPosition" => Ogre::Vector2 "WorldRay" => Ogre::Ray |
CREATE_ENTITY |
The event that causes the EntityFactory to produce a new entity of given type. Payload: "EntityType" => std::string "PositionVector" => Ogre::Vector3 // Absolute, world position (optional) "FacingVector" => Ogre::Vector3 // Facing vector, units in world absolute world space, begins at the object... have fun interpretting that (optional) "RotationVector" => Ogre::Vector3 // Absolute, rotation vector <pitch, yaw, roll> (optional) Responder Payload: "EntityId" => GameEntityId |
DESTROY_ENTITY |
The event that causes an entity to be dropped from the world and destroyed. (Don't worry... it's humane.) Payload: "EntityId" => GameEntityId |
SOAR_ENTITY |
The event which carries wind induced movement information. Handled by the flocking group associated with the given entity. Payload: "EntityId" => GameEntityId "PositionDelta" => Ogre::Vector3 |
TRANSLATE_ENTITY |
The event that translates an entity in virtual world space. Used to move the entity. Payload: "EntityId" => int "PositionVector" => Ogre::Vector3 // Absolute, world position (optional) "PositionDelta" => Ogre::Vector3 // Relative position vector, applied per frame (optional) "RotationVector" => Ogre::Vector3 // Absolute, rotation vector <pitch, yaw, roll> (optional) "RotationDelta" => Ogre::Vector3 // Relative rotation vector, applied per frame (optional) "ScaleVector" => Ogre::Vector3 // Scale vector, should be absolute scale factor with 1.0 being original size (optional) "FacingVector" => Ogre::Vector3 // Facing vector, units in world absolute world space, begins at the object (optional) |
ENTITY_TRANSLATED |
The event that notifies behaviours when the entity is actually translated. Payload: "EntityId" => int "PositionVector" => Ogre::Vector3 // Absolute, world position (optional) "FacingVector" => Ogre::Vector3 // The direction the entity is currently facing (optional) "RotationVector" => Ogre::Vector3 // The rotation <pitch, yaw, roll> vector (optional) "ScaleVector" => Ogre::Vector3 // Scale vector, should be absolute scale factor with 1.0 being original size (optional) |
TRANSLATION_QUERY |
The event that requests about an entity's position. Quite possibly a very bad idea to use en masse... which is, of course, what I intend to do (for lack of a better idea). Payload: "EntityId" => int Responder Payload: "PositionVector" => Ogre::Vector3 // Absolute, world position "FacingVector" => Ogre::Vector3 // The direction the entity is currently facing "RotationVector" => Ogre::Vector3 // The rotation <pitch, yaw, roll> vector |
FLOCK_UPDATE |
The event which lets a Flocking behaviour know its new entity list. Payload: "EntityId" => GameEntityId "EntityList" => list<GameEntityId> |
EventSystem::EventSystem | ( | GameEntityId | owner = 0 | ) |
EventSystem constructor, yep!
ownerId | The id of the owning entity. |
|
virtual |
EventSystem destructor, it DESTROYS THINGS!
void EventSystem::fireEvent | ( | EventType | type, |
const payloadmap & | payload = payloadmap() , |
||
EventListener * | responder = NULL |
||
) |
Fires an Event to the EventSystem to distribute to the appropriate listeners.
event | A reference to the Event to fire. |
type | The type of Event to fire. |
|
inlinestatic |
Gets the singleton.
NOTE: CAN return a null value if the EventSystem has not been initialized!!
|
static |
Initializes the global event system singleton.
bool EventSystem::registerListener | ( | EventListener * | listener, |
EventType | type, | ||
filtermap | filter = filtermap() |
||
) |
Used to register an EventListener to the system for a certain type of Event.
listener | A reference to an isntance of the listener for the Event type. |
type | The type of Event the listener would like to listen for. |
filter | The filter for the events which this listener should listen to. |
void EventSystem::unregisterListener | ( | EventListener * | listener, |
EventType | type, | ||
filtermap | filter = filtermap() |
||
) |
Used to deregister a previously registered EventListener.
listener | A reference to the EventListener to deregister. |
type | The type of Event the listener is registered to. |
filter | The filter for the event which this listener is listening to. |