mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
rename EntityArhietype to Query
This commit is contained in:
parent
05aa578b96
commit
d81ee5f1e5
@ -33,7 +33,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public override string ToString() => $"{(_pool == null ? "NULL" : _pool.World.ArchetypeType.Name)}inc<{typeof(TComponent).Name}>";
|
public override string ToString() => $"{(_pool == null ? "NULL" : _pool.World.ArchetypeType.Name)}inc<{typeof(TComponent).Name}>";
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static implicit operator inc<TComponent>(EcsEntityArchetypeBuilder buider) => buider.Include<TComponent>();
|
public static implicit operator inc<TComponent>(EcsQueryBuilder buider) => buider.Include<TComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
|
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
|
||||||
@ -55,7 +55,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public override string ToString() => $"{(_pool == null ? "NULL" : _pool.World.ArchetypeType.Name)}exc<{typeof(TComponent).Name}>";
|
public override string ToString() => $"{(_pool == null ? "NULL" : _pool.World.ArchetypeType.Name)}exc<{typeof(TComponent).Name}>";
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static implicit operator exc<TComponent>(EcsEntityArchetypeBuilder buider) => buider.Exclude<TComponent>();
|
public static implicit operator exc<TComponent>(EcsQueryBuilder buider) => buider.Exclude<TComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
|
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
|
||||||
@ -77,6 +77,6 @@ namespace DCFApixels.DragonECS
|
|||||||
public override string ToString() => $"{(_pool == null ? "NULL" : _pool.World.ArchetypeType.Name)}opt<{typeof(TComponent).Name}>";
|
public override string ToString() => $"{(_pool == null ? "NULL" : _pool.World.ArchetypeType.Name)}opt<{typeof(TComponent).Name}>";
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static implicit operator opt<TComponent>(EcsEntityArchetypeBuilder buider) => buider.Optional<TComponent>();
|
public static implicit operator opt<TComponent>(EcsQueryBuilder buider) => buider.Optional<TComponent>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,18 +8,18 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
public abstract class EcsEntityArchetypeBuilder
|
public abstract class EcsQueryBuilder
|
||||||
{
|
{
|
||||||
public abstract inc<TComponent> Include<TComponent>() where TComponent : struct;
|
public abstract inc<TComponent> Include<TComponent>() where TComponent : struct;
|
||||||
public abstract exc<TComponent> Exclude<TComponent>() where TComponent : struct;
|
public abstract exc<TComponent> Exclude<TComponent>() where TComponent : struct;
|
||||||
public abstract opt<TComponent> Optional<TComponent>() where TComponent : struct;
|
public abstract opt<TComponent> Optional<TComponent>() where TComponent : struct;
|
||||||
}
|
}
|
||||||
public interface IEcsEntityArchetype
|
public interface IEcsQuery
|
||||||
{
|
{
|
||||||
internal void AddEntity(int entityID);
|
internal void AddEntity(int entityID);
|
||||||
internal void RemoveEntity(int entityID);
|
internal void RemoveEntity(int entityID);
|
||||||
}
|
}
|
||||||
public class EcsEntityArchetype<TWorldArchetype> : IEcsEntityArchetype
|
public class EcsQuery<TWorldArchetype> : IEcsQuery
|
||||||
where TWorldArchetype : EcsWorld<TWorldArchetype>
|
where TWorldArchetype : EcsWorld<TWorldArchetype>
|
||||||
{
|
{
|
||||||
private int _id;
|
private int _id;
|
||||||
@ -32,7 +32,7 @@ namespace DCFApixels.DragonECS
|
|||||||
get => group.Readonly;
|
get => group.Readonly;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EcsEntityArchetype(Builder b)
|
public EcsQuery(Builder b)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,12 +40,12 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
void IEcsEntityArchetype.AddEntity(int entityID) => group.Add(entityID);
|
void IEcsQuery.AddEntity(int entityID) => group.Add(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
void IEcsEntityArchetype.RemoveEntity(int entityID) => group.Remove(entityID);
|
void IEcsQuery.RemoveEntity(int entityID) => group.Remove(entityID);
|
||||||
|
|
||||||
#region Builder
|
#region Builder
|
||||||
public sealed class Builder : EcsEntityArchetypeBuilder
|
public sealed class Builder : EcsQueryBuilder
|
||||||
{
|
{
|
||||||
private IEcsWorld _world;
|
private IEcsWorld _world;
|
||||||
private List<int> _inc;
|
private List<int> _inc;
|
||||||
@ -74,11 +74,11 @@ namespace DCFApixels.DragonECS
|
|||||||
return new opt<TComponent>(_world.GetPool<TComponent>());
|
return new opt<TComponent>(_world.GetPool<TComponent>());
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void End(out EcsEntityArhetypeMask mask)
|
internal void End(out EcsQueryMask mask)
|
||||||
{
|
{
|
||||||
_inc.Sort();
|
_inc.Sort();
|
||||||
_exc.Sort();
|
_exc.Sort();
|
||||||
mask = new EcsEntityArhetypeMask(_world.ArchetypeType, _inc.ToArray(), _exc.ToArray());
|
mask = new EcsQueryMask(_world.ArchetypeType, _inc.ToArray(), _exc.ToArray());
|
||||||
_world = null;
|
_world = null;
|
||||||
_inc.Clear();
|
_inc.Clear();
|
||||||
_inc = null;
|
_inc = null;
|
||||||
@ -89,7 +89,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EcsEntityArhetypeMask
|
public class EcsQueryMask
|
||||||
{
|
{
|
||||||
internal readonly Type WorldArchetypeType;
|
internal readonly Type WorldArchetypeType;
|
||||||
internal readonly int[] Inc;
|
internal readonly int[] Inc;
|
||||||
@ -97,7 +97,7 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public int IncCount => Inc.Length;
|
public int IncCount => Inc.Length;
|
||||||
public int ExcCount => Exc.Length;
|
public int ExcCount => Exc.Length;
|
||||||
public EcsEntityArhetypeMask(Type worldArchetypeType, int[] inc, int[] exc)
|
public EcsQueryMask(Type worldArchetypeType, int[] inc, int[] exc)
|
||||||
{
|
{
|
||||||
WorldArchetypeType = worldArchetypeType;
|
WorldArchetypeType = worldArchetypeType;
|
||||||
Inc = inc;
|
Inc = inc;
|
@ -17,7 +17,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Entities
|
#region Entities
|
||||||
public TArhetype Entities<TArhetype>(out TArhetype entities) where TArhetype : IEcsEntityArchetype;
|
public TArhetype Entities<TArhetype>(out TArhetype entities) where TArhetype : IEcsQuery;
|
||||||
|
|
||||||
public ent NewEntity();
|
public ent NewEntity();
|
||||||
public void DelEntity(ent entity);
|
public void DelEntity(ent entity);
|
||||||
@ -72,7 +72,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private List<EcsGroup>[] _filtersByIncludedComponents;
|
private List<EcsGroup>[] _filtersByIncludedComponents;
|
||||||
private List<EcsGroup>[] _filtersByExcludedComponents;
|
private List<EcsGroup>[] _filtersByExcludedComponents;
|
||||||
|
|
||||||
private IEcsEntityArchetype[] _archetypes;
|
private IEcsQuery[] _archetypes;
|
||||||
|
|
||||||
private EcsPipeline _pipeline;
|
private EcsPipeline _pipeline;
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ namespace DCFApixels.DragonECS
|
|||||||
FillArray(_pools, _nullPool);
|
FillArray(_pools, _nullPool);
|
||||||
|
|
||||||
_gens = new short[512];
|
_gens = new short[512];
|
||||||
_archetypes = new EcsEntityArchetype<TWorldArchetype>[EntityArhetype.capacity];
|
_archetypes = new EcsQuery<TWorldArchetype>[EntityArhetype.capacity];
|
||||||
_groups = new List<EcsGroup>(128);
|
_groups = new List<EcsGroup>(128);
|
||||||
|
|
||||||
_denseEntities = new int[512];
|
_denseEntities = new int[512];
|
||||||
@ -160,7 +160,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Entities
|
#region Entities
|
||||||
public TEntityArhetype Entities<TEntityArhetype>(out TEntityArhetype entities) where TEntityArhetype : IEcsEntityArchetype
|
public TEntityArhetype Entities<TEntityArhetype>(out TEntityArhetype entities) where TEntityArhetype : IEcsQuery
|
||||||
{
|
{
|
||||||
int uniqueID = EntityArhetype<TEntityArhetype>.uniqueID;
|
int uniqueID = EntityArhetype<TEntityArhetype>.uniqueID;
|
||||||
if (_archetypes.Length < EntityArhetype.capacity)
|
if (_archetypes.Length < EntityArhetype.capacity)
|
||||||
@ -168,13 +168,13 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
if (_archetypes[uniqueID] == null)
|
if (_archetypes[uniqueID] == null)
|
||||||
{
|
{
|
||||||
EcsEntityArchetype<TWorldArchetype>.Builder builder = new EcsEntityArchetype<TWorldArchetype>.Builder(this);
|
EcsQuery<TWorldArchetype>.Builder builder = new EcsQuery<TWorldArchetype>.Builder(this);
|
||||||
_archetypes[uniqueID] = (TEntityArhetype)Activator.CreateInstance(typeof(TEntityArhetype), builder);
|
_archetypes[uniqueID] = (TEntityArhetype)Activator.CreateInstance(typeof(TEntityArhetype), builder);
|
||||||
builder.End(out EcsEntityArhetypeMask mask);
|
builder.End(out EcsQueryMask mask);
|
||||||
|
|
||||||
var filter = new EcsGroup(this);
|
var filter = new EcsGroup(this);
|
||||||
|
|
||||||
((EcsEntityArchetype<TWorldArchetype>)_archetypes[uniqueID]).group = filter;
|
((EcsQuery<TWorldArchetype>)_archetypes[uniqueID]).group = filter;
|
||||||
|
|
||||||
for (int i = 0; i < mask.IncCount; i++)
|
for (int i = 0; i < mask.IncCount; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user