blob: 445a8bff3cae228b2260fe5924ce4f50f625912c (
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
45
46
47
48
49
50
51
52
53
54
55
56
|
#pragma once
#include <thread>
#include <chrono>
#include <stack>
#include <mutex>
#include "People.h"
#include "Canvas.h"
#include "CollisionContext.h"
#include "PathfindingContext.h"
using namespace std::chrono_literals;
class Museum {
public:
Museum();
virtual ~Museum();
public:
People people;
Canvas canvas;
CollisionContext collision;
PathfindingContext pathfinding;
public:
bool paused = true;
void update();
void skip_forward();
void skip_backward();
private:
int jump = 0;
std::mutex jump_mutex;
void process_jump();
private:
bool working = true;
std::thread * worker = nullptr;
void work();
private:
unsigned long long tick = 0;
static constexpr std::chrono::milliseconds tick_interval = 15ms;
private:
static constexpr unsigned snapshot_ticks = 50;
struct Snapshot {
unsigned long long tick;
Memories memories;
};
std::stack<Snapshot, std::vector<Snapshot>> history;
Snapshot save_snapshot();
void restore_snapshot(const Snapshot &);
};
|