blob: fbe0a4388339a6d79005d832b19caf8a03e5cd6f (
plain) (
blame)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#ifndef SIMULATION_H_7BF6EEA4
#define SIMULATION_H_7BF6EEA4
#include "entity.h"
#include "renderer.h"
#include "schedule.h"
#include "grid_cache.h"
#include <vector>
#include <deque>
#include <set>
class Level;
class Simulation {
public:
using id_type = std::vector<Entity>::size_type;
// Constructor
explicit Simulation(const Level& level);
void tick(
double dt,
const Uint8* keystate);
id_type emplaceEntity();
void deleteEntity(id_type id);
Entity& getEntity(id_type id)
{
return entities_.at(id);
}
const Entity& getEntity(id_type id) const
{
return entities_.at(id);
}
const std::set<id_type>& getActive() const
{
return active_;
}
const Level& getLevel() const
{
return level_;
}
private:
bool moveEntityOnGrid(
id_type id,
Direction moveDir,
bool validate = false);
const Level& level_;
Schedule schedule_ { 90 };
std::vector<Entity> entities_;
std::deque<id_type> available_;
std::set<id_type> active_;
mutable GridCache<id_type> posCache_ { level_ };
mutable GridCache<id_type> moveToCache_ { level_ };
};
#endif /* end of include guard: SIMULATION_H_7BF6EEA4 */
|