]> git.localhorst.tv Git - blobs.git/blobdiff - src/world/sim.cpp
load universe from file
[blobs.git] / src / world / sim.cpp
index 350d2440f0a8739a877bcbf86c6b7072bcca8477..8b4ecd47a7be431c1f7a7a392bfa6fd970f0d75b 100644 (file)
@@ -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);
 }