summary refs log tree commit diff stats
path: root/src/simulation.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2019-02-23 12:02:00 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2019-02-23 12:02:00 -0500
commit15b511e694f976686fdec1fb9f959f8a92f3b594 (patch)
tree18c0a234bbbfd34592a371d15dbfbecbede906c8 /src/simulation.h
parent26fbd8c1edaf94513d9750681edbe449b699efe4 (diff)
downloaddispatcher-15b511e694f976686fdec1fb9f959f8a92f3b594.tar.gz
dispatcher-15b511e694f976686fdec1fb9f959f8a92f3b594.tar.bz2
dispatcher-15b511e694f976686fdec1fb9f959f8a92f3b594.zip
More ranges stuff! Now with custom views
Diffstat (limited to 'src/simulation.h')
-rw-r--r--src/simulation.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/simulation.h b/src/simulation.h index fbe0a43..a205796 100644 --- a/src/simulation.h +++ b/src/simulation.h
@@ -5,6 +5,7 @@
5#include "renderer.h" 5#include "renderer.h"
6#include "schedule.h" 6#include "schedule.h"
7#include "grid_cache.h" 7#include "grid_cache.h"
8#include <range/v3/all.hpp>
8#include <vector> 9#include <vector>
9#include <deque> 10#include <deque>
10#include <set> 11#include <set>
@@ -14,8 +15,6 @@ class Level;
14class Simulation { 15class Simulation {
15public: 16public:
16 17
17 using id_type = std::vector<Entity>::size_type;
18
19 // Constructor 18 // Constructor
20 explicit Simulation(const Level& level); 19 explicit Simulation(const Level& level);
21 20
@@ -47,13 +46,27 @@ public:
47 return level_; 46 return level_;
48 } 47 }
49 48
49 auto entityView()
50 {
51 return ranges::view::transform([&] (id_type id) -> Entity& {
52 return entities_.at(id);
53 });
54 }
55
56 auto entityView() const
57 {
58 return ranges::view::transform([&] (id_type id) -> const Entity& {
59 return entities_.at(id);
60 });
61 }
62
50private: 63private:
51 64
52 65
53 66
54 67
55 bool moveEntityOnGrid( 68 bool moveEntityOnGrid(
56 id_type id, 69 Entity& entity,
57 Direction moveDir, 70 Direction moveDir,
58 bool validate = false); 71 bool validate = false);
59 72