]> git.localhorst.tv Git - blobs.git/blob - src/world/Simulation.hpp
load universe from file
[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(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         app::Assets &Assets() noexcept { return assets; }
41         const app::Assets &Assets() const noexcept { return assets; }
42         const Set<Resource> &Resources() const noexcept { return assets.data.resources; }
43         const Set<TileType> &TileTypes() const noexcept { return assets.data.tile_types; }
44
45         void AddBody(Body &);
46         void AddPlanet(Planet &);
47         void AddSun(Sun &);
48
49         const std::set<Body *> &Bodies() const noexcept { return bodies; }
50         const std::set<Planet *> &Planets() const noexcept { return planets; }
51         const std::set<Sun *> &Suns() const noexcept { return suns; }
52         Planet &PlanetByName(const std::string &);
53
54         void SetAlive(creature::Creature *);
55         std::vector<creature::Creature *> &LiveCreatures() noexcept { return alive; }
56         const std::vector<creature::Creature *> &LiveCreatures() const noexcept { return alive; }
57
58         void SetDead(creature::Creature *);
59         std::vector<creature::Creature *> &DeadCreatures() noexcept { return dead; }
60         const std::vector<creature::Creature *> &DeadCreatures() const noexcept { return dead; }
61
62         double Time() const noexcept { return time; }
63
64         const std::vector<Record> &Records() const noexcept { return records; }
65         void CheckRecords(creature::Creature &) noexcept;
66         void LogRecord(const Record &);
67
68         std::ostream &Log();
69
70 private:
71         app::Assets &assets;
72
73         std::set<Body *> bodies;
74         std::set<Planet *> planets;
75         std::set<Sun *> suns;
76
77         std::vector<creature::Creature *> alive;
78         std::vector<creature::Creature *> dead;
79
80         double time;
81         std::vector<Record> records;
82
83 };
84
85 }
86 }
87
88 #endif