From b291d662f79af8de95ab40de29a09f87470d0095 Mon Sep 17 00:00:00 2001 From: max-001 Date: Fri, 20 Dec 2024 12:24:59 +0100 Subject: pull 3bda25f from demo --- src/crepe/manager/SystemManager.cpp | 15 ++++++++------- src/crepe/manager/SystemManager.h | 8 ++++++++ src/crepe/manager/SystemManager.hpp | 1 + 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src/crepe') diff --git a/src/crepe/manager/SystemManager.cpp b/src/crepe/manager/SystemManager.cpp index 5ada30f..f029aa5 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(); this->load_system(); this->load_system(); + this->load_system(); this->load_system(); this->load_system(); this->load_system(); this->load_system(); this->load_system(); - this->load_system(); this->load_system(); this->load_system(); @@ -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(); } } @@ -64,3 +64,4 @@ void SystemManager::disable_all() { system->active = false; } } + diff --git a/src/crepe/manager/SystemManager.h b/src/crepe/manager/SystemManager.h index 50acf77..b4a001c 100644 --- a/src/crepe/manager/SystemManager.h +++ b/src/crepe/manager/SystemManager.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -42,6 +43,13 @@ private: * constructor of \c SystemManager using SystemManager::load_system. */ std::unordered_map> 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> 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); + this->system_order.push_back(*this->systems[type]); } } // namespace crepe -- cgit v1.2.3