From b9694e8cc6b85a0089f97ff3c21862adc75a7ee5 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 11 Dec 2024 21:49:32 +0100 Subject: working proof of concept replay system --- src/crepe/manager/SystemManager.cpp | 22 ++++++++++++++++++++++ src/crepe/manager/SystemManager.h | 6 ++++++ 2 files changed, 28 insertions(+) (limited to 'src/crepe/manager') diff --git a/src/crepe/manager/SystemManager.cpp b/src/crepe/manager/SystemManager.cpp index 8fd80a7..db7430e 100644 --- a/src/crepe/manager/SystemManager.cpp +++ b/src/crepe/manager/SystemManager.cpp @@ -8,6 +8,7 @@ #include "../system/RenderSystem.h" #include "../system/ScriptSystem.h" #include "../system/EventSystem.h" +#include "../system/ReplaySystem.h" #include "SystemManager.h" @@ -15,6 +16,7 @@ using namespace crepe; using namespace std; SystemManager::SystemManager(Mediator & mediator) : Manager(mediator) { + this->load_system(); this->load_system(); this->load_system(); this->load_system(); @@ -43,3 +45,23 @@ void SystemManager::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; + } +} + diff --git a/src/crepe/manager/SystemManager.h b/src/crepe/manager/SystemManager.h index 5726a5c..6cf7f2b 100644 --- a/src/crepe/manager/SystemManager.h +++ b/src/crepe/manager/SystemManager.h @@ -48,6 +48,12 @@ public: */ template T & get_system(); + +public: + typedef std::unordered_map Snapshot; + Snapshot save(); + void restore(const Snapshot & snapshot); + void disable_all(); }; } // namespace crepe -- cgit v1.2.3