From 4ff546538b2855a52767dcce88c0ce3a85259c8b Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Fri, 27 Jan 2023 09:48:27 -0800 Subject: [PATCH] fix false positive on filter remove callback --- src/FilterStorage.cs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/FilterStorage.cs b/src/FilterStorage.cs index 5a466a8..91b3a0c 100644 --- a/src/FilterStorage.cs +++ b/src/FilterStorage.cs @@ -118,10 +118,12 @@ namespace MoonTools.ECS { if (!EntityStorage.HasComponent(entityID, type)) { - filterSignatureToEntityIDs[filterSignature].Remove(entityID); - if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback)) + if (filterSignatureToEntityIDs[filterSignature].Remove(entityID)) { - removeCallback(entityID); + if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback)) + { + removeCallback(entityID); + } } return; } @@ -131,10 +133,12 @@ namespace MoonTools.ECS { if (EntityStorage.HasComponent(entityID, type)) { - filterSignatureToEntityIDs[filterSignature].Remove(entityID); - if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback)) + if (filterSignatureToEntityIDs[filterSignature].Remove(entityID)) { - removeCallback(entityID); + if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback)) + { + removeCallback(entityID); + } } return; } @@ -153,10 +157,12 @@ namespace MoonTools.ECS { foreach (var filterSignature in filterSignatures) { - filterSignatureToEntityIDs[filterSignature].Remove(entityID); - if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback)) + if (filterSignatureToEntityIDs[filterSignature].Remove(entityID)) { - removeCallback(entityID); + if (removeCallbacks.TryGetValue(filterSignature, out var removeCallback)) + { + removeCallback(entityID); + } } } }