aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/manager/ReplayManager.h
blob: c50196c343cf162074276d1192d603d35b13618d (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
#pragma once

#include "Manager.h"
#include "ComponentManager.h"
#include <unordered_map>

namespace crepe {

class ReplaySystem;
class Memento;

typedef size_t recording_t;

class ReplayManager : public Manager {
public:
	ReplayManager(Mediator & mediator);
	friend class ReplaySystem;

protected:
	void record_frame();

private:
	typedef std::vector<ComponentManager::Snapshot> Recording;

	bool recording = false;
	recording_t current_recording = -1;


	std::unordered_map<recording_t, std::unique_ptr<Recording>> memory;
public:
	void record_start();
	recording_t record_end();
	void play(recording_t handle);
	void release(recording_t handle);
};

} // namespace crepe