add entity.despawn(...)

This commit is contained in:
MihailRis
2024-06-27 14:26:51 +03:00
parent 6d7f950410
commit e11760a5e4
4 changed files with 40 additions and 3 deletions
+10
View File
@@ -33,6 +33,16 @@ entityid_t Entities::spawn(EntityDef& def, glm::vec3 pos) {
return id;
}
void Entities::clean() {
for (auto it = entities.begin(); it != entities.end(); ++it) {
if (registry.valid(it->second)) {
++it;
} else {
it = entities.erase(it);
}
}
}
void Entities::updatePhysics(float delta){
auto view = registry.view<Transform, Rigidbody>();
auto physics = level->physics.get();