aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/crepe/manager/SystemManager.cpp15
-rw-r--r--src/crepe/manager/SystemManager.h8
-rw-r--r--src/crepe/manager/SystemManager.hpp1
3 files changed, 17 insertions, 7 deletions
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<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();
}
}
@@ -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 <memory>
+#include <vector>
#include <typeindex>
#include <unordered_map>
@@ -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