From 15b511e694f976686fdec1fb9f959f8a92f3b594 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 23 Feb 2019 12:02:00 -0500 Subject: More ranges stuff! Now with custom views --- src/simulation.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/simulation.h') 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 @@ #include "renderer.h" #include "schedule.h" #include "grid_cache.h" +#include #include #include #include @@ -14,8 +15,6 @@ class Level; class Simulation { public: - using id_type = std::vector::size_type; - // Constructor explicit Simulation(const Level& level); @@ -47,13 +46,27 @@ public: return level_; } + auto entityView() + { + return ranges::view::transform([&] (id_type id) -> Entity& { + return entities_.at(id); + }); + } + + auto entityView() const + { + return ranges::view::transform([&] (id_type id) -> const Entity& { + return entities_.at(id); + }); + } + private: bool moveEntityOnGrid( - id_type id, + Entity& entity, Direction moveDir, bool validate = false); -- cgit 1.4.1