aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/ReplaySystem.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 21:49:32 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-12-11 21:49:32 +0100
commitb9694e8cc6b85a0089f97ff3c21862adc75a7ee5 (patch)
treed5e85a8000e1b78f5617a792d9acd64f9465ecb5 /src/crepe/system/ReplaySystem.cpp
parent000062b462a3af86db4dac4d8c9e5ef32feb2996 (diff)
working proof of concept replay system
Diffstat (limited to 'src/crepe/system/ReplaySystem.cpp')
-rw-r--r--src/crepe/system/ReplaySystem.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/crepe/system/ReplaySystem.cpp b/src/crepe/system/ReplaySystem.cpp
index 5a90752..a6b8fb1 100644
--- a/src/crepe/system/ReplaySystem.cpp
+++ b/src/crepe/system/ReplaySystem.cpp
@@ -1,8 +1,8 @@
-#include "ScriptSystem.h"
-
+#include "../util/Log.h"
#include "../manager/ReplayManager.h"
#include "../manager/SystemManager.h"
+#include "RenderSystem.h"
#include "ReplaySystem.h"
using namespace crepe;
@@ -45,6 +45,7 @@ void ReplaySystem::update_playing() {
ReplayManager::Recording & recording = replay.recording;
if (recording.frames.size() == recording.frame) {
+ dbg_log("Finished playback");
this->playback_end();
return;
}
@@ -52,27 +53,33 @@ void ReplaySystem::update_playing() {
ComponentManager & components = this->mediator.component_manager;
ComponentManager::Snapshot & frame = recording.frames.at(recording.frame);
+ dbg_logf("Playing recording frame {}", recording.frame);
components.restore(frame);
recording.frame++;
}
void ReplaySystem::playback_begin() {
SystemManager & systems = this->mediator.system_manager;
- systems.get_system<ScriptSystem>().active = false;
- // TODO: store system active state
- // TODO: disable most systems
- // TODO: store components snapshot
-}
+ ComponentManager & components = this->mediator.component_manager;
-void ReplaySystem::playback_end() {
- ReplayManager & replay = this->mediator.replay_manager;
+ this->playback = {
+ .components = components.save(),
+ .systems = systems.save(),
+ };
- replay.state = ReplayManager::IDLE;
+ systems.disable_all();
+ systems.get_system<RenderSystem>().active = true;
+ systems.get_system<ReplaySystem>().active = true;
+}
+void ReplaySystem::playback_end() {
SystemManager & systems = this->mediator.system_manager;
- systems.get_system<ScriptSystem>().active = true;
+ ComponentManager & components = this->mediator.component_manager;
- // TODO: restore system active state snapshot
- // TODO: restore components snapshot
+ components.restore(this->playback.components);
+ systems.restore(this->playback.systems);
+
+ ReplayManager & replay = this->mediator.replay_manager;
+ replay.state = ReplayManager::IDLE;
}