summary refs log tree commit diff stats
path: root/src/simulation.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulation.h')
-rw-r--r--src/simulation.h13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/simulation.h b/src/simulation.h index 4d41b49..f86d513 100644 --- a/src/simulation.h +++ b/src/simulation.h
@@ -3,11 +3,11 @@
3 3
4#include "entity.h" 4#include "entity.h"
5#include "renderer.h" 5#include "renderer.h"
6#include "schedule.h"
7#include "grid_cache.h"
6#include <vector> 8#include <vector>
7#include <deque> 9#include <deque>
8#include <set> 10#include <set>
9#include <unordered_map>
10#include <unordered_set>
11 11
12class Level; 12class Level;
13 13
@@ -17,7 +17,7 @@ public:
17 using id_type = std::vector<Entity>::size_type; 17 using id_type = std::vector<Entity>::size_type;
18 18
19 // Constructor 19 // Constructor
20 explicit Simulation(const Level& level) : level_(level) {} 20 explicit Simulation(const Level& level);
21 21
22 void tick( 22 void tick(
23 double dt, 23 double dt,
@@ -47,15 +47,12 @@ public:
47 return level_; 47 return level_;
48 } 48 }
49 49
50 void setGridPos(id_type id, vec2s pos);
51
52 static vec2s posInDir(vec2s orig, Direction dir); 50 static vec2s posInDir(vec2s orig, Direction dir);
53 51
54private: 52private:
55 53
56 54
57 55
58 const std::unordered_set<id_type>& getGridEntities(vec2s pos) const;
59 56
60 bool moveEntityOnGrid( 57 bool moveEntityOnGrid(
61 id_type id, 58 id_type id,
@@ -63,12 +60,14 @@ private:
63 bool validate = false); 60 bool validate = false);
64 61
65 const Level& level_; 62 const Level& level_;
63 Schedule schedule_ { 120 };
66 64
67 std::vector<Entity> entities_; 65 std::vector<Entity> entities_;
68 std::deque<id_type> available_; 66 std::deque<id_type> available_;
69 std::set<id_type> active_; 67 std::set<id_type> active_;
70 68
71 mutable std::unordered_map<size_t, std::unordered_set<id_type>> gridCache_; 69 mutable GridCache<id_type> posCache_ { level_ };
70 mutable GridCache<id_type> moveToCache_ { level_ };
72}; 71};
73 72
74#endif /* end of include guard: SIMULATION_H_7BF6EEA4 */ 73#endif /* end of include guard: SIMULATION_H_7BF6EEA4 */