diff --git a/src/Snapshot.cs b/src/Snapshot.cs index 61bde14..6d124cb 100644 --- a/src/Snapshot.cs +++ b/src/Snapshot.cs @@ -59,10 +59,14 @@ public class Snapshot // restore entity relation index state // FIXME: arghhhh this is so slow + + foreach (var (id, relationTypeSet) in world.EntityRelationIndex) + { + relationTypeSet.Clear(); + } + foreach (var (id, relationTypeSet) in EntityRelationIndex) { - world.EntityRelationIndex[id].Clear(); - foreach (var typeId in relationTypeSet) { world.EntityRelationIndex[id].Add(typeId); @@ -71,10 +75,14 @@ public class Snapshot // restore entity component index state // FIXME: arrghghhh this is so slow + + foreach (var (id, componentTypeSet) in world.EntityComponentIndex) + { + componentTypeSet.Clear(); + } + foreach (var (id, componentTypeSet) in EntityComponentIndex) { - world.EntityComponentIndex[id].Clear(); - foreach (var typeId in componentTypeSet) { world.EntityComponentIndex[id].Add(typeId); @@ -192,7 +200,6 @@ public class Snapshot private class ComponentSnapshot { - private readonly Dictionary EntityIDToStorageIndex = new Dictionary(); private readonly NativeArray Components; private readonly NativeArray EntityIDs;