39 lines
818 B
C#
39 lines
818 B
C#
using System.Collections.Generic;
|
|
using MoonTools.ECS.Collections;
|
|
|
|
namespace MoonTools.ECS;
|
|
|
|
internal class Archetype
|
|
{
|
|
public World World;
|
|
public ArchetypeSignature Signature;
|
|
public NativeArray<Entity> Entities = new NativeArray<Entity>();
|
|
|
|
public SortedDictionary<TypeId, Archetype> AddEdges =
|
|
new SortedDictionary<TypeId, Archetype>();
|
|
public SortedDictionary<TypeId, Archetype> RemoveEdges =
|
|
new SortedDictionary<TypeId, Archetype>();
|
|
|
|
public int Count => Entities.Count;
|
|
|
|
public Archetype(World world, ArchetypeSignature signature)
|
|
{
|
|
World = world;
|
|
Signature = signature;
|
|
}
|
|
|
|
public int Append(Entity entity)
|
|
{
|
|
Entities.Append(entity);
|
|
return Entities.Count - 1;
|
|
}
|
|
|
|
public void ClearAll()
|
|
{
|
|
for (int i = Entities.Count - 1; i >= 0; i -= 1)
|
|
{
|
|
World.Destroy(Entities[i]);
|
|
}
|
|
}
|
|
}
|