mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 17:34:36 +08:00
stash
This commit is contained in:
parent
d414915465
commit
85a56c22a0
@ -30,7 +30,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public readonly short id;
|
public readonly short id;
|
||||||
private IConfigContainer _configs;
|
private IConfigContainer _configs;
|
||||||
|
|
||||||
private bool _isDestroyed = false;
|
private bool _isDestroyed = false;
|
||||||
|
|
||||||
private IdDispenser _entityDispenser;
|
private IdDispenser _entityDispenser;
|
||||||
private int _entitiesCount = 0;
|
private int _entitiesCount = 0;
|
||||||
@ -45,6 +45,10 @@ namespace DCFApixels.DragonECS
|
|||||||
internal int[] _entityComponentMasks = Array.Empty<int>();
|
internal int[] _entityComponentMasks = Array.Empty<int>();
|
||||||
private const int COMPONENT_MASK_CHUNK_SIZE = 32;
|
private const int COMPONENT_MASK_CHUNK_SIZE = 32;
|
||||||
|
|
||||||
|
private bool[] _isDirtyEntitiesMapping = Array.Empty<bool>();
|
||||||
|
private int[] _dirtyEntitiesDense = Array.Empty<int>();
|
||||||
|
private int _dirtyEntitiesDenseCount = 0;
|
||||||
|
|
||||||
//"лениво" обновляется только для NewEntity
|
//"лениво" обновляется только для NewEntity
|
||||||
private long _deleteLeakedEntitesLastVersion = 0;
|
private long _deleteLeakedEntitesLastVersion = 0;
|
||||||
//обновляется в NewEntity и в DelEntity
|
//обновляется в NewEntity и в DelEntity
|
||||||
@ -565,6 +569,9 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||||
private void OnEntityDispenserResized(int newSize)
|
private void OnEntityDispenserResized(int newSize)
|
||||||
{
|
{
|
||||||
|
Array.Resize(ref _dirtyEntitiesDense, newSize);
|
||||||
|
Array.Resize(ref _isDirtyEntitiesMapping, newSize);
|
||||||
|
|
||||||
Array.Resize(ref _entities, newSize);
|
Array.Resize(ref _entities, newSize);
|
||||||
Array.Resize(ref _delEntBuffer, newSize);
|
Array.Resize(ref _delEntBuffer, newSize);
|
||||||
_entityComponentMaskLength = CalcEntityComponentMaskLastIndex(); //_pools.Length / COMPONENT_MASK_CHUNK_SIZE + 1;
|
_entityComponentMaskLength = CalcEntityComponentMaskLastIndex(); //_pools.Length / COMPONENT_MASK_CHUNK_SIZE + 1;
|
||||||
@ -775,6 +782,22 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region DirtyEntities
|
||||||
|
public EcsSpan GetDirtyEntities()
|
||||||
|
{
|
||||||
|
return new EcsSpan(id, _dirtyEntitiesDense, _dirtyEntitiesDenseCount);
|
||||||
|
}
|
||||||
|
public void SetEntityDirty(int entityID)
|
||||||
|
{
|
||||||
|
bool lastValue = _isDirtyEntitiesMapping[entityID];
|
||||||
|
if (lastValue)
|
||||||
|
{
|
||||||
|
_isDirtyEntitiesMapping[entityID] = true;
|
||||||
|
_dirtyEntitiesDense[_dirtyEntitiesDenseCount++] = entityID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EcsWorldExtenssions
|
public static class EcsWorldExtenssions
|
||||||
|
59
src/Executors/EcsFilter.cs
Normal file
59
src/Executors/EcsFilter.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using DCFApixels.DragonECS.Internal;
|
||||||
|
using System;
|
||||||
|
using System.Reflection.Emit;
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS
|
||||||
|
{
|
||||||
|
public abstract class EcsFilter : EcsQueryExecutor
|
||||||
|
{
|
||||||
|
public abstract EcsAspect AspectRaw { get; }
|
||||||
|
}
|
||||||
|
public class EcsFilter<TAspect> : EcsFilter
|
||||||
|
where TAspect : EcsAspect
|
||||||
|
{
|
||||||
|
private long _version;
|
||||||
|
|
||||||
|
private EcsGroup _filterGroup;
|
||||||
|
|
||||||
|
private TAspect _aspect;
|
||||||
|
|
||||||
|
public override long Version { get { return _version; } }
|
||||||
|
public TAspect Aspect { get { return _aspect; } }
|
||||||
|
public override EcsAspect AspectRaw { get { return _aspect; } }
|
||||||
|
|
||||||
|
private bool IsMatches(int entityID)
|
||||||
|
{
|
||||||
|
//int _entityComponentMaskBitShift = BitsUtility.GetHighBitNumber(World._entityComponentMaskLength);
|
||||||
|
//
|
||||||
|
//int[] _entityComponentMasks = World._entityComponentMasks;
|
||||||
|
//int chunck = entityID << _entityComponentMaskBitShift;
|
||||||
|
//for (int i = 0; i < _sortIncChunckBuffer.Length; i++)
|
||||||
|
//{
|
||||||
|
// var bit = _sortIncChunckBuffer.ptr[i];
|
||||||
|
// if ((_entityComponentMasks[chunck + bit.chankIndex] & bit.mask) != bit.mask)
|
||||||
|
// {
|
||||||
|
// goto skip;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//for (int i = 0; i < _sortExcChunckBuffer.Length; i++)
|
||||||
|
//{
|
||||||
|
// var bit = _sortExcChunckBuffer.ptr[i];
|
||||||
|
// if ((_entityComponentMasks[chunck + bit.chankIndex] & bit.mask) != 0)
|
||||||
|
// {
|
||||||
|
// goto skip;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//return true;
|
||||||
|
//skip: continue;
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
protected override void OnInitialize()
|
||||||
|
{
|
||||||
|
_aspect = World.GetAspect<TAspect>();
|
||||||
|
}
|
||||||
|
protected override void OnDestroy()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user