mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 09:54:35 +08:00
refactoring
This commit is contained in:
parent
7e4a33bd4d
commit
3d6155ea80
@ -10,12 +10,6 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
public abstract class EcsQueryBuilder
|
|
||||||
{
|
|
||||||
public abstract inc<TComponent> Include<TComponent>() where TComponent : struct;
|
|
||||||
public abstract exc<TComponent> Exclude<TComponent>() where TComponent : struct;
|
|
||||||
public abstract opt<TComponent> Optional<TComponent>() where TComponent : struct;
|
|
||||||
}
|
|
||||||
public interface IEcsQuery
|
public interface IEcsQuery
|
||||||
{
|
{
|
||||||
internal void AddEntity(int entityID);
|
internal void AddEntity(int entityID);
|
||||||
@ -115,7 +109,6 @@ namespace DCFApixels.DragonECS
|
|||||||
_exc.Sort();
|
_exc.Sort();
|
||||||
mask = new EcsQueryMask(_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;
|
||||||
@ -128,12 +121,6 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public class EcsQueryMask : EcsMaskBase
|
public class EcsQueryMask : EcsMaskBase
|
||||||
{
|
{
|
||||||
// internal readonly Type WorldArchetypeType;
|
|
||||||
// internal readonly int[] Inc;
|
|
||||||
// internal readonly int[] Exc;
|
|
||||||
//
|
|
||||||
// public int IncCount => Inc.Length;
|
|
||||||
// public int ExcCount => Exc.Length;
|
|
||||||
public EcsQueryMask(Type worldArchetypeType, int[] inc, int[] exc)
|
public EcsQueryMask(Type worldArchetypeType, int[] inc, int[] exc)
|
||||||
{
|
{
|
||||||
WorldArchetypeType = worldArchetypeType;
|
WorldArchetypeType = worldArchetypeType;
|
||||||
@ -141,5 +128,10 @@ namespace DCFApixels.DragonECS
|
|||||||
Exc = exc;
|
Exc = exc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public abstract class EcsQueryBuilder
|
||||||
|
{
|
||||||
|
public abstract inc<TComponent> Include<TComponent>() where TComponent : struct;
|
||||||
|
public abstract exc<TComponent> Exclude<TComponent>() where TComponent : struct;
|
||||||
|
public abstract opt<TComponent> Optional<TComponent>() where TComponent : struct;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,20 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal inc(EcsPool<TComponent> pool) => _pool = pool;
|
internal inc(EcsPool<TComponent> pool) => _pool = pool;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public ref TComponent Write(ent entity) => ref _pool.Write(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref TComponent Write(int entityID) => ref _pool.Write(entityID);
|
public ref TComponent Write(int entityID) => ref _pool.Write(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public ref readonly TComponent Read(ent entity) => ref _pool.Read(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref readonly TComponent Read(int entityID) => ref _pool.Read(entityID);
|
public ref readonly TComponent Read(int entityID) => ref _pool.Read(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public bool Has(ent entity) => _pool.Has(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool Has(int entityID) => _pool.Has(entityID);
|
public bool Has(int entityID) => _pool.Has(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void Del(ent entity) => _pool.Del(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Del(int entityID) => _pool.Del(entityID);
|
public void Del(int entityID) => _pool.Del(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
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}>";
|
||||||
@ -44,12 +52,20 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal exc(EcsPool<TComponent> pool) => _pool = pool;
|
internal exc(EcsPool<TComponent> pool) => _pool = pool;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public ref TComponent Write(ent entity) => ref _pool.Write(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref TComponent Write(int entityID) => ref _pool.Write(entityID);
|
public ref TComponent Write(int entityID) => ref _pool.Write(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public ref readonly TComponent Read(ent entity) => ref _pool.Read(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref readonly TComponent Read(int entityID) => ref _pool.Read(entityID);
|
public ref readonly TComponent Read(int entityID) => ref _pool.Read(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public bool Has(ent entity) => _pool.Has(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool Has(int entityID) => _pool.Has(entityID);
|
public bool Has(int entityID) => _pool.Has(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void Del(ent entity) => _pool.Del(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Del(int entityID) => _pool.Del(entityID);
|
public void Del(int entityID) => _pool.Del(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
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}>";
|
||||||
@ -66,12 +82,20 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
internal opt(EcsPool<TComponent> pool) => _pool = pool;
|
internal opt(EcsPool<TComponent> pool) => _pool = pool;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public ref TComponent Write(ent entity) => ref _pool.Write(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref TComponent Write(int entityID) => ref _pool.Write(entityID);
|
public ref TComponent Write(int entityID) => ref _pool.Write(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public ref readonly TComponent Read(ent entity) => ref _pool.Read(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref readonly TComponent Read(int entityID) => ref _pool.Read(entityID);
|
public ref readonly TComponent Read(int entityID) => ref _pool.Read(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public bool Has(ent entity) => _pool.Has(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool Has(int entityID) => _pool.Has(entityID);
|
public bool Has(int entityID) => _pool.Has(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void Del(ent entity) => _pool.Del(entity.id);
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Del(int entityID) => _pool.Del(entityID);
|
public void Del(int entityID) => _pool.Del(entityID);
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
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}>";
|
||||||
|
Loading…
Reference in New Issue
Block a user