mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-19 02:24:37 +08:00
fix executor logic
This commit is contained in:
parent
89ebd5d1ba
commit
6c1e999a31
@ -13,7 +13,11 @@ namespace DCFApixels.DragonECS.Internal
|
||||
internal class EcsWhereExecutorCore : EcsQueryExecutorCore
|
||||
{
|
||||
private EcsMaskIterator _iterator;
|
||||
private int[] _filteredEntities = new int[32];
|
||||
private int[] _filteredAllEntities = new int[32];
|
||||
private int _filteredAllEntitiesCount = 0;
|
||||
private long _version;
|
||||
|
||||
private int[] _filteredEntities = null;
|
||||
private int _filteredEntitiesCount = 0;
|
||||
|
||||
private long _lastWorldVersion = 0;
|
||||
@ -23,7 +27,7 @@ namespace DCFApixels.DragonECS.Internal
|
||||
public long Version
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _lastWorldVersion; }
|
||||
get { return _version; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -38,49 +42,54 @@ namespace DCFApixels.DragonECS.Internal
|
||||
|
||||
#region Methods
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void Filter(EcsSpan span)
|
||||
private void Execute_Iternal()
|
||||
{
|
||||
_filteredEntitiesCount = _iterator.Iterate(span).CopyTo(ref _filteredEntities);
|
||||
World.ReleaseDelEntityBufferAllAuto();
|
||||
if (_lastWorldVersion != World.Version || _versionsChecker.NextEquals() == false)
|
||||
{
|
||||
_version++;
|
||||
_filteredAllEntitiesCount = _iterator.Iterate(World.Entities).CopyTo(ref _filteredAllEntities);
|
||||
}
|
||||
_lastWorldVersion = World.Version;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsSpan Execute()
|
||||
{
|
||||
return ExecuteFor(World.Entities);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsSpan ExecuteFor(EcsSpan span)
|
||||
private void ExecuteFor_Iternal(EcsSpan span)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
|
||||
if (span.WorldID != World.id) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
||||
#endif
|
||||
World.ReleaseDelEntityBufferAllAuto();
|
||||
if (_lastWorldVersion != World.Version || _versionsChecker.NextEquals() == false)
|
||||
if (_filteredEntities == null)
|
||||
{
|
||||
Filter(span);
|
||||
_filteredEntities = new int[32];
|
||||
}
|
||||
_filteredEntitiesCount = _iterator.Iterate(span).CopyTo(ref _filteredEntities);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsSpan Execute()
|
||||
{
|
||||
Execute_Iternal();
|
||||
return new EcsSpan(World.id, _filteredAllEntities, _filteredAllEntitiesCount);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsSpan ExecuteFor(EcsSpan span)
|
||||
{
|
||||
ExecuteFor_Iternal(span);
|
||||
return new EcsSpan(World.id, _filteredEntities, _filteredEntitiesCount);
|
||||
}
|
||||
|
||||
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
//public EcsSpan Execute(Comparison<int> comparison)
|
||||
//{
|
||||
// return ExecuteFor(_aspect.World.Entities, comparison);
|
||||
// Execute_Iternal();
|
||||
// return new EcsSpan(World.id, _filteredAllEntities, _filteredAllEntitiesCount);
|
||||
//}
|
||||
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
//public EcsSpan ExecuteFor(EcsSpan span, Comparison<int> comparison)
|
||||
//{
|
||||
//#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
// if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
|
||||
// if (span.WorldID != WorldID) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
||||
//#endif
|
||||
// World.ReleaseDelEntityBufferAllAuto();
|
||||
// if (_lastWorldVersion != World.Version)
|
||||
// {
|
||||
// Filter(span);
|
||||
// }
|
||||
// Array.Sort<int>(_filteredEntities, 0, _filteredEntitiesCount, comparison);
|
||||
// ExecuteFor_Iternal(span);
|
||||
// return new EcsSpan(World.id, _filteredEntities, _filteredEntitiesCount);
|
||||
//}
|
||||
#endregion
|
||||
}
|
||||
|
@ -13,6 +13,9 @@ namespace DCFApixels.DragonECS.Internal
|
||||
internal class EcsWhereToGroupExecutorCore : EcsQueryExecutorCore
|
||||
{
|
||||
private EcsMaskIterator _iterator;
|
||||
private EcsGroup _filteredAllGroup;
|
||||
private long _version;
|
||||
|
||||
private EcsGroup _filteredGroup;
|
||||
|
||||
private long _lastWorldVersion;
|
||||
@ -22,7 +25,7 @@ namespace DCFApixels.DragonECS.Internal
|
||||
public long Version
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _lastWorldVersion; }
|
||||
get { return _version; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -30,40 +33,52 @@ namespace DCFApixels.DragonECS.Internal
|
||||
protected sealed override void OnInitialize()
|
||||
{
|
||||
_versionsChecker = new PoolVersionsChecker(Mask);
|
||||
_filteredGroup = EcsGroup.New(World);
|
||||
_filteredAllGroup = EcsGroup.New(World);
|
||||
_iterator = Mask.GetIterator();
|
||||
}
|
||||
protected sealed override void OnDestroy()
|
||||
{
|
||||
_filteredGroup.Dispose();
|
||||
_filteredAllGroup.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void Filter(EcsSpan span)
|
||||
private void Execute_Iternal()
|
||||
{
|
||||
_iterator.Iterate(span).CopyTo(_filteredGroup);
|
||||
World.ReleaseDelEntityBufferAllAuto();
|
||||
if (_lastWorldVersion != World.Version || _versionsChecker.NextEquals() == false)
|
||||
{
|
||||
_version++;
|
||||
_iterator.Iterate(World.Entities).CopyTo(_filteredAllGroup);
|
||||
}
|
||||
_lastWorldVersion = World.Version;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsReadonlyGroup Execute()
|
||||
{
|
||||
return ExecuteFor(World.Entities);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsReadonlyGroup ExecuteFor(EcsSpan span)
|
||||
private void ExecuteFor_Iternal(EcsSpan span)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
|
||||
if (span.WorldID != World.id) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
||||
#endif
|
||||
World.ReleaseDelEntityBufferAllAuto();
|
||||
if (_lastWorldVersion != World.Version || _versionsChecker.NextEquals() == false)
|
||||
if (_filteredGroup == null)
|
||||
{
|
||||
Filter(span);
|
||||
_filteredGroup = EcsGroup.New(World);
|
||||
}
|
||||
return _filteredGroup.Readonly;
|
||||
_iterator.Iterate(span).CopyTo(_filteredGroup);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsReadonlyGroup Execute()
|
||||
{
|
||||
Execute_Iternal();
|
||||
return _filteredAllGroup;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsReadonlyGroup ExecuteFor(EcsSpan span)
|
||||
{
|
||||
ExecuteFor_Iternal(span);
|
||||
return _filteredGroup;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user