Sdk/World: Refactor

Former-commit-id: abdef9b717866de6ab91624242583830573d9320
This commit is contained in:
Lynix 2015-12-10 23:50:35 +01:00
parent 8adc0097df
commit f8f3dbd696
1 changed files with 24 additions and 25 deletions

View File

@ -127,23 +127,23 @@ namespace Ndk
Entity* entity = &m_entities[i].entity; Entity* entity = &m_entities[i].entity;
// Aucun intérêt de traiter une entité n'existant plus // Check entity validity (as it could have been reported as dirty and killed during the same iteration)
if (entity->IsValid()) if (!entity->IsValid())
{ continue;
for (auto& system : m_systems) for (auto& system : m_systems)
{ {
// Ignore non-existent systems // Ignore non-existent systems
if (!system) if (!system)
continue; continue;
// L'entité est-elle enregistrée comme faisant partie du système ? // Is our entity already part of this system?
bool partOfSystem = system->HasEntity(entity); bool partOfSystem = system->HasEntity(entity);
// Doit-elle en faire partie ? // Should it be part of it?
if (system->Filters(entity))
if (entity->IsEnabled() && system->Filters(entity)) if (entity->IsEnabled() && system->Filters(entity))
{ {
// L'entité doit faire partie du système, revalidons-là (événement système) ou ajoutons-la au système // Yes it should, add it to the system if not already done and validate it (again)
if (!partOfSystem) if (!partOfSystem)
system->AddEntity(entity); system->AddEntity(entity);
@ -151,13 +151,12 @@ namespace Ndk
} }
else else
{ {
// Elle ne doit pas en faire partie, si elle en faisait partie nous devons la retirer // No, it shouldn't, remove it if it's part of the system
if (partOfSystem) if (partOfSystem)
system->RemoveEntity(entity); system->RemoveEntity(entity);
} }
} }
} }
}
m_dirtyEntities.Reset(); m_dirtyEntities.Reset();
} }
} }