snapshot: review ::orphans functions

This commit is contained in:
Michele Caini
2023-03-24 16:33:40 +01:00
parent 2664b52559
commit 295c68841c

View File

@@ -265,11 +265,13 @@ public:
* @return A valid loader to continue restoring data.
*/
const basic_snapshot_loader &orphans() const {
reg->each([this](const auto entt) {
auto &entities = reg->template storage<entity_type>();
for(auto entt: entities) {
if(reg->orphan(entt)) {
reg->release(entt);
entities.erase(entt);
}
});
}
return *this;
}
@@ -523,11 +525,13 @@ public:
* @return A non-const reference to this loader.
*/
basic_continuous_loader &orphans() {
reg->each([this](const auto entt) {
auto &entities = reg->template storage<entity_type>();
for(auto entt: entities) {
if(reg->orphan(entt)) {
reg->release(entt);
entities.erase(entt);
}
});
}
return *this;
}