diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-02-23 12:02:00 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-02-23 12:02:00 -0500 |
| commit | 15b511e694f976686fdec1fb9f959f8a92f3b594 (patch) | |
| tree | 18c0a234bbbfd34592a371d15dbfbecbede906c8 /src/simulation.h | |
| parent | 26fbd8c1edaf94513d9750681edbe449b699efe4 (diff) | |
| download | dispatcher-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.h | 19 |
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; | |||
| 14 | class Simulation { | 15 | class Simulation { |
| 15 | public: | 16 | public: |
| 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 | |||
| 50 | private: | 63 | private: |
| 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 | ||
