diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-02-03 16:10:44 -0500 | 
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-02-03 16:10:44 -0500 | 
| commit | 8ffb27ab09ff567a159e5be5a243fd3967084977 (patch) | |
| tree | c7c1be31a4074a0d58191b9cc5ed880271c65b91 /src/simulation.h | |
| download | dispatcher-8ffb27ab09ff567a159e5be5a243fd3967084977.tar.gz dispatcher-8ffb27ab09ff567a159e5be5a243fd3967084977.tar.bz2 dispatcher-8ffb27ab09ff567a159e5be5a243fd3967084977.zip | |
Very basic ECS
Diffstat (limited to 'src/simulation.h')
| -rw-r--r-- | src/simulation.h | 57 | 
1 files changed, 57 insertions, 0 deletions
| 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 @@ | |||
| 1 | #ifndef SIMULATION_H_7BF6EEA4 | ||
| 2 | #define SIMULATION_H_7BF6EEA4 | ||
| 3 | |||
| 4 | #include "entity.h" | ||
| 5 | #include "renderer.h" | ||
| 6 | #include <vector> | ||
| 7 | #include <deque> | ||
| 8 | #include <set> | ||
| 9 | |||
| 10 | class Level; | ||
| 11 | |||
| 12 | class Simulation { | ||
| 13 | public: | ||
| 14 | |||
| 15 | using id_type = std::vector<Entity>::size_type; | ||
| 16 | |||
| 17 | // Constructor | ||
| 18 | explicit Simulation(const Level& level) : level_(level) {} | ||
| 19 | |||
| 20 | void tick( | ||
| 21 | double dt, | ||
| 22 | const Uint8* keystate); | ||
| 23 | |||
| 24 | id_type emplaceEntity(); | ||
| 25 | |||
| 26 | void deleteEntity(id_type id); | ||
| 27 | |||
| 28 | Entity& getEntity(id_type id) | ||
| 29 | { | ||
| 30 | return entities_.at(id); | ||
| 31 | } | ||
| 32 | |||
| 33 | const Entity& getEntity(id_type id) const | ||
| 34 | { | ||
| 35 | return entities_.at(id); | ||
| 36 | } | ||
| 37 | |||
| 38 | const std::set<id_type>& getActive() const | ||
| 39 | { | ||
| 40 | return active_; | ||
| 41 | } | ||
| 42 | |||
| 43 | const Level& getLevel() const | ||
| 44 | { | ||
| 45 | return level_; | ||
| 46 | } | ||
| 47 | |||
| 48 | private: | ||
| 49 | |||
| 50 | const Level& level_; | ||
| 51 | |||
| 52 | std::vector<Entity> entities_; | ||
| 53 | std::deque<id_type> available_; | ||
| 54 | std::set<id_type> active_; | ||
| 55 | }; | ||
| 56 | |||
| 57 | #endif /* end of include guard: SIMULATION_H_7BF6EEA4 */ | ||
