]> git.localhorst.tv Git - blobs.git/blobdiff - src/world/world.cpp
split creature when it's "ripe" lol
[blobs.git] / src / world / world.cpp
index 0b1260f8673d8a0eb1b054bec81847b61602d711..91f9bc6751fbaedcda6f67fd1378720c87eda680 100644 (file)
@@ -8,12 +8,12 @@
 #include "Tile.hpp"
 #include "TileType.hpp"
 
-#include "../const.hpp"
 #include "../app/Assets.hpp"
 #include "../creature/Creature.hpp"
 #include "../graphics/Viewport.hpp"
-#include "../rand/OctaveNoise.hpp"
-#include "../rand/SimplexNoise.hpp"
+#include "../math/const.hpp"
+#include "../math/OctaveNoise.hpp"
+#include "../math/SimplexNoise.hpp"
 
 #include <algorithm>
 #include <cmath>
@@ -144,6 +144,14 @@ void Body::Tick(double dt) {
        for (creature::Creature *c : Creatures()) {
                c->Tick(dt);
        }
+       for (auto c = Creatures().begin(); c != Creatures().end();) {
+               if ((*c)->Removable()) {
+                       delete *c;
+                       c = Creatures().erase(c);
+               } else {
+                       ++c;
+               }
+       }
 }
 
 void Body::Cache() noexcept {
@@ -421,8 +429,8 @@ void Planet::Draw(app::Assets &assets, graphics::Viewport &viewport) {
 
 
 void GenerateEarthlike(const Set<TileType> &tiles, Planet &p) noexcept {
-       rand::SimplexNoise elevation_gen(0);
-       rand::SimplexNoise variation_gen(45623752346);
+       math::SimplexNoise elevation_gen(0);
+       math::SimplexNoise variation_gen(45623752346);
 
        const int ice = tiles["ice"].id;
        const int ocean = tiles["ocean"].id;
@@ -460,7 +468,7 @@ void GenerateEarthlike(const Set<TileType> &tiles, Planet &p) noexcept {
                                        p.TileAt(surface, x, y).type = ice;
                                        continue;
                                }
-                               float elevation = rand::OctaveNoise(
+                               float elevation = math::OctaveNoise(
                                        elevation_gen,
                                        to_tile / p.Radius(),
                                        3,   // octaves
@@ -469,7 +477,7 @@ void GenerateEarthlike(const Set<TileType> &tiles, Planet &p) noexcept {
                                        2,   // amplitude
                                        2    // growth
                                );
-                               float variation = rand::OctaveNoise(
+                               float variation = math::OctaveNoise(
                                        variation_gen,
                                        to_tile / p.Radius(),
                                        3,   // octaves