From 8ffb27ab09ff567a159e5be5a243fd3967084977 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 3 Feb 2019 16:10:44 -0500 Subject: Very basic ECS --- src/simulation.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/simulation.h (limited to 'src/simulation.h') diff --git a/src/simulation.h b/src/simulation.h new file mode 100644 index 0000000..bc47642 --- /dev/null +++ b/src/simulation.h @@ -0,0 +1,57 @@ +#ifndef SIMULATION_H_7BF6EEA4 +#define SIMULATION_H_7BF6EEA4 + +#include "entity.h" +#include "renderer.h" +#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_; + } + +private: + + const Level& level_; + + std::vector entities_; + std::deque available_; + std::set active_; +}; + +#endif /* end of include guard: SIMULATION_H_7BF6EEA4 */ -- cgit 1.4.1