]> git.localhorst.tv Git - blobs.git/blob - src/world/Simulation.hpp
track a few things
[blobs.git] / src / world / Simulation.hpp
1 #ifndef BLOBS_WORLD_SIMULATION_HPP_
2 #define BLOBS_WORLD_SIMULATION_HPP_
3
4 #include "Record.hpp"
5 #include "Set.hpp"
6 #include "../app/Assets.hpp"
7
8 #include <set>
9 #include <vector>
10
11
12 namespace blobs {
13 namespace creature {
14         class Creature;
15 }
16 namespace world {
17
18 class Body;
19 class Planet;
20 class Resource;
21 class Sun;
22 class TileType;
23
24 class Simulation {
25
26 public:
27         explicit Simulation(Body &root, app::Assets &);
28         ~Simulation();
29
30         Simulation(const Simulation &) = delete;
31         Simulation &operator =(const Simulation &) = delete;
32
33         Simulation(Simulation &&) = delete;
34         Simulation &operator =(Simulation &&) = delete;
35
36 public:
37         void Tick(double dt);
38
39         Body &Root() noexcept { return root; }
40         const Body &Root() const noexcept { return root; }
41
42         app::Assets &Assets() noexcept { return assets; }
43         const app::Assets &Assets() const noexcept { return assets; }
44         const Set<Resource> &Resources() const noexcept { return assets.data.resources; }
45         const Set<TileType> &TileTypes() const noexcept { return assets.data.tile_types; }
46
47         void AddBody(Body &);
48         void AddPlanet(Planet &);
49         void AddSun(Sun &);
50
51         const std::set<Body *> &Bodies() const noexcept { return bodies; }
52         const std::set<Planet *> &Planets() const noexcept { return planets; }
53         const std::set<Sun *> &Suns() const noexcept { return suns; }
54
55         void SetAlive(creature::Creature *);
56         std::vector<creature::Creature *> &LiveCreatures() noexcept { return alive; }
57         const std::vector<creature::Creature *> &LiveCreatures() const noexcept { return alive; }
58
59         void SetDead(creature::Creature *);
60         std::vector<creature::Creature *> &DeadCreatures() noexcept { return dead; }
61         const std::vector<creature::Creature *> &DeadCreatures() const noexcept { return dead; }
62
63         double Time() const noexcept { return time; }
64
65         const std::vector<Record> &Records() const noexcept { return records; }
66         void CheckRecords(creature::Creature &) noexcept;
67
68 private:
69         Body &root;
70         app::Assets &assets;
71
72         std::set<Body *> bodies;
73         std::set<Planet *> planets;
74         std::set<Sun *> suns;
75
76         std::vector<creature::Creature *> alive;
77         std::vector<creature::Creature *> dead;
78
79         double time;
80         std::vector<Record> records;
81
82 };
83
84 }
85 }
86
87 #endif