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)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get { return _config; }
|
get { return _config; }
|
||||||
}
|
}
|
||||||
|
public long Version
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
get { return _version; }
|
||||||
|
}
|
||||||
public bool IsDestroyed
|
public bool IsDestroyed
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -56,7 +61,6 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public int Capacity
|
public int Capacity
|
||||||
{
|
{
|
||||||
//_denseEntities.Length;
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get { return _entitesCapacity; }
|
get { return _entitesCapacity; }
|
||||||
}
|
}
|
||||||
@ -203,6 +207,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int NewEntity()
|
public int NewEntity()
|
||||||
{
|
{
|
||||||
|
unchecked { _version++; }
|
||||||
int entityID = _entityDispenser.GetFree();
|
int entityID = _entityDispenser.GetFree();
|
||||||
_freeSpace--;
|
_freeSpace--;
|
||||||
_entitiesCount++;
|
_entitiesCount++;
|
||||||
@ -367,6 +372,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
unchecked { _version++; }
|
||||||
count = Math.Clamp(count, 0, _delEntBufferCount);
|
count = Math.Clamp(count, 0, _delEntBufferCount);
|
||||||
_delEntBufferCount -= count;
|
_delEntBufferCount -= count;
|
||||||
ReadOnlySpan<int> buffser = new ReadOnlySpan<int>(_delEntBuffer, _delEntBufferCount, count);
|
ReadOnlySpan<int> buffser = new ReadOnlySpan<int>(_delEntBuffer, _delEntBufferCount, count);
|
||||||
|
@ -7,7 +7,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private TAspect _aspect;
|
private TAspect _aspect;
|
||||||
private int[] _filteredEntities;
|
private int[] _filteredEntities;
|
||||||
|
|
||||||
private long _version;
|
private long _lastWorldVersion;
|
||||||
|
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
private readonly EcsProfilerMarker _executeMarker = new EcsProfilerMarker("Where");
|
private readonly EcsProfilerMarker _executeMarker = new EcsProfilerMarker("Where");
|
||||||
@ -22,7 +22,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public sealed override long Version
|
public sealed override long Version
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get => _version;
|
get => _lastWorldVersion;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -46,8 +46,16 @@ namespace DCFApixels.DragonECS
|
|||||||
if (span.IsNull) throw new System.ArgumentNullException();//TODO составить текст исключения.
|
if (span.IsNull) throw new System.ArgumentNullException();//TODO составить текст исключения.
|
||||||
if (span.WorldID != WorldID) throw new System.ArgumentException();//TODO составить текст исключения.
|
if (span.WorldID != WorldID) throw new System.ArgumentException();//TODO составить текст исключения.
|
||||||
#endif
|
#endif
|
||||||
unchecked { _version++; }
|
EcsSpan result;
|
||||||
EcsSpan result = _aspect.GetIteratorFor(span).CopyToSpan(ref _filteredEntities);
|
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
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
_executeMarker.End();
|
_executeMarker.End();
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,7 +7,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private TAspect _aspect;
|
private TAspect _aspect;
|
||||||
private EcsGroup _filteredGroup;
|
private EcsGroup _filteredGroup;
|
||||||
|
|
||||||
private long _version;
|
private long _lastWorldVersion;
|
||||||
|
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
private readonly EcsProfilerMarker _executeMarker = new EcsProfilerMarker("Where");
|
private readonly EcsProfilerMarker _executeMarker = new EcsProfilerMarker("Where");
|
||||||
@ -22,7 +22,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public sealed override long Version
|
public sealed override long Version
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get => _version;
|
get => _lastWorldVersion;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -49,8 +49,11 @@ namespace DCFApixels.DragonECS
|
|||||||
if (span.IsNull) throw new System.ArgumentNullException();//TODO составить текст исключения.
|
if (span.IsNull) throw new System.ArgumentNullException();//TODO составить текст исключения.
|
||||||
if (span.WorldID != WorldID) throw new System.ArgumentException();//TODO составить текст исключения.
|
if (span.WorldID != WorldID) throw new System.ArgumentException();//TODO составить текст исключения.
|
||||||
#endif
|
#endif
|
||||||
unchecked { _version++; }
|
if (_lastWorldVersion != World.Version)
|
||||||
_aspect.GetIteratorFor(span).CopyTo(_filteredGroup);
|
{
|
||||||
|
_aspect.GetIteratorFor(span).CopyTo(_filteredGroup);
|
||||||
|
_lastWorldVersion = World.Version;
|
||||||
|
}
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
_executeMarker.End();
|
_executeMarker.End();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user