diff options
Diffstat (limited to 'src/crepe/manager')
-rw-r--r-- | src/crepe/manager/SystemManager.cpp | 14 | ||||
-rw-r--r-- | src/crepe/manager/SystemManager.h | 8 | ||||
-rw-r--r-- | src/crepe/manager/SystemManager.hpp | 1 |
3 files changed, 16 insertions, 7 deletions
diff --git a/src/crepe/manager/SystemManager.cpp b/src/crepe/manager/SystemManager.cpp index 5ada30f..eabc022 100644 --- a/src/crepe/manager/SystemManager.cpp +++ b/src/crepe/manager/SystemManager.cpp @@ -19,12 +19,12 @@ SystemManager::SystemManager(Mediator & mediator) : Manager(mediator) { this->load_system<InputSystem>(); this->load_system<EventSystem>(); this->load_system<ScriptSystem>(); + this->load_system<ParticleSystem>(); this->load_system<AISystem>(); this->load_system<PhysicsSystem>(); this->load_system<CollisionSystem>(); this->load_system<AudioSystem>(); this->load_system<AnimatorSystem>(); - this->load_system<ParticleSystem>(); this->load_system<RenderSystem>(); this->load_system<ReplaySystem>(); @@ -32,16 +32,16 @@ SystemManager::SystemManager(Mediator & mediator) : Manager(mediator) { } void SystemManager::fixed_update() { - for (auto & [type, system] : this->systems) { - if (!system->active) continue; - system->fixed_update(); + for (System & system : this->system_order) { + if (!system.active) continue; + system.fixed_update(); } } void SystemManager::frame_update() { - for (auto & [type, system] : this->systems) { - if (!system->active) continue; - system->frame_update(); + for (System & system : this->system_order) { + if (!system.active) continue; + system.frame_update(); } } diff --git a/src/crepe/manager/SystemManager.h b/src/crepe/manager/SystemManager.h index 50acf77..614d90c 100644 --- a/src/crepe/manager/SystemManager.h +++ b/src/crepe/manager/SystemManager.h @@ -3,6 +3,7 @@ #include <memory> #include <typeindex> #include <unordered_map> +#include <vector> #include "../system/System.h" @@ -43,6 +44,13 @@ private: */ std::unordered_map<std::type_index, std::unique_ptr<System>> systems; /** + * \brief Collection of System instances + * + * This map holds System instances indexed by the system's class typeid. It is filled in the + * constructor of \c SystemManager using SystemManager::load_system. + */ + std::vector<std::reference_wrapper<System>> system_order; + /** * \brief Initialize a system * \tparam T System type (must be derivative of \c System) */ diff --git a/src/crepe/manager/SystemManager.hpp b/src/crepe/manager/SystemManager.hpp index 3d26e4c..8d06eb1 100644 --- a/src/crepe/manager/SystemManager.hpp +++ b/src/crepe/manager/SystemManager.hpp @@ -36,6 +36,7 @@ void SystemManager::load_system() { throw runtime_error(format("SystemManager: {} is already initialized", type.name())); System * system = new T(this->mediator); this->systems[type] = unique_ptr<System>(system); + this->system_order.push_back(*this->systems[type]); } } // namespace crepe |