]> git.localhorst.tv Git - blank.git/blobdiff - src/world/World.cpp
make entities removable
[blank.git] / src / world / World.cpp
index 97dcc0848a40a7936179ee7e4171aac8c29f1fd1..dc078189fdc494ab98bbb8dc93aeb4c12a565809 100644 (file)
@@ -257,6 +257,13 @@ void World::Update(int dt) {
                        Resolve(entity, col);
                }
        }
+       for (auto iter = entities.begin(), end = entities.end(); iter != end;) {
+               if (iter->CanRemove()) {
+                       iter = entities.erase(iter);
+               } else {
+                       ++iter;
+               }
+       }
        chunks.Rebase(player->ChunkCoords());
        chunks.Update(dt);
 }