diff --git a/SHADE_Engine/src/Events/SHEventManager.cpp b/SHADE_Engine/src/Events/SHEventManager.cpp index 2b4d15f1..1cede2a0 100644 --- a/SHADE_Engine/src/Events/SHEventManager.cpp +++ b/SHADE_Engine/src/Events/SHEventManager.cpp @@ -16,16 +16,7 @@ namespace SHADE std::unordered_map SHEventManager::dataEventMap; SHEventHandle SHEventManager::handleCounter{ 0 }; - - - /**************************************************************************** - * \brief Returns function pointer to entry point for events. - ****************************************************************************/ - EventManagerListener SHEventManager::GetListenerFunction() - { - return &CatchEvent; - } - + /**************************************************************************** * \param ListenerConstPtr - Const pointer to listener that sent event. * \param EventType - Templated type for every type of event diff --git a/SHADE_Engine/src/Events/SHEventManager.h b/SHADE_Engine/src/Events/SHEventManager.h index 35acd4de..fd09d323 100644 --- a/SHADE_Engine/src/Events/SHEventManager.h +++ b/SHADE_Engine/src/Events/SHEventManager.h @@ -17,7 +17,33 @@ /****************************************************************************** INSTRUCTIONS FOR USE: On broadcaster side: - 1. + 1. Create a struct/class to contain the data that you would need to send + in the event. + 2. Create unique event identifier in SHEventDefines.h, follow the example + provided. + 3. When ready to send the event, call + SHEventManager::BroadcastEvent(exampleClass, EVENT_IDENTIFIER); + + Headers required: SHEventManager.h + + On Receiver side: + 1. Create a function with the signature: + SHEventHandle FunctionName(SHEvent); + 2. In the init function of the class, copy the below in and replace the + necessary: + + std::shared_ptr> thisReceiver{ + std::make_shared>(this, &ReceiverClass::ReceiveFunction) + }; + ReceiverPtr receiver = std::dynamic_pointer_cast(thisReceiver); + SHEventManager::SubscribeTo(EVENT_IDENTIFIER, receiver); + + 3. Note: The EventIdentifier should match all that is defined in + SHEventDefines.h so check there. When the receiver catches the event, it + needs to know the struct that the broadcaster is using to cast the void* + properly. + + Headers required: SHEventManager.h, SHEventReceiver.h ******************************************************************************/ namespace SHADE @@ -32,10 +58,6 @@ namespace SHADE class SHEventManager { public: - /**************************************************************************** - * \brief Returns function pointer to entry point for events. - ****************************************************************************/ - static EventManagerListener GetListenerFunction(); /**************************************************************************** * \param ListenerConstPtr - Const pointer to listener that sent event. @@ -86,4 +108,5 @@ namespace SHADE static void RegisterReceiverToType(SHEventIdentifier, ReceiverPtr); }; + }