misc fixes

pull/6/head
cosmonaut 2023-11-03 17:47:17 -07:00
parent 53f4124fdb
commit e6059a2f0a
2 changed files with 23 additions and 6 deletions

View File

@ -132,12 +132,21 @@ public class Filter
// breadth-first search // breadth-first search
// ignore excluded component edges // ignore excluded component edges
foreach (var (componentId, edge) in current.AddEdges) foreach (var (componentId, archetype) in current.AddEdges)
{ {
if (!filter.Excluded.Contains(componentId)) if (!Explored.Contains(archetype) && !filter.Excluded.Contains(componentId))
{ {
Explored.Add(edge); Explored.Add(archetype);
ArchetypeSearchQueue.Enqueue(edge); ArchetypeSearchQueue.Enqueue(archetype);
}
}
foreach (var (componentId, archetype) in current.RemoveEdges)
{
if (!Explored.Contains(archetype))
{
Explored.Add(archetype);
ArchetypeSearchQueue.Enqueue(archetype);
} }
} }
} }

View File

@ -220,7 +220,11 @@ namespace MoonTools.ECS
} }
archetype.AddEdges.Add(componentTypeId, nextArchetype); archetype.AddEdges.Add(componentTypeId, nextArchetype);
if (!nextArchetype.RemoveEdges.ContainsKey(componentTypeId))
{
nextArchetype.RemoveEdges.Add(componentTypeId, archetype); nextArchetype.RemoveEdges.Add(componentTypeId, archetype);
}
return nextArchetype; return nextArchetype;
} }
@ -246,7 +250,11 @@ namespace MoonTools.ECS
} }
archetype.RemoveEdges.Add(componentTypeId, nextArchetype); archetype.RemoveEdges.Add(componentTypeId, nextArchetype);
if (!nextArchetype.AddEdges.ContainsKey(componentTypeId))
{
nextArchetype.AddEdges.Add(componentTypeId, archetype); nextArchetype.AddEdges.Add(componentTypeId, archetype);
}
return nextArchetype; return nextArchetype;
} }