]> git.localhorst.tv Git - blobs.git/blob - src/world/sim.cpp
071ad17cb0ed5786a998334c6e0fc9cb03a3ac1f
[blobs.git] / src / world / sim.cpp
1 #include "Simulation.hpp"
2
3 #include "Body.hpp"
4 #include "Planet.hpp"
5 #include "Sun.hpp"
6
7
8 namespace blobs {
9 namespace world {
10
11 Simulation::Simulation(Body &r, const Set<Resource> &res, const Set<TileType> &tile)
12 : root(r)
13 , resources(res)
14 , tile_types(tile)
15 , bodies()
16 , planets()
17 , suns()
18 , time(0.0) {
19         AddBody(r);
20 }
21
22 Simulation::~Simulation() {
23 }
24
25
26 void Simulation::AddBody(Body &b) {
27         b.SetSimulation(*this);
28         bodies.insert(&b);
29 }
30
31 void Simulation::AddPlanet(Planet &p) {
32         AddBody(p);
33         planets.insert(&p);
34 }
35
36 void Simulation::AddSun(Sun &s) {
37         AddBody(s);
38         suns.insert(&s);
39 }
40
41 void Simulation::Tick() {
42         constexpr double dt = 0.01666666666666666666666666666666;
43         time += dt;
44         for (auto body : bodies) {
45                 body->Tick(dt);
46         }
47 }
48
49 }
50 }