From 9a119f38bb7043832db29795e449008c36252b35 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Sun, 13 Dec 2015 20:05:48 +0100 Subject: [PATCH] Added events processing to SystemPipeline --- include/Engine/Core/SystemPipeline.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/Engine/Core/SystemPipeline.h b/include/Engine/Core/SystemPipeline.h index 0f32b422..78ebc966 100644 --- a/include/Engine/Core/SystemPipeline.h +++ b/include/Engine/Core/SystemPipeline.h @@ -25,6 +25,7 @@ public: void AddSystem(Arguments... args) { System* system = new T(m_EventBroker, args...); + m_Systems[typeid(T).name()] = system; if (std::is_base_of::value) { PureSystem* pureSystem = static_cast(system); @@ -32,9 +33,6 @@ public: m_PureSystems[pureSystem->m_ComponentType].push_back(pureSystem); } else { LOG_ERROR("Failed to add pure system \"%s\": Missing component type!", typeid(T).name()); - if (std::is_base_of::value) { - delete system; - } } } @@ -46,6 +44,12 @@ public: void Update(World* world, double dt) { + // Process events + for (auto& pair : m_Systems) { + m_EventBroker->Process(pair.first); + } + + // Update for (auto& pair : m_PureSystems) { const std::string& componentName = pair.first; auto& systems = pair.second; @@ -66,7 +70,8 @@ public: private: EventBroker* m_EventBroker; - std::unordered_map> m_PureSystems; + std::map m_Systems; + std::map> m_PureSystems; std::vector m_ImpureSystems; };