fix false positive on filter remove callback

pull/4/head
cosmonaut 2023-01-27 09:48:27 -08:00
parent 1438188dca
commit 4ff546538b
1 changed files with 15 additions and 9 deletions

View File

@ -118,10 +118,12 @@ namespace MoonTools.ECS
{ {
if (!EntityStorage.HasComponent(entityID, type)) if (!EntityStorage.HasComponent(entityID, type))
{ {
filterSignatureToEntityIDs[filterSignature].Remove(entityID); if (filterSignatureToEntityIDs[filterSignature].Remove(entityID))
if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback))
{ {
removeCallback(entityID); if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback))
{
removeCallback(entityID);
}
} }
return; return;
} }
@ -131,10 +133,12 @@ namespace MoonTools.ECS
{ {
if (EntityStorage.HasComponent(entityID, type)) if (EntityStorage.HasComponent(entityID, type))
{ {
filterSignatureToEntityIDs[filterSignature].Remove(entityID); if (filterSignatureToEntityIDs[filterSignature].Remove(entityID))
if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback))
{ {
removeCallback(entityID); if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback))
{
removeCallback(entityID);
}
} }
return; return;
} }
@ -153,10 +157,12 @@ namespace MoonTools.ECS
{ {
foreach (var filterSignature in filterSignatures) foreach (var filterSignature in filterSignatures)
{ {
filterSignatureToEntityIDs[filterSignature].Remove(entityID); if (filterSignatureToEntityIDs[filterSignature].Remove(entityID))
if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback))
{ {
removeCallback(entityID); if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback))
{
removeCallback(entityID);
}
} }
} }
} }