X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fsim.cpp;h=8c3749f347bff8963783cb2f322c60f22da37683;hb=dd8b3145a03ed676b0ae6311c29fc3d68f666b15;hp=0e0b46616694dfd9bf05fbf7089a3cb21b831024;hpb=be413456f57da06e918ae7bf4c4f35e5198ff7ce;p=blobs.git diff --git a/src/world/sim.cpp b/src/world/sim.cpp index 0e0b466..8c3749f 100644 --- a/src/world/sim.cpp +++ b/src/world/sim.cpp @@ -1,18 +1,47 @@ #include "Simulation.hpp" +#include "Body.hpp" +#include "Planet.hpp" +#include "Sun.hpp" + namespace blobs { namespace world { -Simulation::Simulation(Body &r) -: root(r) { +Simulation::Simulation(Body &r, app::Assets &assets) +: root(r) +, assets(assets) +, bodies() +, planets() +, suns() +, time(0.0) { + AddBody(r); } Simulation::~Simulation() { } -void Simulation::Tick() { +void Simulation::AddBody(Body &b) { + b.SetSimulation(*this); + 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(double dt) { + time += dt; + for (auto body : bodies) { + body->Tick(dt); + } } }