clear entity sets on snapshot

pull/6/head
cosmonaut 2023-11-07 21:41:55 -08:00
parent 0551aa0a07
commit 95b38cb092
1 changed files with 12 additions and 5 deletions

View File

@ -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<Entity, int> EntityIDToStorageIndex = new Dictionary<Entity, int>();
private readonly NativeArray Components;
private readonly NativeArray<Entity> EntityIDs;