add World.Clear

set_order
cosmonaut 2023-07-21 14:41:53 -07:00
parent 4d45d05618
commit b5e28ae69f
2 changed files with 18 additions and 3 deletions

View File

@ -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<Entity> callback)
{
addCallbacks.Add(filterSignature, callback);

View File

@ -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<int, int> WorldToTransferID = new Dictionary<int, int>();
// FIXME: there's probably a better way to handle Filters so they are not world-bound