diff options
Diffstat (limited to 'src/crepe/manager')
-rw-r--r-- | src/crepe/manager/SystemManager.cpp | 30 | ||||
-rw-r--r-- | src/crepe/manager/SystemManager.h | 13 | ||||
-rw-r--r-- | src/crepe/manager/SystemManager.hpp | 5 |
3 files changed, 12 insertions, 36 deletions
diff --git a/src/crepe/manager/SystemManager.cpp b/src/crepe/manager/SystemManager.cpp index fea59aa..eabc022 100644 --- a/src/crepe/manager/SystemManager.cpp +++ b/src/crepe/manager/SystemManager.cpp @@ -31,31 +31,17 @@ SystemManager::SystemManager(Mediator & mediator) : Manager(mediator) { this->mediator.system_manager = *this; } -void SystemManager::fixed_update() noexcept { - for (SystemEntry & entry : this->system_order) { - if (!entry.system.active) continue; - try { - entry.system.fixed_update(); - } catch (const exception & e) { - Log::logf( - Log::Level::WARNING, "Uncaught exception in {} fixed update: {}", entry.name, - e.what() - ); - } +void SystemManager::fixed_update() { + for (System & system : this->system_order) { + if (!system.active) continue; + system.fixed_update(); } } -void SystemManager::frame_update() noexcept { - for (SystemEntry & entry : this->system_order) { - if (!entry.system.active) continue; - try { - entry.system.frame_update(); - } catch (const exception & e) { - Log::logf( - Log::Level::WARNING, "Uncaught exception in {} frame update: {}", entry.name, - e.what() - ); - } +void SystemManager::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 7b862a3..614d90c 100644 --- a/src/crepe/manager/SystemManager.h +++ b/src/crepe/manager/SystemManager.h @@ -26,14 +26,14 @@ public: * * Updates the game state based on the elapsed time since the last frame. */ - void frame_update() noexcept; + void frame_update(); /** * \brief Fixed update executed at a fixed rate. * * This function updates physics and game logic based on LoopTimer's fixed_delta_time. */ - void fixed_update() noexcept; + void fixed_update(); private: /** @@ -43,20 +43,13 @@ private: * constructor of \c SystemManager using SystemManager::load_system. */ std::unordered_map<std::type_index, std::unique_ptr<System>> systems; - //! Internal ordered system list entry - struct SystemEntry { - //! System instance reference - System & system; - //! System name - std::string name; - }; /** * \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<SystemEntry> system_order; + 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 a19a253..addd274 100644 --- a/src/crepe/manager/SystemManager.hpp +++ b/src/crepe/manager/SystemManager.hpp @@ -38,10 +38,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(SystemEntry { - .system = *this->systems[type], - .name = type.name(), - }); + this->system_order.push_back(*this->systems[type]); } } // namespace crepe |