X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fworld%2Fsim.cpp;fp=src%2Fworld%2Fsim.cpp;h=8b4ecd47a7be431c1f7a7a392bfa6fd970f0d75b;hp=350d2440f0a8739a877bcbf86c6b7072bcca8477;hb=38db9a31695abef65ebc421f120a05219132b15f;hpb=f8c0f8706e51450ee0e87a548ccf3a66ee9f0db3 diff --git a/src/world/sim.cpp b/src/world/sim.cpp index 350d244..8b4ecd4 100644 --- a/src/world/sim.cpp +++ b/src/world/sim.cpp @@ -69,9 +69,8 @@ std::string Record::ValueString(int i) const { } } -Simulation::Simulation(Body &r, app::Assets &assets) -: root(r) -, assets(assets) +Simulation::Simulation(app::Assets &assets) +: assets(assets) , bodies() , planets() , suns() @@ -79,7 +78,6 @@ Simulation::Simulation(Body &r, app::Assets &assets) , dead() , time(0.0) , records(7) { - AddBody(r); records[0].name = "Age"; records[0].type = Record::TIME; records[1].name = "Mass"; @@ -126,6 +124,15 @@ void Simulation::AddSun(Sun &s) { suns.insert(&s); } +Planet &Simulation::PlanetByName(const std::string &name) { + for (auto &p : planets) { + if (p->Name() == name) { + return *p; + } + } + throw std::runtime_error("planet named \"" + name + "\" not found"); +} + void Simulation::SetAlive(creature::Creature *c) { alive.push_back(c); }