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
|
internal class EcsWhereExecutorCore : EcsQueryExecutorCore
|
||||||
{
|
{
|
||||||
private EcsMaskIterator _iterator;
|
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 int _filteredEntitiesCount = 0;
|
||||||
|
|
||||||
private long _lastWorldVersion = 0;
|
private long _lastWorldVersion = 0;
|
||||||
@ -23,7 +27,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
public long Version
|
public long Version
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get { return _lastWorldVersion; }
|
get { return _version; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -38,50 +42,55 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[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;
|
_lastWorldVersion = World.Version;
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsSpan Execute()
|
private void ExecuteFor_Iternal(EcsSpan span)
|
||||||
{
|
|
||||||
return ExecuteFor(World.Entities);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public EcsSpan ExecuteFor(EcsSpan span)
|
|
||||||
{
|
{
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
|
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
|
||||||
if (span.WorldID != World.id) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
if (span.WorldID != World.id) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
||||||
#endif
|
#endif
|
||||||
World.ReleaseDelEntityBufferAllAuto();
|
if (_filteredEntities == null)
|
||||||
if (_lastWorldVersion != World.Version || _versionsChecker.NextEquals() == false)
|
|
||||||
{
|
{
|
||||||
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);
|
return new EcsSpan(World.id, _filteredEntities, _filteredEntitiesCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
// public EcsSpan Execute(Comparison<int> comparison)
|
//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)
|
//[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)); }
|
// ExecuteFor_Iternal(span);
|
||||||
// if (span.WorldID != WorldID) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
// return new EcsSpan(World.id, _filteredEntities, _filteredEntitiesCount);
|
||||||
//#endif
|
//}
|
||||||
// World.ReleaseDelEntityBufferAllAuto();
|
|
||||||
// if (_lastWorldVersion != World.Version)
|
|
||||||
// {
|
|
||||||
// Filter(span);
|
|
||||||
// }
|
|
||||||
// Array.Sort<int>(_filteredEntities, 0, _filteredEntitiesCount, comparison);
|
|
||||||
// }
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,9 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
internal class EcsWhereToGroupExecutorCore : EcsQueryExecutorCore
|
internal class EcsWhereToGroupExecutorCore : EcsQueryExecutorCore
|
||||||
{
|
{
|
||||||
private EcsMaskIterator _iterator;
|
private EcsMaskIterator _iterator;
|
||||||
|
private EcsGroup _filteredAllGroup;
|
||||||
|
private long _version;
|
||||||
|
|
||||||
private EcsGroup _filteredGroup;
|
private EcsGroup _filteredGroup;
|
||||||
|
|
||||||
private long _lastWorldVersion;
|
private long _lastWorldVersion;
|
||||||
@ -22,7 +25,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
public long Version
|
public long Version
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get { return _lastWorldVersion; }
|
get { return _version; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -30,40 +33,52 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
protected sealed override void OnInitialize()
|
protected sealed override void OnInitialize()
|
||||||
{
|
{
|
||||||
_versionsChecker = new PoolVersionsChecker(Mask);
|
_versionsChecker = new PoolVersionsChecker(Mask);
|
||||||
_filteredGroup = EcsGroup.New(World);
|
_filteredAllGroup = EcsGroup.New(World);
|
||||||
_iterator = Mask.GetIterator();
|
_iterator = Mask.GetIterator();
|
||||||
}
|
}
|
||||||
protected sealed override void OnDestroy()
|
protected sealed override void OnDestroy()
|
||||||
{
|
{
|
||||||
_filteredGroup.Dispose();
|
_filteredAllGroup.Dispose();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[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;
|
_lastWorldVersion = World.Version;
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsReadonlyGroup Execute()
|
private void ExecuteFor_Iternal(EcsSpan span)
|
||||||
{
|
|
||||||
return ExecuteFor(World.Entities);
|
|
||||||
}
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public EcsReadonlyGroup ExecuteFor(EcsSpan span)
|
|
||||||
{
|
{
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
|
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
|
||||||
if (span.WorldID != World.id) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
if (span.WorldID != World.id) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
||||||
#endif
|
#endif
|
||||||
World.ReleaseDelEntityBufferAllAuto();
|
if (_filteredGroup == null)
|
||||||
if (_lastWorldVersion != World.Version || _versionsChecker.NextEquals() == false)
|
|
||||||
{
|
{
|
||||||
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
|
#endregion
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user