Sdk/World: Fix destruction retrieval while world clear

This commit is contained in:
Jérôme Leclercq
2017-11-22 10:26:33 +01:00
parent 19724f1e66
commit b83a9b60e7
4 changed files with 11 additions and 5 deletions

View File

@@ -115,10 +115,15 @@ namespace Ndk
void World::Clear() noexcept
{
// First, destruction of entities, then handles
// This is made to avoid that handle warn uselessly entities before their destruction
m_entities.clear();
// Destroy every valid entity first, to ensure entities are still accessible by ID while being destroyed
for (EntityBlock* entBlock : m_entityBlocks)
{
if (entBlock->entity.IsValid())
entBlock->entity.Destroy();
}
m_entityBlocks.clear();
m_entities.clear();
m_freeIdList.clear();
m_waitingEntities.clear();