mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 13:01:49 +00:00
add entity 'save' property support
This commit is contained in:
parent
5b5abd1ab0
commit
51f6f0e629
3 changed files with 24 additions and 8 deletions
|
|
@ -743,17 +743,13 @@ void Chunks::save(Chunk* chunk) {
|
|||
)
|
||||
);
|
||||
auto entities = level->entities->getAllInside(aabb);
|
||||
auto root = dynamic::create_map();
|
||||
auto& list = root->putList("data");
|
||||
for (auto& entity : entities) {
|
||||
level->entities->onSave(entity);
|
||||
list.put(level->entities->serialize(entity));
|
||||
entity.destroy();
|
||||
}
|
||||
if (!entities.empty()) {
|
||||
auto root = dynamic::create_map();
|
||||
root->put("data", level->entities->serialize(entities));
|
||||
level->entities->despawn(std::move(entities));
|
||||
chunk->flags.entities = true;
|
||||
worldFiles->getRegions().put(chunk, json::to_binary(root, true));
|
||||
}
|
||||
worldFiles->getRegions().put(chunk, json::to_binary(root, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue