aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/ReplaySystem.h
blob: bbc8d7679b9db4dfd734cdda100dfa209d445f74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include "../manager/ReplayManager.h"
#include "../manager/SystemManager.h"

#include "System.h"

namespace crepe {

/**
 * \brief ReplayManager helper system
 *
 * This system records and replays recordings using ReplayManager.
 */
class ReplaySystem : public System {
public:
	using System::System;

	void fixed_update() override;

private:
	//! Last ReplayManager state
	ReplayManager::State last_state = ReplayManager::IDLE;

	/**
	 * \brief Playback snapshot
	 *
	 * When starting playback, the component state is saved and most systems are disabled. This
	 * struct stores the engine state before ReplayManager::play is called.
	 */
	struct Snapshot {
		ComponentManager::Snapshot components;
		SystemManager::Snapshot systems;
	};
	//! Before playback snapshot
	Snapshot playback;

	//! Snapshot state and disable systems during playback
	void playback_begin();
	//! Restore state from before \c playback_begin()
	void playback_end();
};

} // namespace crepe