handle case where storages are created after snapshot

pull/6/head
cosmonaut 2023-11-16 12:58:51 -08:00
parent 2d333d0651
commit d8d021060e
1 changed files with 14 additions and 0 deletions

View File

@ -43,6 +43,20 @@ public class Snapshot
}
}
// clear all component storages in case any were created after snapshot
// FIXME: this can be eliminated via component discovery
foreach (var (typeId, componentStorage) in world.ComponentIndex)
{
componentStorage.Clear();
}
// clear all relation storages in case any were created after snapshot
// FIXME: this can be eliminated via component discovery
foreach (var (typeId, relationStorage) in world.RelationIndex)
{
relationStorage.Clear();
}
// restore components
foreach (var (typeId, componentSnapshot) in ComponentSnapshots)
{