Merge pull request #480 from MihailRis/despawned-entities-save-fix
fix: entity:despawn in on_save not preventing entity save
This commit is contained in:
commit
aa80bbb14f
@ -370,12 +370,15 @@ dv::value Entities::serialize(const Entity& entity) {
|
|||||||
dv::value Entities::serialize(const std::vector<Entity>& entities) {
|
dv::value Entities::serialize(const std::vector<Entity>& entities) {
|
||||||
auto list = dv::list();
|
auto list = dv::list();
|
||||||
for (auto& entity : entities) {
|
for (auto& entity : entities) {
|
||||||
if (!entity.getDef().save.enabled) {
|
const EntityId& eid = entity.getID();
|
||||||
|
if (!entity.getDef().save.enabled || eid.destroyFlag) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
level.entities->onSave(entity);
|
level.entities->onSave(entity);
|
||||||
|
if (!eid.destroyFlag) {
|
||||||
list.add(level.entities->serialize(entity));
|
list.add(level.entities->serialize(entity));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,9 +600,9 @@ bool Entities::hasBlockingInside(AABB aabb) {
|
|||||||
|
|
||||||
std::vector<Entity> Entities::getAllInside(AABB aabb) {
|
std::vector<Entity> Entities::getAllInside(AABB aabb) {
|
||||||
std::vector<Entity> collected;
|
std::vector<Entity> collected;
|
||||||
auto view = registry.view<Transform>();
|
auto view = registry.view<EntityId, Transform>();
|
||||||
for (auto [entity, transform] : view.each()) {
|
for (auto [entity, eid, transform] : view.each()) {
|
||||||
if (aabb.contains(transform.pos)) {
|
if (!eid.destroyFlag && aabb.contains(transform.pos)) {
|
||||||
const auto& found = uids.find(entity);
|
const auto& found = uids.find(entity);
|
||||||
if (found == uids.end()) {
|
if (found == uids.end()) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user