correctly update filters on entity destroy

pull/1/head
cosmonaut 2022-03-06 22:43:53 -08:00
parent b19d8441b1
commit 57474f1c63
1 changed files with 20 additions and 1 deletions

View File

@ -80,6 +80,25 @@ internal class ComponentDepot
return Lookup<TComponent>().AllComponents();
}
private void Remove(Type type, int entityID)
{
Lookup(type).Remove(entityID);
var found = entityComponentMap[entityID].Remove(type);
// update filters
if (found)
{
if (typeToFilterSignatures.TryGetValue(type, out var filterSignatures))
{
foreach (var filterSignature in filterSignatures)
{
CheckFilter(filterSignature, entityID);
}
}
}
}
public void Remove<TComponent>(int entityID) where TComponent : struct
{
Lookup<TComponent>().Remove(entityID);
@ -105,7 +124,7 @@ internal class ComponentDepot
{
foreach (var type in entityComponentMap[entityID])
{
storages[type].Remove(entityID);
Remove(type, entityID);
}
entityComponentMap.Remove(entityID);