]> git.localhorst.tv Git - blobs.git/blobdiff - src/creature/creature.cpp
brake hard, not break hard
[blobs.git] / src / creature / creature.cpp
index deb5a10e4173376ca27e3e9434459f570350367f..396385e9ce33253c512eea680c1f9a3ee255da5a 100644 (file)
@@ -266,7 +266,7 @@ void Creature::AddParent(Creature &p) {
 }
 
 double Creature::Age() const noexcept {
-       return sim.Time() - birth;
+       return Dead() ? death - birth : sim.Time() - birth;
 }
 
 double Creature::AgeFactor(double peak) const noexcept {
@@ -756,7 +756,7 @@ void Split(Creature &c) {
        // TODO: duplicate situation somehow
        a->GetSituation().SetPlanetSurface(
                s.GetPlanet(),
-               s.Position() + glm::dvec3(0.0, 0.55 * a->Size(), 0.0));
+               s.Position() + glm::rotate(s.Heading() * a->Size() * 0.6, PI * 0.5, s.SurfaceNormal()));
        a->BuildVAO();
        c.GetSimulation().Log() << a->Name() << " was born" << std::endl;
 
@@ -770,7 +770,7 @@ void Split(Creature &c) {
        s.GetPlanet().AddCreature(b);
        b->GetSituation().SetPlanetSurface(
                s.GetPlanet(),
-               s.Position() - glm::dvec3(0.0, 0.55 * b->Size(), 0.0));
+               s.Position() + glm::rotate(s.Heading() * b->Size() * 0.6, PI * -0.5, s.SurfaceNormal()));
        b->BuildVAO();
        c.GetSimulation().Log() << b->Name() << " was born" << std::endl;
 
@@ -891,6 +891,10 @@ bool Situation::OnSurface() const noexcept {
        return type == PLANET_SURFACE;
 }
 
+glm::dvec3 Situation::SurfaceNormal() const noexcept {
+       return planet->NormalAt(state.pos);
+}
+
 world::Tile &Situation::GetTile() const noexcept {
        return planet->TileAt(state.pos);
 }
@@ -1003,8 +1007,8 @@ glm::dvec3 Steering::Force(const Situation::State &s) const noexcept {
                result += repulse;
        }
        if (halting) {
-               // break twice as hard
-               result += -2.0 * s.vel * force;
+               // brake hard
+               result += -5.0 * s.vel * force;
        }
        if (seeking) {
                glm::dvec3 diff = target - s.pos;