}
for (auto iter = entities.begin(), end = entities.end(); iter != end;) {
if (iter->CanRemove()) {
- iter = entities.erase(iter);
+ iter = RemoveEntity(iter);
} else {
++iter;
}
e.Move(final_disp);
}
+World::EntityHandle World::RemoveEntity(EntityHandle &eh) {
+ // check for player
+ auto player = std::find(players.begin(), players.end(), &*eh);
+ if (player != players.end()) {
+ players.erase(player);
+ }
+ return entities.erase(eh);
+}
+
void World::Render(Viewport &viewport) {
DirectionalLighting &entity_prog = viewport.EntityProgram();