]> git.localhorst.tv Git - blobs.git/blobdiff - src/world/sim.cpp
split creature when it's "ripe" lol
[blobs.git] / src / world / sim.cpp
index 46454fd2952197311b72db9bfeace430a44bebdc..b6a198d7365a7336be1d7e224b6fe4aaddd1656b 100644 (file)
@@ -1,14 +1,19 @@
 #include "Simulation.hpp"
 
 #include "Body.hpp"
+#include "Planet.hpp"
+#include "Sun.hpp"
 
 
 namespace blobs {
 namespace world {
 
-Simulation::Simulation(Body &r)
+Simulation::Simulation(Body &r, app::Assets &assets)
 : root(r)
-, all_bodies()
+, assets(assets)
+, bodies()
+, planets()
+, suns()
 , time(0.0) {
        AddBody(r);
 }
@@ -19,14 +24,24 @@ Simulation::~Simulation() {
 
 void Simulation::AddBody(Body &b) {
        b.SetSimulation(*this);
-       all_bodies.push_back(&b);
+       bodies.insert(&b);
+}
+
+void Simulation::AddPlanet(Planet &p) {
+       AddBody(p);
+       planets.insert(&p);
+}
+
+void Simulation::AddSun(Sun &s) {
+       AddBody(s);
+       suns.insert(&s);
 }
 
 void Simulation::Tick() {
        constexpr double dt = 0.01666666666666666666666666666666;
        time += dt;
-       for (auto body : all_bodies) {
-               body->Rotation(body->Rotation() + dt * body->AngularMomentum() / body->Inertia());
+       for (auto body : bodies) {
+               body->Tick(dt);
        }
 }