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