add relation pools

This commit is contained in:
Mikhail 2023-04-21 14:21:24 +08:00
parent b38d59ae80
commit 699a64f0b6
10 changed files with 330 additions and 151 deletions

View File

@ -50,19 +50,19 @@ namespace DCFApixels.DragonECS
return (TQuery)(object)newQuery; return (TQuery)(object)newQuery;
} }
public override inc_<TComponent> Include<TComponent>() where TComponent : struct public sealed override TPool Include<TComponent, TPool>()
{ {
_inc.Add(_world.GetComponentID<TComponent>()); _inc.Add(_world.GetComponentID<TComponent>());
return new inc_<TComponent>(_world.GetPool<TComponent, EcsPool<TComponent>>()); return _world.GetPool<TComponent, TPool>();
} }
public override exc_<TComponent> Exclude<TComponent>() where TComponent : struct public sealed override TPool Exclude<TComponent, TPool>()
{ {
_exc.Add(_world.GetComponentID<TComponent>()); _exc.Add(_world.GetComponentID<TComponent>());
return new exc_<TComponent>(_world.GetPool<TComponent, EcsPool<TComponent>>()); return _world.GetPool<TComponent, TPool>();
} }
public override opt_<TComponent> Optional<TComponent>() where TComponent : struct public sealed override TPool Optional<TComponent, TPool>()
{ {
return new opt_<TComponent>(_world.GetPool<TComponent, EcsPool<TComponent>>()); return _world.GetPool<TComponent, TPool>();
} }
private void End(out EcsQueryMask mask) private void End(out EcsQueryMask mask)
@ -77,20 +77,11 @@ namespace DCFApixels.DragonECS
} }
#endregion #endregion
} }
public abstract class EcsHierarchyQuery : EcsQueryBase public abstract class EcsJoinAttachQuery : EcsQueryBase
{ {
private ProfilerMarker _getEnumerator = new ProfilerMarker("EcsHierarchyQuery.Execute"); // private EcsPool<Edge> attachPool;
protected override void OnBuildAfter() { } private ProfilerMarker _getEnumerator = new ProfilerMarker("EcsJoinAttachQuery.Execute");
public override void Execute()
{
}
}
public abstract class EcsGraphQuery : EcsQueryBase
{
private EcsPool<Edge> attachPool;
private ProfilerMarker _getEnumerator = new ProfilerMarker("EcsGraphQuery.Execute");
protected sealed override void OnBuildAfter() protected sealed override void OnBuildAfter()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@ -108,6 +99,28 @@ namespace DCFApixels.DragonECS
return groupFilter.GetEnumerator(); return groupFilter.GetEnumerator();
} }
} }
public abstract class EcsJoinRelationQuery : EcsQueryBase
{
// private EcsPool<Edge> attachPool;
private ProfilerMarker _getEnumerator = new ProfilerMarker("EcsJoinAttachQuery.Execute");
protected sealed override void OnBuildAfter()
{
throw new NotImplementedException();
// attachPool = World.GetPool<Edge>();
}
public sealed override void Execute()
{
using (_getEnumerator.Auto())
{
throw new NotImplementedException();
}
}
public EcsGroup.Enumerator GetEnumerator()
{
return groupFilter.GetEnumerator();
}
}
public abstract class EcsQuery : EcsQueryBase public abstract class EcsQuery : EcsQueryBase
{ {
@ -156,8 +169,8 @@ namespace DCFApixels.DragonECS
} }
public abstract class EcsQueryBuilderBase public abstract class EcsQueryBuilderBase
{ {
public abstract inc_<TComponent> Include<TComponent>() where TComponent : struct; public abstract TPool Include<TComponent, TPool>() where TComponent : struct where TPool : EcsPoolBase, new();
public abstract exc_<TComponent> Exclude<TComponent>() where TComponent : struct; public abstract TPool Exclude<TComponent, TPool>() where TComponent : struct where TPool : EcsPoolBase, new();
public abstract opt_<TComponent> Optional<TComponent>() where TComponent : struct; public abstract TPool Optional<TComponent, TPool>() where TComponent : struct where TPool : EcsPoolBase, new();
} }
} }

View File

@ -1,84 +0,0 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace DCFApixels.DragonECS
{
public interface IEcsQueryMember { }
public interface IEcsQueryReadonlyField<TComponent> : IEcsQueryMember
{
public ref readonly TComponent Read(ent entityID);
public bool Has(ent entityID);
}
public interface IEcsQueryField<TComponent> : IEcsQueryReadonlyField<TComponent>
where TComponent : struct
{
public ref TComponent Add(ent entityID);
public ref TComponent Write(ent entityID);
public void Del(ent entityID);
}
#region select
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
public readonly struct inc_<TComponent> : IEcsQueryField<TComponent>
where TComponent : struct
{
internal readonly EcsPool<TComponent> pool;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal inc_(EcsPool<TComponent> pool) => this.pool = pool;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref TComponent Add(ent entityID) => ref pool.Add(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref TComponent Write(ent entityID) => ref pool.Write(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref readonly TComponent Read(ent entityID) => ref pool.Read(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Has(ent entityID) => pool.Has(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Del(ent entityID) => pool.Del(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator inc_<TComponent>(EcsQueryBuilderBase buider) => buider.Include<TComponent>();
}
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
public readonly struct exc_<TComponent> : IEcsQueryField<TComponent>
where TComponent : struct
{
internal readonly EcsPool<TComponent> pool;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal exc_(EcsPool<TComponent> pool) => this.pool = pool;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref TComponent Add(ent entityID) => ref pool.Add(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref TComponent Write(ent entityID) => ref pool.Write(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref readonly TComponent Read(ent entityID) => ref pool.Read(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Has(ent entityID) => pool.Has(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Del(ent entityID) => pool.Del(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator exc_<TComponent>(EcsQueryBuilderBase buider) => buider.Exclude<TComponent>();
}
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
public readonly struct opt_<TComponent> : IEcsQueryField<TComponent>
where TComponent : struct
{
internal readonly EcsPool<TComponent> pool;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal opt_(EcsPool<TComponent> pool) => this.pool = pool;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref TComponent Add(ent entityID) => ref pool.Add(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref TComponent Write(ent entityID) => ref pool.Write(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref readonly TComponent Read(ent entityID) => ref pool.Read(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Has(ent entityID) => pool.Has(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Del(ent entityID) => pool.Del(entityID.id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator opt_<TComponent>(EcsQueryBuilderBase buider) => buider.Optional<TComponent>();
}
#endregion
}

View File

@ -0,0 +1,15 @@
using System;
namespace DCFApixels.DragonECS
{
[Serializable]
public class EcsRelationsException : Exception
{
public EcsRelationsException() { }
public EcsRelationsException(string message) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message) { }
public EcsRelationsException(string message, Exception inner) : base(EcsConsts.EXCEPTION_MESSAGE_PREFIX + message, inner) { }
protected EcsRelationsException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
}
}

View File

@ -17,8 +17,9 @@ namespace DCFApixels.DragonECS
public int GetComponentID<T>(); public int GetComponentID<T>();
public TPool GetPool<TComponent, TPool>() where TComponent : struct where TPool : EcsPoolBase, new(); public TPool GetPool<TComponent, TPool>() where TComponent : struct where TPool : EcsPoolBase, new();
public ReadOnlySpan<EcsPoolBase> GetAllPools(); public ReadOnlySpan<EcsPoolBase> GetAllPools();
public TQuery Where<TQuery>(out TQuery query) where TQuery : EcsQueryBase;
public TQuery Select<TQuery>() where TQuery : EcsQueryBase; public TQuery Select<TQuery>() where TQuery : EcsQueryBase;
public TQuery Where<TQuery>(out TQuery query) where TQuery : EcsQuery;
public TQuery Join<TQuery>(out TQuery query) where TQuery : EcsJoinAttachQuery;
public bool IsMaskCompatible(EcsComponentMask mask, int entityID); public bool IsMaskCompatible(EcsComponentMask mask, int entityID);

127
src/Pools/EcsAttachPool.cs Normal file
View File

@ -0,0 +1,127 @@
using System;
using System.Runtime.CompilerServices;
using Unity.Profiling;
namespace DCFApixels.DragonECS
{
public sealed class EcsAttachPool<T> : EcsPoolBase
where T : struct, IEcsAttachComponent
{
private EcsWorld _source;
private bool[] _entityFlags;// index = entityID / value = entityFlag;/ value = 0 = no entityID
private T[] _items; //sparse
private int _count;
private PoolRunners _poolRunners;
#if (DEBUG && !DISABLE_DEBUG) || !DRAGONECS_NO_SANITIZE_CHECKS
private int _sanitizeTargetWorld = -1;
#endif
#region Properites
public int Count => _count;
public int Capacity => _items.Length;
public sealed override EcsWorld World => _source;
public sealed override Type ComponentType => typeof(T);
#endregion
#region Init
protected override void Init(EcsWorld world)
{
_source = world;
_entityFlags = new bool[world.Capacity];
_items = new T[world.Capacity];
_count = 0;
_poolRunners = new PoolRunners(world.Pipeline);
}
#endregion
#region Write/Read/Has/Del
private ProfilerMarker _addMark = new ProfilerMarker("EcsPoo.Add");
private ProfilerMarker _writeMark = new ProfilerMarker("EcsPoo.Write");
private ProfilerMarker _readMark = new ProfilerMarker("EcsPoo.Read");
private ProfilerMarker _hasMark = new ProfilerMarker("EcsPoo.Has");
private ProfilerMarker _delMark = new ProfilerMarker("EcsPoo.Del");
public void Add(int entityID, EcsEntity target)
{
#if (DEBUG && !DISABLE_DEBUG) || !DRAGONECS_NO_SANITIZE_CHECKS
if (_sanitizeTargetWorld >= 0 && target.world != _sanitizeTargetWorld)
{
throw new EcsRelationsException();
}
#endif
// using (_addMark.Auto())
// {
ref bool entityFlag = ref _entityFlags[entityID];
if (entityFlag == false)
{
entityFlag = true;
_count++;
_poolRunners.add.OnComponentAdd<T>(entityID);
}
_poolRunners.write.OnComponentWrite<T>(entityID);
_items[entityID].Target = target;
// }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Set(int entityID, EcsEntity target)
{
#if (DEBUG && !DISABLE_DEBUG) || !DRAGONECS_NO_SANITIZE_CHECKS
if (_sanitizeTargetWorld >= 0 && target.world != _sanitizeTargetWorld)
{
throw new EcsRelationsException();
}
#endif
// using (_writeMark.Auto())
_poolRunners.write.OnComponentWrite<T>(entityID);
_items[entityID].Target = target;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref readonly T Read(int entityID)
{
// using (_readMark.Auto())
return ref _items[entityID];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public sealed override bool Has(int entityID)
{
// using (_hasMark.Auto())
return _entityFlags[entityID];
}
public void Del(int entityID)
{
// using (_delMark.Auto())
// {
_entityFlags[entityID] = false;
_count--;
_poolRunners.del.OnComponentDel<T>(entityID);
// }
}
#endregion
#region WorldCallbacks
protected override void OnWorldResize(int newSize)
{
Array.Resize(ref _entityFlags, newSize);
Array.Resize(ref _items, newSize);
}
protected override void OnDestroy() { }
#endregion
}
public interface IEcsAttachComponent
{
public EcsEntity Target { get; set; }
}
public static class EcsAttachComponentPoolExt
{
public static EcsAttachPool<TAttachComponent> GetPool<TAttachComponent>(this EcsWorld self)
where TAttachComponent : struct, IEcsAttachComponent
{
return self.GetPool<TAttachComponent, EcsAttachPool<TAttachComponent>>();
}
}
}

View File

@ -5,11 +5,10 @@ using Unity.Profiling;
namespace DCFApixels.DragonECS namespace DCFApixels.DragonECS
{ {
public sealed class EcsNotNullPool<T> : EcsPoolBase public sealed class EcsNotNullPool<T> : EcsPoolBase
where T : struct where T : struct, INotNullComponent
{ {
private EcsWorld _source; private EcsWorld _source;
private bool[] _entityFlags;// index = entityID / value = entityFlag;/ value = 0 = no entityID
private T[] _items; //sparse private T[] _items; //sparse
private int _count; private int _count;
@ -28,7 +27,6 @@ namespace DCFApixels.DragonECS
{ {
_source = world; _source = world;
_entityFlags = new bool[world.Capacity];
_items = new T[world.Capacity]; _items = new T[world.Capacity];
_count = 0; _count = 0;
@ -37,27 +35,12 @@ namespace DCFApixels.DragonECS
} }
#endregion #endregion
#region Write/Read/Has/Del #region Write/Read/Has
private ProfilerMarker _addMark = new ProfilerMarker("EcsPoo.Add"); private ProfilerMarker _addMark = new ProfilerMarker("EcsPoo.Add");
private ProfilerMarker _writeMark = new ProfilerMarker("EcsPoo.Write"); private ProfilerMarker _writeMark = new ProfilerMarker("EcsPoo.Write");
private ProfilerMarker _readMark = new ProfilerMarker("EcsPoo.Read"); private ProfilerMarker _readMark = new ProfilerMarker("EcsPoo.Read");
private ProfilerMarker _hasMark = new ProfilerMarker("EcsPoo.Has"); private ProfilerMarker _hasMark = new ProfilerMarker("EcsPoo.Has");
private ProfilerMarker _delMark = new ProfilerMarker("EcsPoo.Del"); private ProfilerMarker _delMark = new ProfilerMarker("EcsPoo.Del");
public ref T Add(int entityID)
{
// using (_addMark.Auto())
// {
ref bool entityFlag = ref _entityFlags[entityID];
if (entityFlag == false)
{
entityFlag = true;
_count++;
_poolRunners.add.OnComponentAdd<T>(entityID);
}
_poolRunners.write.OnComponentWrite<T>(entityID);
return ref _items[entityID];
// }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref T Write(int entityID) public ref T Write(int entityID)
{ {
@ -75,24 +58,13 @@ namespace DCFApixels.DragonECS
public sealed override bool Has(int entityID) public sealed override bool Has(int entityID)
{ {
// using (_hasMark.Auto()) // using (_hasMark.Auto())
return _entityFlags[entityID]; return true;
}
public void Del(int entityID)
{
// using (_delMark.Auto())
// {
_componentResetHandler.Reset(ref _items[entityID]);
_entityFlags[entityID] = false;
_count--;
_poolRunners.del.OnComponentDel<T>(entityID);
// }
} }
#endregion #endregion
#region WorldCallbacks #region WorldCallbacks
protected override void OnWorldResize(int newSize) protected override void OnWorldResize(int newSize)
{ {
Array.Resize(ref _entityFlags, newSize);
Array.Resize(ref _items, newSize); Array.Resize(ref _items, newSize);
} }
protected override void OnDestroy() { } protected override void OnDestroy() { }
@ -102,10 +74,10 @@ namespace DCFApixels.DragonECS
public interface INotNullComponent { } public interface INotNullComponent { }
public static class EcsNotNullPoolExt public static class EcsNotNullPoolExt
{ {
public static EcsNotNullPool<TComponent> GetPool<TComponent>(this EcsWorld self) public static EcsNotNullPool<TNotNullComponent> GetPool<TNotNullComponent>(this EcsWorld self)
where TComponent : struct, INotNullComponent where TNotNullComponent : struct, INotNullComponent
{ {
return self.GetPool<TComponent, EcsNotNullPool<TComponent>>(); return self.GetPool<TNotNullComponent, EcsNotNullPool<TNotNullComponent>>();
} }
} }
} }

View File

@ -50,7 +50,7 @@ namespace DCFApixels.DragonECS
} }
public sealed class EcsPool<T> : EcsPoolBase public sealed class EcsPool<T> : EcsPoolBase
where T : struct where T : struct, IEcsComponent
{ {
private EcsWorld _source; private EcsWorld _source;

View File

@ -0,0 +1,134 @@
using System;
using System.Runtime.CompilerServices;
using Unity.Profiling;
namespace DCFApixels.DragonECS
{
public sealed class EcsRelationPool<T> : EcsPoolBase
where T : struct, IEcsRelationComponent
{
private EcsWorld _source;
private bool[] _entityFlags;// index = entityID / value = entityFlag;/ value = 0 = no entityID
private T[] _items; //sparse
private int _count;
private PoolRunners _poolRunners;
#if (DEBUG && !DISABLE_DEBUG) || !DRAGONECS_NO_SANITIZE_CHECKS
private int _sanitizeFirstWorld = -1;
private int _sanitizeSecondWorld = -1;
#endif
#region Properites
public int Count => _count;
public int Capacity => _items.Length;
public sealed override EcsWorld World => _source;
public sealed override Type ComponentType => typeof(T);
#endregion
#region Init
protected override void Init(EcsWorld world)
{
_source = world;
_entityFlags = new bool[world.Capacity];
_items = new T[world.Capacity];
_count = 0;
_poolRunners = new PoolRunners(world.Pipeline);
}
#endregion
#region Write/Read/Has/Del
private ProfilerMarker _addMark = new ProfilerMarker("EcsPoo.Add");
private ProfilerMarker _writeMark = new ProfilerMarker("EcsPoo.Write");
private ProfilerMarker _readMark = new ProfilerMarker("EcsPoo.Read");
private ProfilerMarker _hasMark = new ProfilerMarker("EcsPoo.Has");
private ProfilerMarker _delMark = new ProfilerMarker("EcsPoo.Del");
public void Add(int entityID, EcsEntity first, EcsEntity second)
{
#if (DEBUG && !DISABLE_DEBUG) || !DRAGONECS_NO_SANITIZE_CHECKS
if((_sanitizeFirstWorld >= 0 && first.world != _sanitizeFirstWorld) &&
(_sanitizeSecondWorld >= 0 && second.world != _sanitizeSecondWorld))
{
throw new EcsRelationsException();
}
#endif
// using (_addMark.Auto())
// {
ref bool entityFlag = ref _entityFlags[entityID];
if (entityFlag == false)
{
entityFlag = true;
_count++;
_poolRunners.add.OnComponentAdd<T>(entityID);
}
_poolRunners.write.OnComponentWrite<T>(entityID);
_items[entityID].Set(first, second);
// }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Set(int entityID, EcsEntity first, EcsEntity second)
{
#if (DEBUG && !DISABLE_DEBUG) || !DRAGONECS_NO_SANITIZE_CHECKS
if ((_sanitizeFirstWorld >= 0 && first.world != _sanitizeFirstWorld) &&
(_sanitizeSecondWorld >= 0 && second.world != _sanitizeSecondWorld))
{
throw new EcsRelationsException();
}
#endif
// using (_writeMark.Auto())
//{
_poolRunners.write.OnComponentWrite<T>(entityID);
_items[entityID].Set(first, second);
//}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref readonly T Read(int entityID)
{
// using (_readMark.Auto())
return ref _items[entityID];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public sealed override bool Has(int entityID)
{
// using (_hasMark.Auto())
return _entityFlags[entityID];
}
public void Del(int entityID)
{
// using (_delMark.Auto())
// {
_entityFlags[entityID] = false;
_count--;
_poolRunners.del.OnComponentDel<T>(entityID);
// }
}
#endregion
#region WorldCallbacks
protected override void OnWorldResize(int newSize)
{
Array.Resize(ref _entityFlags, newSize);
Array.Resize(ref _items, newSize);
}
protected override void OnDestroy() { }
#endregion
}
public interface IEcsRelationComponent
{
public EcsEntity First { get; set; }
public EcsEntity Second { get; set; }
public void Set(EcsEntity first, EcsEntity second);
}
public static class EcsRelationPoolExt
{
public static EcsRelationPool<TRelationComponent> GetPool<TRelationComponent>(this EcsWorld self)
where TRelationComponent : struct, IEcsRelationComponent
{
return self.GetPool<TRelationComponent, EcsRelationPool<TRelationComponent>>();
}
}
}

View File

@ -5,7 +5,7 @@ using Unity.Profiling;
namespace DCFApixels.DragonECS namespace DCFApixels.DragonECS
{ {
public sealed class EcsSinglePool<T> : EcsPoolBase public sealed class EcsSinglePool<T> : EcsPoolBase
where T : struct where T : struct, IEcsSingleComponent
{ {
private EcsWorld _source; private EcsWorld _source;
@ -93,11 +93,11 @@ namespace DCFApixels.DragonECS
#endregion #endregion
} }
public interface ISingleComponent { } public interface IEcsSingleComponent { }
public static class EcsSinglePoolExt public static class EcsSinglePoolExt
{ {
public static EcsSinglePool<TSingleComponent> GetPool<TSingleComponent>(this EcsWorld self) public static EcsSinglePool<TSingleComponent> GetPool<TSingleComponent>(this EcsWorld self)
where TSingleComponent : struct, ISingleComponent where TSingleComponent : struct, IEcsSingleComponent
{ {
return self.GetPool<TSingleComponent, EcsSinglePool<TSingleComponent>>(); return self.GetPool<TSingleComponent, EcsSinglePool<TSingleComponent>>();
} }

View File

@ -5,11 +5,11 @@ using Unity.Profiling;
namespace DCFApixels.DragonECS namespace DCFApixels.DragonECS
{ {
public sealed class EcsTagPool<T> : EcsPoolBase public sealed class EcsTagPool<T> : EcsPoolBase
where T : struct where T : struct, IEcsTagComponent
{ {
private EcsWorld _source; private EcsWorld _source;
private int[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID private bool[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID
private int _count; private int _count;
private PoolRunners _poolRunners; private PoolRunners _poolRunners;
@ -25,7 +25,7 @@ namespace DCFApixels.DragonECS
{ {
_source = world; _source = world;
_mapping = new int[world.Capacity]; _mapping = new bool[world.Capacity];
_count = 0; _count = 0;
_poolRunners = new PoolRunners(world.Pipeline); _poolRunners = new PoolRunners(world.Pipeline);
@ -40,9 +40,10 @@ namespace DCFApixels.DragonECS
{ {
// using (_addMark.Auto()) // using (_addMark.Auto())
// { // {
if (_mapping[entityID] <= 0) if (_mapping[entityID] == false)
{ {
_mapping[entityID] = ++_count; _count++;
_mapping[entityID] = true;
_poolRunners.add.OnComponentAdd<T>(entityID); _poolRunners.add.OnComponentAdd<T>(entityID);
} }
// } // }
@ -51,13 +52,13 @@ namespace DCFApixels.DragonECS
public sealed override bool Has(int entityID) public sealed override bool Has(int entityID)
{ {
// using (_hasMark.Auto()) // using (_hasMark.Auto())
return _mapping[entityID] > 0; return _mapping[entityID];
} }
public void Del(int entityID) public void Del(int entityID)
{ {
// using (_delMark.Auto()) // using (_delMark.Auto())
// { // {
_mapping[entityID] = 0; _mapping[entityID] = false;
_count--; _count--;
_poolRunners.del.OnComponentDel<T>(entityID); _poolRunners.del.OnComponentDel<T>(entityID);
// } // }