diff --git a/src/Snapshot.cs b/src/Snapshot.cs index 6d124cb..10a080d 100644 --- a/src/Snapshot.cs +++ b/src/Snapshot.cs @@ -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) {