add World.Clear
parent
4d45d05618
commit
b5e28ae69f
|
@ -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);
|
||||
|
|
12
src/World.cs
12
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<int, int> WorldToTransferID = new Dictionary<int, int>();
|
||||
|
||||
// FIXME: there's probably a better way to handle Filters so they are not world-bound
|
||||
|
|
Loading…
Reference in New Issue