run Filter callbacks before updating component storage

pull/4/head
cosmonaut 2023-05-19 13:24:26 -07:00
parent 4268762a0c
commit c68e16456e
2 changed files with 4 additions and 2 deletions

View File

@ -19,8 +19,9 @@ namespace MoonTools.ECS
{
if (EntityStorage.RemoveComponent(entity.ID, ComponentTypeIndices.GetIndex<TComponent>()))
{
ComponentDepot.Remove<TComponent>(entity.ID);
// Run filter storage update first so that the entity state is still valid in the remove callback.
FilterStorage.Check<TComponent>(entity.ID);
ComponentDepot.Remove<TComponent>(entity.ID);
}
}

View File

@ -90,8 +90,9 @@ namespace MoonTools.ECS
{
foreach (var componentTypeIndex in EntityStorage.ComponentTypeIndices(entity.ID))
{
ComponentDepot.Remove(entity.ID, componentTypeIndex);
// Run filter storage update first so that the entity state is still valid in the remove callback.
FilterStorage.RemoveEntity(entity.ID, componentTypeIndex);
ComponentDepot.Remove(entity.ID, componentTypeIndex);
}
foreach (var relationTypeIndex in EntityStorage.RelationTypeIndices(entity.ID))