Allowing entities to be deleted

This commit is contained in:
Zoe Roux
2021-06-01 14:48:15 +02:00
parent f8e5446946
commit 42a45a06ff
2 changed files with 6 additions and 1 deletions
+2
View File
@@ -122,5 +122,7 @@ namespace WAL
~Entity() = default;
//! @brief An entity is not assignable
Entity &operator=(const Entity &) = delete;
//! @brief An entity is move assignable.
Entity &operator=(Entity &&) = default;
};
} // namespace WAL
+4 -1
View File
@@ -133,7 +133,10 @@ namespace WAL
this->_fixedUpdate();
}
this->_update(dtime);
// TODO delete entities scheduled for deletion.
auto &entities = this->scene->getEntities();
entities.erase(std::remove_if(entities.begin(), entities.end(), [](auto &entity) {
return entity.shouldDelete();
}), entities.end());
callback(*this, state);
}
}