#ifndef SIMULATION_H_7BF6EEA4 #define SIMULATION_H_7BF6EEA4 #include "state.h" #include "entity.h" #include "schedule.h" #include #include #include #include class Level; class Simulation : public State { public: // Constructor explicit Simulation(const Level& level); void tick( double dt, const Uint8* keystate) override; void render(SDL_Renderer* ren) override; 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& getActive() const { return active_; } const Level& getLevel() const { 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); }); } auto entityRange() { return active_ | entityView(); } auto entityRange() const { return active_ | entityView(); } private: bool moveEntityOnGrid( Entity& entity, Direction moveDir, bool validate = false); const Level& level_; Schedule schedule_ { 90 }; std::vector entities_; std::deque available_; std::set active_; texture_ptr renderedMap_; }; #endif /* end of include guard: SIMULATION_H_7BF6EEA4 */