#ifndef SIMULATION_H_7BF6EEA4 #define SIMULATION_H_7BF6EEA4 #include "entity.h" #include "renderer.h" #include #include #include #include #include class Level; class Simulation { public: using id_type = std::vector::size_type; // Constructor explicit Simulation(const Level& level) : level_(level) {} void tick( double dt, const Uint8* keystate); 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_; } void setGridPos(id_type id, vec2s pos); static vec2s posInDir(vec2s orig, Direction dir); private: const std::unordered_set& getGridEntities(vec2s pos) const; bool moveEntityOnGrid( id_type id, Direction moveDir, bool validate = false); const Level& level_; std::vector entities_; std::deque available_; std::set active_; mutable std::unordered_map> gridCache_; }; #endif /* end of include guard: SIMULATION_H_7BF6EEA4 */