diff options
author | max-001 <maxsmits21@kpnmail.nl> | 2024-12-20 12:01:36 +0100 |
---|---|---|
committer | max-001 <maxsmits21@kpnmail.nl> | 2024-12-20 12:01:36 +0100 |
commit | 79d3a9f4311e6684b6df83a15ca7844f58c1959c (patch) | |
tree | b2883e83f61cee9edf290a6a7228c7f0b1fbae8a /src/crepe/manager/SystemManager.cpp | |
parent | 9140b73e4af7aa925b53e4fb4e6aa7f4ea2e3385 (diff) | |
parent | 03aea832aa0bc2edba2cc5ab4d9f8eba42d355be (diff) |
Merge remote-tracking branch 'origin/master' into max/game
Diffstat (limited to 'src/crepe/manager/SystemManager.cpp')
-rw-r--r-- | src/crepe/manager/SystemManager.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/crepe/manager/SystemManager.cpp b/src/crepe/manager/SystemManager.cpp new file mode 100644 index 0000000..5ada30f --- /dev/null +++ b/src/crepe/manager/SystemManager.cpp @@ -0,0 +1,66 @@ +#include "../system/AISystem.h" +#include "../system/AnimatorSystem.h" +#include "../system/AudioSystem.h" +#include "../system/CollisionSystem.h" +#include "../system/EventSystem.h" +#include "../system/InputSystem.h" +#include "../system/ParticleSystem.h" +#include "../system/PhysicsSystem.h" +#include "../system/RenderSystem.h" +#include "../system/ReplaySystem.h" +#include "../system/ScriptSystem.h" + +#include "SystemManager.h" + +using namespace crepe; +using namespace std; + +SystemManager::SystemManager(Mediator & mediator) : Manager(mediator) { + this->load_system<InputSystem>(); + this->load_system<EventSystem>(); + this->load_system<ScriptSystem>(); + 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>(); + + this->mediator.system_manager = *this; +} + +void SystemManager::fixed_update() { + for (auto & [type, system] : this->systems) { + if (!system->active) continue; + system->fixed_update(); + } +} + +void SystemManager::frame_update() { + for (auto & [type, system] : this->systems) { + if (!system->active) continue; + system->frame_update(); + } +} + +SystemManager::Snapshot SystemManager::save() { + Snapshot snapshot; + for (auto & [type, system] : this->systems) { + snapshot[type] = system->active; + } + return snapshot; +} + +void SystemManager::restore(const Snapshot & snapshot) { + for (auto & [type, active] : snapshot) { + this->systems[type]->active = active; + } +} + +void SystemManager::disable_all() { + for (auto & [type, system] : this->systems) { + system->active = false; + } +} |