diff --git a/src/FilterStorage.cs b/src/FilterStorage.cs index 804ed93..aad179b 100644 --- a/src/FilterStorage.cs +++ b/src/FilterStorage.cs @@ -171,6 +171,15 @@ namespace MoonTools.ECS } } + // used by World.Clear, ignores callbacks + public void Clear() + { + foreach (var (filterSignature, entityIDs) in filterSignatureToEntityIDs) + { + entityIDs.Clear(); + } + } + public void RegisterAddCallback(FilterSignature filterSignature, Action callback) { addCallbacks.Add(filterSignature, callback); diff --git a/src/World.cs b/src/World.cs index 81a8ca5..79fa68f 100644 --- a/src/World.cs +++ b/src/World.cs @@ -14,14 +14,11 @@ namespace MoonTools.ECS internal readonly FilterStorage FilterStorage; public FilterBuilder FilterBuilder => new FilterBuilder(FilterStorage, ComponentTypeIndices); - internal readonly ComponentDepot TemplateComponentDepot; - public World() { ComponentDepot = new ComponentDepot(ComponentTypeIndices); RelationDepot = new RelationDepot(RelationTypeIndices); FilterStorage = new FilterStorage(EntityStorage, ComponentTypeIndices); - TemplateComponentDepot = new ComponentDepot(ComponentTypeIndices); } public Entity CreateEntity(string tag = "") @@ -148,6 +145,15 @@ namespace MoonTools.ECS MessageDepot.Clear(); } + public void Clear() + { + EntityStorage.Clear(); + MessageDepot.Clear(); + RelationDepot.Clear(); + ComponentDepot.Clear(); + FilterStorage.Clear(); + } + private Dictionary WorldToTransferID = new Dictionary(); // FIXME: there's probably a better way to handle Filters so they are not world-bound