mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
add EcsWrold.Version & optimize query executors
This commit is contained in:
parent
316735cf9a
commit
186ef6bd1a
@ -44,6 +44,11 @@ namespace DCFApixels.DragonECS
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _config; }
|
||||
}
|
||||
public long Version
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _version; }
|
||||
}
|
||||
public bool IsDestroyed
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@ -56,7 +61,6 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
public int Capacity
|
||||
{
|
||||
//_denseEntities.Length;
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _entitesCapacity; }
|
||||
}
|
||||
@ -203,6 +207,7 @@ namespace DCFApixels.DragonECS
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int NewEntity()
|
||||
{
|
||||
unchecked { _version++; }
|
||||
int entityID = _entityDispenser.GetFree();
|
||||
_freeSpace--;
|
||||
_entitiesCount++;
|
||||
@ -367,6 +372,7 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
return;
|
||||
}
|
||||
unchecked { _version++; }
|
||||
count = Math.Clamp(count, 0, _delEntBufferCount);
|
||||
_delEntBufferCount -= count;
|
||||
ReadOnlySpan<int> buffser = new ReadOnlySpan<int>(_delEntBuffer, _delEntBufferCount, count);
|
||||
|
@ -7,7 +7,7 @@ namespace DCFApixels.DragonECS
|
||||
private TAspect _aspect;
|
||||
private int[] _filteredEntities;
|
||||
|
||||
private long _version;
|
||||
private long _lastWorldVersion;
|
||||
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
private readonly EcsProfilerMarker _executeMarker = new EcsProfilerMarker("Where");
|
||||
@ -22,7 +22,7 @@ namespace DCFApixels.DragonECS
|
||||
public sealed override long Version
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _version;
|
||||
get => _lastWorldVersion;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -46,8 +46,16 @@ namespace DCFApixels.DragonECS
|
||||
if (span.IsNull) throw new System.ArgumentNullException();//TODO составить текст исключения.
|
||||
if (span.WorldID != WorldID) throw new System.ArgumentException();//TODO составить текст исключения.
|
||||
#endif
|
||||
unchecked { _version++; }
|
||||
EcsSpan result = _aspect.GetIteratorFor(span).CopyToSpan(ref _filteredEntities);
|
||||
EcsSpan result;
|
||||
if (_lastWorldVersion != World.Version)
|
||||
{
|
||||
result = _aspect.GetIteratorFor(span).CopyToSpan(ref _filteredEntities);
|
||||
_lastWorldVersion = World.Version;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new EcsSpan(WorldID, _filteredEntities);
|
||||
}
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
_executeMarker.End();
|
||||
#endif
|
||||
|
@ -7,7 +7,7 @@ namespace DCFApixels.DragonECS
|
||||
private TAspect _aspect;
|
||||
private EcsGroup _filteredGroup;
|
||||
|
||||
private long _version;
|
||||
private long _lastWorldVersion;
|
||||
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
private readonly EcsProfilerMarker _executeMarker = new EcsProfilerMarker("Where");
|
||||
@ -22,7 +22,7 @@ namespace DCFApixels.DragonECS
|
||||
public sealed override long Version
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _version;
|
||||
get => _lastWorldVersion;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -49,8 +49,11 @@ namespace DCFApixels.DragonECS
|
||||
if (span.IsNull) throw new System.ArgumentNullException();//TODO составить текст исключения.
|
||||
if (span.WorldID != WorldID) throw new System.ArgumentException();//TODO составить текст исключения.
|
||||
#endif
|
||||
unchecked { _version++; }
|
||||
_aspect.GetIteratorFor(span).CopyTo(_filteredGroup);
|
||||
if (_lastWorldVersion != World.Version)
|
||||
{
|
||||
_aspect.GetIteratorFor(span).CopyTo(_filteredGroup);
|
||||
_lastWorldVersion = World.Version;
|
||||
}
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
_executeMarker.End();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user