fix destroyed entities validation
This commit is contained in:
@@ -34,7 +34,7 @@ entityid_t Entities::spawn(EntityDef& def, glm::vec3 pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Entities::clean() {
|
void Entities::clean() {
|
||||||
for (auto it = entities.begin(); it != entities.end(); ++it) {
|
for (auto it = entities.begin(); it != entities.end();) {
|
||||||
if (registry.valid(it->second)) {
|
if (registry.valid(it->second)) {
|
||||||
++it;
|
++it;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public:
|
|||||||
|
|
||||||
std::optional<Entity> get(entityid_t id) {
|
std::optional<Entity> get(entityid_t id) {
|
||||||
const auto& found = entities.find(id);
|
const auto& found = entities.find(id);
|
||||||
if (found != entities.end()) {
|
if (found != entities.end() && registry.valid(found->second)) {
|
||||||
return Entity(id, registry, found->second);
|
return Entity(id, registry, found->second);
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|||||||
Reference in New Issue
Block a user