mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-19 02:24:37 +08:00
Merge branch 'main' into test-pool
This commit is contained in:
commit
f809fd8c71
@ -881,13 +881,13 @@ using (_marker.Auto())
|
|||||||
</br>
|
</br>
|
||||||
|
|
||||||
# Define Symbols
|
# Define Symbols
|
||||||
+ `DISABLE_POOLS_EVENTS` - выключает реактивное поведение в пулах.
|
+ `DRAGONECS_DISABLE_POOLS_EVENTS` - выключает реактивное поведение в пулах.
|
||||||
+ `ENABLE_DRAGONECS_DEBUGGER` - включает работу EcsDebug в релизном билде.
|
+ `DRAGONECS_ENABLE_DEBUG_SERVICE` - включает работу EcsDebug в релизном билде.
|
||||||
+ `ENABLE_DRAGONECS_ASSERT_CHECKS` - включает опускаемые в релизном билде проверки.
|
+ `DRAGONECS_STABILITY_MODE` - включает опускаемые в релизном билде проверки.
|
||||||
|
+ `DRAGONECS_DISABLE_CATH_EXCEPTIONS` - Выключает поведение по умолчанию по обработке исключений. По умолчанию фреймворк будет ловить исключения с выводом информации из исключений через EcsDebug и продолжать работу.
|
||||||
+ `REFLECTION_DISABLED` - Полностью ограничивает работу фреймворка с Reflection.
|
+ `REFLECTION_DISABLED` - Полностью ограничивает работу фреймворка с Reflection.
|
||||||
+ `DISABLE_DEBUG` - Для среды где не поддерживается ручное отключение DEBUG, например Unity.
|
+ `DISABLE_DEBUG` - Для среды где не поддерживается ручное отключение DEBUG, например Unity.
|
||||||
+ `ENABLE_DUMMY_SPAN` - На случай если в среде не поддерживаются Span типы, включает его замену.
|
+ `ENABLE_DUMMY_SPAN` - На случай если в среде не поддерживаются Span типы, включает его замену.
|
||||||
+ `DISABLE_CATH_EXCEPTIONS` - Выключает поведение по умолчанию по обработке исключений. По умолчанию фреймворк будет ловить исключения с выводом информации из исключений через EcsDebug и продолжать работу.
|
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
|
|
||||||
|
@ -844,13 +844,13 @@ using (_marker.Auto())
|
|||||||
</br>
|
</br>
|
||||||
|
|
||||||
# Define Symbols
|
# Define Symbols
|
||||||
+ `DISABLE_POOLS_EVENTS` - 禁用池子事件的响应行为。
|
+ `DRAGONECS_DISABLE_POOLS_EVENTS` - 禁用池子事件的响应行为。
|
||||||
+ `ENABLE_DRAGONECS_DEBUGGER` - 在发布版中启用 EcsDebug 的工作。
|
+ `DRAGONECS_ENABLE_DEBUG_SERVICE` - 在发布版中启用 EcsDebug 的工作。
|
||||||
+ `ENABLE_DRAGONECS_ASSERT_CHECKS` - 在发布版中启用可忽略的检查和异常。
|
+ `DRAGONECS_STABILITY_MODE` - 默认情况下,为了优化,框架在发布版本中跳过许多异常检查。此定义不是跳过检查,而是将其替换为能够解决错误的代码。这提高了稳定性,但降低了执行速度。
|
||||||
|
+ `DRAGONECS_DISABLE_CATH_EXCEPTIONS` - 禁用默认的异常处理行为。默认情况下,框架将捕获异常并通过 EcsDebug 输出异常信息,然后继续执行。
|
||||||
+ `REFLECTION_DISABLED` - 完全限制框架内部代码中的 Reflection 使用。
|
+ `REFLECTION_DISABLED` - 完全限制框架内部代码中的 Reflection 使用。
|
||||||
+ `DISABLE_DEBUG` - 用于不支持手动禁用 DEBUG 的环境,例如 Unity。
|
+ `DISABLE_DEBUG` - 用于不支持手动禁用 DEBUG 的环境,例如 Unity。
|
||||||
+ `ENABLE_DUMMY_SPAN` - 如果环境不支持 Span 类型,则启用它的替代。
|
+ `ENABLE_DUMMY_SPAN` - 如果环境不支持 Span 类型,则启用它的替代。
|
||||||
+ `DISABLE_CATH_EXCEPTIONS` - 禁用默认的异常处理行为。默认情况下,框架将捕获异常并通过 EcsDebug 输出异常信息,然后继续执行。
|
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
|
|
||||||
|
@ -851,13 +851,14 @@ using (_marker.Auto())
|
|||||||
</br>
|
</br>
|
||||||
|
|
||||||
# Define Symbols
|
# Define Symbols
|
||||||
+ `DISABLE_POOLS_EVENTS` - disables reactive behavior in pools.
|
+ `DRAGONECS_DISABLE_POOLS_EVENTS` - Disables reactive behavior in pools.
|
||||||
+ `ENABLE_DRAGONECS_DEBUGGER` - enables EcsDebug functionality in release builds.
|
+ `DRAGONECS_ENABLE_DEBUG_SERVICE` - Enables EcsDebug functionality in release builds.
|
||||||
+ `ENABLE_DRAGONECS_ASSERT_CHECKS` - enables omitted checks in the release build.
|
+ `DRAGONECS_STABILITY_MODE` - By default, for optimization purposes, the framework skips many exception checks in the release build. This define, instead of disabling checks, replaces them with code that resolves errors. This increases stability but reduces execution speed.
|
||||||
|
+ `DRAGONECS_DISABLE_CATH_EXCEPTIONS` - Turns off the default exception handling behavior. By default, the framework will catch exceptions with the exception information output via EcsDebug and continue working.
|
||||||
+ `REFLECTION_DISABLED` - completely restricts the framework's use of Reflection.
|
+ `REFLECTION_DISABLED` - completely restricts the framework's use of Reflection.
|
||||||
+ `DISABLE_DEBUG` - for environments where manual DEBUG disabling is not supported, e.g., Unity.
|
+ `DISABLE_DEBUG` - for environments where manual DEBUG disabling is not supported, e.g., Unity.
|
||||||
+ `ENABLE_DUMMY_SPAN` - For environments where Span types are not supported, enables its replacement.
|
+ `ENABLE_DUMMY_SPAN` - For environments where Span types are not supported, enables its replacement.
|
||||||
+ `DISABLE_CATH_EXCEPTIONS` - Turns off the default exception handling behavior. By default, the framework will catch exceptions with the exception information output via EcsDebug and continue working.
|
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"displayName": "DragonECS",
|
"displayName": "DragonECS",
|
||||||
"description": "C# Entity Component System Framework",
|
"description": "C# Entity Component System Framework",
|
||||||
"unity": "2020.3",
|
"unity": "2020.3",
|
||||||
"version": "0.9.1",
|
"version": "0.9.4",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/DCFApixels/DragonECS.git"
|
"url": "https://github.com/DCFApixels/DragonECS.git"
|
||||||
|
@ -149,7 +149,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -166,10 +166,11 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
try { item.Run(); }
|
try { item.Run(); }
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw e;
|
||||||
#endif
|
#else
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -234,8 +234,16 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
internal void ReleaseGroup(EcsGroup group)
|
internal void ReleaseGroup(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (group.World != this) { Throw.World_GroupDoesNotBelongWorld(); }
|
if (group.World != this) { Throw.World_GroupDoesNotBelongWorld(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (group.World != this)
|
||||||
|
{
|
||||||
|
if (TryGetWorld(group.WorldID, out EcsWorld sourceWorld))
|
||||||
|
{
|
||||||
|
group.World.ReleaseGroup(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
group._isReleased = true;
|
group._isReleased = true;
|
||||||
group.Clear();
|
group.Clear();
|
||||||
@ -307,8 +315,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
|
if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (index < 0 || index >= Count) { return EcsConsts.NULL_ENTITY_ID; }
|
||||||
#endif
|
#endif
|
||||||
return _dense[++index];
|
return _dense[++index];
|
||||||
}
|
}
|
||||||
@ -316,7 +326,7 @@ namespace DCFApixels.DragonECS
|
|||||||
// set
|
// set
|
||||||
// {
|
// {
|
||||||
// // TODO добавить лок енумератора на изменение
|
// // TODO добавить лок енумератора на изменение
|
||||||
//#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
//#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
// if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
|
// if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
|
||||||
//#endif
|
//#endif
|
||||||
// var oldValue = _dense[index];
|
// var oldValue = _dense[index];
|
||||||
@ -369,8 +379,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Add/Remove
|
#region Add/Remove
|
||||||
public void AddUnchecked(int entityID)
|
public void AddUnchecked(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID)) { Throw.Group_AlreadyContains(entityID); }
|
if (Has(entityID)) { Throw.Group_AlreadyContains(entityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (Has(entityID)) { return; }
|
||||||
#endif
|
#endif
|
||||||
Add_Internal(entityID);
|
Add_Internal(entityID);
|
||||||
}
|
}
|
||||||
@ -413,8 +425,10 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public void RemoveUnchecked(int entityID)
|
public void RemoveUnchecked(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID) == false) { Throw.Group_DoesNotContain(entityID); }
|
if (Has(entityID) == false) { Throw.Group_DoesNotContain(entityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (Has(entityID) == false) { return; }
|
||||||
#endif
|
#endif
|
||||||
Remove_Internal(entityID);
|
Remove_Internal(entityID);
|
||||||
}
|
}
|
||||||
@ -526,13 +540,16 @@ namespace DCFApixels.DragonECS
|
|||||||
#region CopyFrom/Clone/Slice/ToSpan/ToArray
|
#region CopyFrom/Clone/Slice/ToSpan/ToArray
|
||||||
public void CopyFrom(EcsGroup group)
|
public void CopyFrom(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (group.World != _source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (group.World != _source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
#endif
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
if (_count > 0)
|
if (group.World != _source)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
Clear();
|
||||||
foreach (var entityID in group)
|
foreach (var entityID in group)
|
||||||
{
|
{
|
||||||
Add_Internal(entityID);
|
Add_Internal(entityID);
|
||||||
@ -578,8 +595,11 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsSpan Slice(int start, int length)
|
public EcsSpan Slice(int start, int length)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (start < 0 || start + length > _count) { Throw.ArgumentOutOfRange(); }
|
if (start < 0 || start + length > _count) { Throw.ArgumentOutOfRange(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (start < 0) { start = 0; }
|
||||||
|
if (start + length > _count) { length = _count - start; }
|
||||||
#endif
|
#endif
|
||||||
return new EcsSpan(WorldID, _dense, start + 1, length);
|
return new EcsSpan(WorldID, _dense, start + 1, length);
|
||||||
}
|
}
|
||||||
@ -622,8 +642,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Union sets</summary>
|
/// <summary>as Union sets</summary>
|
||||||
public void UnionWith(EcsGroup group)
|
public void UnionWith(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in group) { UnionWithStep(entityID); }
|
foreach (var entityID in group) { UnionWithStep(entityID); }
|
||||||
}
|
}
|
||||||
@ -633,8 +655,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Union sets</summary>
|
/// <summary>as Union sets</summary>
|
||||||
public void UnionWith(EcsSpan span)
|
public void UnionWith(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in span) { UnionWithStep(entityID); }
|
foreach (var entityID in span) { UnionWithStep(entityID); }
|
||||||
}
|
}
|
||||||
@ -656,8 +680,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Except sets</summary>
|
/// <summary>as Except sets</summary>
|
||||||
public void ExceptWith(EcsGroup group)
|
public void ExceptWith(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return; }
|
||||||
#endif
|
#endif
|
||||||
if (group.Count > Count) //мини оптимизация, итеррируемся по короткому списку
|
if (group.Count > Count) //мини оптимизация, итеррируемся по короткому списку
|
||||||
{
|
{
|
||||||
@ -681,8 +707,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Except sets</summary>
|
/// <summary>as Except sets</summary>
|
||||||
public void ExceptWith(EcsSpan span)
|
public void ExceptWith(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in span) { ExceptWithStep_Internal(entityID); }
|
foreach (var entityID in span) { ExceptWithStep_Internal(entityID); }
|
||||||
}
|
}
|
||||||
@ -704,8 +732,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Intersect sets</summary>
|
/// <summary>as Intersect sets</summary>
|
||||||
public void IntersectWith(EcsGroup group)
|
public void IntersectWith(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return; }
|
||||||
#endif
|
#endif
|
||||||
for (int i = _count; i > 0; i--)//итерация в обратном порядке исключает ошибки при удалении элементов
|
for (int i = _count; i > 0; i--)//итерация в обратном порядке исключает ошибки при удалении элементов
|
||||||
{
|
{
|
||||||
@ -722,8 +752,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Intersect sets</summary>
|
/// <summary>as Intersect sets</summary>
|
||||||
public void IntersectWith(EcsSpan span)
|
public void IntersectWith(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in span)
|
foreach (var entityID in span)
|
||||||
{
|
{
|
||||||
@ -765,8 +797,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Symmetric Except sets</summary>
|
/// <summary>as Symmetric Except sets</summary>
|
||||||
public void SymmetricExceptWith(EcsGroup group)
|
public void SymmetricExceptWith(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in group) { SymmetricExceptWithStep_Internal(entityID); }
|
foreach (var entityID in group) { SymmetricExceptWithStep_Internal(entityID); }
|
||||||
}
|
}
|
||||||
@ -777,8 +811,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Symmetric Except sets</summary>
|
/// <summary>as Symmetric Except sets</summary>
|
||||||
public void SymmetricExceptWith(EcsSpan span)
|
public void SymmetricExceptWith(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in span) { SymmetricExceptWithStep_Internal(entityID); }
|
foreach (var entityID in span) { SymmetricExceptWithStep_Internal(entityID); }
|
||||||
}
|
}
|
||||||
@ -827,8 +863,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region SetEquals
|
#region SetEquals
|
||||||
public bool SetEquals(EcsGroup group)
|
public bool SetEquals(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group.World) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (group.Count != Count) { return false; }
|
if (group.Count != Count) { return false; }
|
||||||
foreach (var entityID in group)
|
foreach (var entityID in group)
|
||||||
@ -844,8 +882,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool SetEquals(EcsReadonlyGroup group) { return SetEquals(group.GetSource_Internal()); }
|
public bool SetEquals(EcsReadonlyGroup group) { return SetEquals(group.GetSource_Internal()); }
|
||||||
public bool SetEquals(EcsSpan span)
|
public bool SetEquals(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (span.Count != Count) { return false; }
|
if (span.Count != Count) { return false; }
|
||||||
foreach (var entityID in span)
|
foreach (var entityID in span)
|
||||||
@ -874,8 +914,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Overlaps
|
#region Overlaps
|
||||||
public bool Overlaps(EcsGroup group)
|
public bool Overlaps(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group.World) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (group.Count > Count)
|
if (group.Count > Count)
|
||||||
{
|
{
|
||||||
@ -903,8 +945,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool Overlaps(EcsReadonlyGroup group) { return Overlaps(group.GetSource_Internal()); }
|
public bool Overlaps(EcsReadonlyGroup group) { return Overlaps(group.GetSource_Internal()); }
|
||||||
public bool Overlaps(EcsSpan span)
|
public bool Overlaps(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in span)
|
foreach (var entityID in span)
|
||||||
{
|
{
|
||||||
@ -931,8 +975,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region IsSubsetOf/IsProperSubsetOf
|
#region IsSubsetOf/IsProperSubsetOf
|
||||||
public bool IsSubsetOf(EcsGroup group)
|
public bool IsSubsetOf(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (Count == 0) { return true; }
|
if (Count == 0) { return true; }
|
||||||
if (group.Count < Count) { return false; }
|
if (group.Count < Count) { return false; }
|
||||||
@ -942,8 +988,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool IsSubsetOf(EcsReadonlyGroup group) { return IsSubsetOf(group.GetSource_Internal()); }
|
public bool IsSubsetOf(EcsReadonlyGroup group) { return IsSubsetOf(group.GetSource_Internal()); }
|
||||||
public bool IsSubsetOf(EcsSpan span)
|
public bool IsSubsetOf(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (Count == 0) { return true; }
|
if (Count == 0) { return true; }
|
||||||
if (span.Count < Count) { return false; }
|
if (span.Count < Count) { return false; }
|
||||||
@ -960,8 +1008,10 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public bool IsProperSubsetOf(EcsGroup group)
|
public bool IsProperSubsetOf(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (Count == 0) { return true; }
|
if (Count == 0) { return true; }
|
||||||
if (group.Count <= Count) { return false; }
|
if (group.Count <= Count) { return false; }
|
||||||
@ -971,8 +1021,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool IsProperSubsetOf(EcsReadonlyGroup group) { return IsProperSubsetOf(group.GetSource_Internal()); }
|
public bool IsProperSubsetOf(EcsReadonlyGroup group) { return IsProperSubsetOf(group.GetSource_Internal()); }
|
||||||
public bool IsProperSubsetOf(EcsSpan span)
|
public bool IsProperSubsetOf(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (Count == 0) { return true; }
|
if (Count == 0) { return true; }
|
||||||
if (span.Count <= Count) { return false; }
|
if (span.Count <= Count) { return false; }
|
||||||
@ -1035,8 +1087,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region IsSupersetOf/IsProperSupersetOf
|
#region IsSupersetOf/IsProperSupersetOf
|
||||||
public bool IsSupersetOf(EcsGroup group)
|
public bool IsSupersetOf(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (group.Count > Count) { return false; }
|
if (group.Count > Count) { return false; }
|
||||||
return IsSupersetOf_Internal(group);
|
return IsSupersetOf_Internal(group);
|
||||||
@ -1045,8 +1099,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool IsSupersetOf(EcsReadonlyGroup group) { return IsSupersetOf(group.GetSource_Internal()); }
|
public bool IsSupersetOf(EcsReadonlyGroup group) { return IsSupersetOf(group.GetSource_Internal()); }
|
||||||
public bool IsSupersetOf(EcsSpan span)
|
public bool IsSupersetOf(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (span.Count > Count) { return false; }
|
if (span.Count > Count) { return false; }
|
||||||
return IsSupersetOf_Internal(span);
|
return IsSupersetOf_Internal(span);
|
||||||
@ -1061,8 +1117,10 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public bool IsProperSupersetOf(EcsGroup group)
|
public bool IsProperSupersetOf(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (group.Count >= Count) { return false; }
|
if (group.Count >= Count) { return false; }
|
||||||
return IsSupersetOf_Internal(group);
|
return IsSupersetOf_Internal(group);
|
||||||
@ -1071,8 +1129,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool IsProperSupersetOf(EcsReadonlyGroup group) { return IsProperSupersetOf(group.GetSource_Internal()); }
|
public bool IsProperSupersetOf(EcsReadonlyGroup group) { return IsProperSupersetOf(group.GetSource_Internal()); }
|
||||||
public bool IsProperSupersetOf(EcsSpan span)
|
public bool IsProperSupersetOf(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (span.Count >= Count) { return false; }
|
if (span.Count >= Count) { return false; }
|
||||||
return IsSupersetOf_Internal(span);
|
return IsSupersetOf_Internal(span);
|
||||||
@ -1129,8 +1189,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Union(EcsGroup a, EcsGroup b)
|
public static EcsGroup Union(EcsGroup a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a._source != b._source) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a._source.GetFreeGroup();
|
EcsGroup result = a._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1153,8 +1215,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Union(EcsSpan a, EcsSpan b)
|
public static EcsGroup Union(EcsSpan a, EcsSpan b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a.World.GetFreeGroup();
|
EcsGroup result = a.World.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1174,8 +1238,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Except(EcsGroup a, EcsGroup b)
|
public static EcsGroup Except(EcsGroup a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a._source != b._source) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a._source.GetFreeGroup();
|
EcsGroup result = a._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1191,8 +1257,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Except(EcsSpan a, EcsGroup b)
|
public static EcsGroup Except(EcsSpan a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b._source.ID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = b._source.GetFreeGroup();
|
EcsGroup result = b._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1208,8 +1276,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Except(EcsSpan a, EcsSpan b)
|
public static EcsGroup Except(EcsSpan a, EcsSpan b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a.World.GetFreeGroup();
|
EcsGroup result = a.World.GetFreeGroup();
|
||||||
result.CopyFrom(a);
|
result.CopyFrom(a);
|
||||||
@ -1229,8 +1299,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Intersect(EcsGroup a, EcsGroup b)
|
public static EcsGroup Intersect(EcsGroup a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a._source != b._source) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a._source.GetFreeGroup();
|
EcsGroup result = a._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1246,8 +1318,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Intersect(EcsSpan a, EcsGroup b)
|
public static EcsGroup Intersect(EcsSpan a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b._source.ID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = b._source.GetFreeGroup();
|
EcsGroup result = b._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1270,8 +1344,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Intersect(EcsSpan a, EcsSpan b)
|
public static EcsGroup Intersect(EcsSpan a, EcsSpan b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = b.World.GetFreeGroup();
|
EcsGroup result = b.World.GetFreeGroup();
|
||||||
result.CopyFrom(a);
|
result.CopyFrom(a);
|
||||||
@ -1291,8 +1367,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup SymmetricExcept(EcsGroup a, EcsGroup b)
|
public static EcsGroup SymmetricExcept(EcsGroup a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a._source != b._source) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a._source.GetFreeGroup();
|
EcsGroup result = a._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1315,8 +1393,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup SymmetricExcept(EcsSpan a, EcsSpan b)
|
public static EcsGroup SymmetricExcept(EcsSpan a, EcsSpan b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a.World.GetFreeGroup();
|
EcsGroup result = a.World.GetFreeGroup();
|
||||||
result.CopyFrom(a);
|
result.CopyFrom(a);
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace DCFApixels.DragonECS
|
using System;
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
public static class EcsConsts
|
public static class EcsConsts
|
||||||
{
|
{
|
||||||
@ -23,6 +25,8 @@
|
|||||||
|
|
||||||
public const int MAGIC_PRIME = 314159;
|
public const int MAGIC_PRIME = 314159;
|
||||||
|
|
||||||
|
public const int NULL_ENTITY_ID = 0;
|
||||||
|
public const short NULL_WORLD_ID = 0;
|
||||||
/// meta subgroups
|
/// meta subgroups
|
||||||
|
|
||||||
public const string PACK_GROUP = "_" + FRAMEWORK_NAME + "/_Core";
|
public const string PACK_GROUP = "_" + FRAMEWORK_NAME + "/_Core";
|
||||||
@ -41,30 +45,34 @@
|
|||||||
public const string MODULES_GROUP = "Modules";
|
public const string MODULES_GROUP = "Modules";
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO заменить ENABLE_DRAGONECS_ASSERT_CHEKS на DEV_MODE и добавить еще PERF_MODE и STAB_MODE
|
|
||||||
public static class EcsDefines
|
public static class EcsDefines
|
||||||
{
|
{
|
||||||
public const bool DISABLE_POOLS_EVENTS =
|
public const bool DRAGONECS_ENABLE_DEBUG_SERVICE =
|
||||||
#if DISABLE_POOLS_EVENTS
|
#if DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
true;
|
|
||||||
#else
|
|
||||||
false;
|
|
||||||
#endif
|
|
||||||
public const bool ENABLE_DRAGONECS_DEBUGGER =
|
|
||||||
#if ENABLE_DRAGONECS_DEBUGGER
|
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
public const bool ENABLE_DRAGONECS_ASSERT_CHEKS =
|
public const bool DRAGONECS_DISABLE_POOLS_EVENTS =
|
||||||
#if ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
|
public const bool DRAGONECS_DISABLE_CATH_EXCEPTIONS =
|
||||||
public const bool REFLECTION_DISABLED =
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
#if REFLECTION_DISABLED
|
true;
|
||||||
|
#else
|
||||||
|
false;
|
||||||
|
#endif
|
||||||
|
public const bool DRAGONECS_STABILITY_MODE =
|
||||||
|
#if DRAGONECS_STABILITY_MODE
|
||||||
|
true;
|
||||||
|
#else
|
||||||
|
false;
|
||||||
|
#endif
|
||||||
|
public const bool DRAGONECS_DEEP_DEBUG =
|
||||||
|
#if DRAGONECS_DEEP_DEBUG
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
@ -75,35 +83,46 @@
|
|||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
|
public const bool REFLECTION_DISABLED =
|
||||||
public const bool ENABLE_DUMMY_SPAN =
|
#if REFLECTION_DISABLED
|
||||||
#if ENABLE_DUMMY_SPAN
|
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Obsolete("DRAGONECS_ENABLE_DEBUG_SERVICE")]
|
||||||
|
public const bool ENABLE_DRAGONECS_DEBUGGER =
|
||||||
|
#if ENABLE_DRAGONECS_DEBUGGER
|
||||||
|
true;
|
||||||
|
#else
|
||||||
|
false;
|
||||||
|
#endif
|
||||||
|
[Obsolete("DRAGONECS_DISABLE_POOLS_EVENTS")]
|
||||||
|
public const bool DISABLE_POOLS_EVENTS =
|
||||||
|
#if DISABLE_POOLS_EVENTS
|
||||||
|
true;
|
||||||
|
#else
|
||||||
|
false;
|
||||||
|
#endif
|
||||||
|
[Obsolete("DRAGONECS_DISABLE_CATH_EXCEPTIONS")]
|
||||||
public const bool DISABLE_CATH_EXCEPTIONS =
|
public const bool DISABLE_CATH_EXCEPTIONS =
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DISABLE_CATH_EXCEPTIONS
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
|
[Obsolete("DRAGONECS_STABILITY_MODE")]
|
||||||
|
public const bool ENABLE_DRAGONECS_ASSERT_CHEKS =
|
||||||
public const bool DRAGONECS_PERF_MODE =
|
#if ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
#if DRAGONECS_PERF_MODE
|
true;
|
||||||
true;
|
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
public const bool DRAGONECS_STAB_MODE =
|
[Obsolete]
|
||||||
#if DRAGONECS_STAB_MODE
|
public const bool ENABLE_DUMMY_SPAN =
|
||||||
true;
|
#if ENABLE_DUMMY_SPAN
|
||||||
#else
|
|
||||||
false;
|
|
||||||
#endif
|
|
||||||
public const bool DRAGONECS_DEEP_DEBUG =
|
|
||||||
#if DRAGONECS_DEEP_DEBUG
|
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
|
@ -13,39 +13,39 @@ namespace DCFApixels.DragonECS
|
|||||||
using static EcsConsts;
|
using static EcsConsts;
|
||||||
public readonly struct EcsProfilerMarker
|
public readonly struct EcsProfilerMarker
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
public readonly int id;
|
public readonly int id;
|
||||||
#endif
|
#endif
|
||||||
internal EcsProfilerMarker(int id)
|
internal EcsProfilerMarker(int id)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
this.id = id;
|
this.id = id;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
public EcsProfilerMarker(string name)
|
public EcsProfilerMarker(string name)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
id = DebugService.CurrentThreadInstance.RegisterMark(name);
|
id = DebugService.CurrentThreadInstance.RegisterMark(name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Begin()
|
public void Begin()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
|
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void End()
|
public void End()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
DebugService.CurrentThreadInstance.ProfilerMarkEnd(id);
|
DebugService.CurrentThreadInstance.ProfilerMarkEnd(id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public AutoScope Auto()
|
public AutoScope Auto()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
return new AutoScope(id);
|
return new AutoScope(id);
|
||||||
#else
|
#else
|
||||||
return default;
|
return default;
|
||||||
@ -53,13 +53,13 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public readonly ref struct AutoScope
|
public readonly ref struct AutoScope
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
private readonly int _id;
|
private readonly int _id;
|
||||||
#endif
|
#endif
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public AutoScope(int id)
|
public AutoScope(int id)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
_id = id;
|
_id = id;
|
||||||
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
|
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
|
||||||
#endif
|
#endif
|
||||||
@ -67,7 +67,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
DebugService.CurrentThreadInstance.ProfilerMarkEnd(_id);
|
DebugService.CurrentThreadInstance.ProfilerMarkEnd(_id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void PrintWarning(object v)
|
public static void PrintWarning(object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
OnPrint(DEBUG_WARNING_TAG, v);
|
OnPrint(DEBUG_WARNING_TAG, v);
|
||||||
DebugService.CurrentThreadInstance.PrintWarning(v);
|
DebugService.CurrentThreadInstance.PrintWarning(v);
|
||||||
#endif
|
#endif
|
||||||
@ -102,7 +102,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void PrintError(object v)
|
public static void PrintError(object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
OnPrint(DEBUG_ERROR_TAG, v);
|
OnPrint(DEBUG_ERROR_TAG, v);
|
||||||
DebugService.CurrentThreadInstance.PrintError(v);
|
DebugService.CurrentThreadInstance.PrintError(v);
|
||||||
#endif
|
#endif
|
||||||
@ -110,7 +110,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void PrintErrorAndBreak(object v)
|
public static void PrintErrorAndBreak(object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
OnPrint(DEBUG_ERROR_TAG, v);
|
OnPrint(DEBUG_ERROR_TAG, v);
|
||||||
DebugService.CurrentThreadInstance.PrintErrorAndBreak(v);
|
DebugService.CurrentThreadInstance.PrintErrorAndBreak(v);
|
||||||
#endif
|
#endif
|
||||||
@ -118,7 +118,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void PrintPass(object v)
|
public static void PrintPass(object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
OnPrint(DEBUG_PASS_TAG, v);
|
OnPrint(DEBUG_PASS_TAG, v);
|
||||||
DebugService.CurrentThreadInstance.PrintPass(v);
|
DebugService.CurrentThreadInstance.PrintPass(v);
|
||||||
#endif
|
#endif
|
||||||
@ -126,7 +126,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Print()
|
public static void Print()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
OnPrint(string.Empty, null);
|
OnPrint(string.Empty, null);
|
||||||
DebugService.CurrentThreadInstance.Print();
|
DebugService.CurrentThreadInstance.Print();
|
||||||
#endif
|
#endif
|
||||||
@ -134,7 +134,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Print(object v)
|
public static void Print(object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
OnPrint(string.Empty, v);
|
OnPrint(string.Empty, v);
|
||||||
DebugService.CurrentThreadInstance.Print(v);
|
DebugService.CurrentThreadInstance.Print(v);
|
||||||
#endif
|
#endif
|
||||||
@ -142,7 +142,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Print(string tag, object v)
|
public static void Print(string tag, object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
OnPrint(tag, v);
|
OnPrint(tag, v);
|
||||||
DebugService.CurrentThreadInstance.Print(tag, v);
|
DebugService.CurrentThreadInstance.Print(tag, v);
|
||||||
#endif
|
#endif
|
||||||
@ -150,7 +150,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Break()
|
public static void Break()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
|
||||||
DebugService.CurrentThreadInstance.Break();
|
DebugService.CurrentThreadInstance.Break();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -301,12 +301,12 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Build
|
#region Build
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
private static EcsProfilerMarker _buildMarker = new EcsProfilerMarker("EcsPipeline.Build");
|
private static EcsProfilerMarker _buildMarker = new EcsProfilerMarker("EcsPipeline.Build");
|
||||||
#endif
|
#endif
|
||||||
public EcsPipeline Build()
|
public EcsPipeline Build()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
_buildMarker.Begin();
|
_buildMarker.Begin();
|
||||||
#endif
|
#endif
|
||||||
var it = new LinkedListIterator<SystemNode>(_systemNodes, _systemNodesCount, _startIndex);
|
var it = new LinkedListIterator<SystemNode>(_systemNodes, _systemNodesCount, _startIndex);
|
||||||
@ -372,7 +372,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
item.Declare(pipeline);
|
item.Declare(pipeline);
|
||||||
}
|
}
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
_buildMarker.End();
|
_buildMarker.End();
|
||||||
#endif
|
#endif
|
||||||
return pipeline;
|
return pipeline;
|
||||||
|
@ -45,7 +45,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private bool _isInit = false;
|
private bool _isInit = false;
|
||||||
private bool _isDestoryed = false;
|
private bool _isDestoryed = false;
|
||||||
|
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
private static EcsProfilerMarker _initMarker = new EcsProfilerMarker("EcsPipeline.Init");
|
private static EcsProfilerMarker _initMarker = new EcsProfilerMarker("EcsPipeline.Init");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ namespace DCFApixels.DragonECS
|
|||||||
EcsDebug.PrintWarning($"This {nameof(EcsPipeline)} has already been initialized");
|
EcsDebug.PrintWarning($"This {nameof(EcsPipeline)} has already been initialized");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
_initMarker.Begin();
|
_initMarker.Begin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ namespace DCFApixels.DragonECS
|
|||||||
_isInit = true;
|
_isInit = true;
|
||||||
|
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
_initMarker.End();
|
_initMarker.End();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Run)); }
|
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Run)); }
|
||||||
if (_isDestoryed) { Throw.Pipeline_MethodCalledAfterDestruction(nameof(Run)); }
|
if (_isDestoryed) { Throw.Pipeline_MethodCalledAfterDestruction(nameof(Run)); }
|
||||||
#endif
|
#endif
|
||||||
@ -215,7 +215,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void Destroy()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Destroy)); }
|
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Destroy)); }
|
||||||
#endif
|
#endif
|
||||||
if (_isDestoryed)
|
if (_isDestoryed)
|
||||||
|
@ -7,7 +7,6 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using static DCFApixels.DragonECS.EcsDebugUtility;
|
using static DCFApixels.DragonECS.EcsDebugUtility;
|
||||||
#pragma warning disable CS0162 // Обнаружен недостижимый код
|
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
@ -132,6 +131,7 @@ namespace DCFApixels.DragonECS
|
|||||||
protected virtual void OnSetup() { }
|
protected virtual void OnSetup() { }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region RunHelper
|
#region RunHelper
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
public
|
public
|
||||||
@ -210,7 +210,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -226,10 +226,11 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw e;
|
||||||
#endif
|
#else
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -249,7 +250,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -265,10 +266,11 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw e;
|
||||||
#endif
|
#else
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -375,7 +377,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -398,10 +400,11 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw e;
|
||||||
#endif
|
#else
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -429,7 +432,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -452,10 +455,11 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw e;
|
||||||
#endif
|
#else
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -342,15 +342,19 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Inc/Exc/Combine/Except
|
#region Inc/Exc/Combine/Except
|
||||||
public void Inc(EcsTypeCode typeCode)
|
public void Inc(EcsTypeCode typeCode)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(typeCode); }
|
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(typeCode); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { return; }
|
||||||
#endif
|
#endif
|
||||||
_inc.Add(typeCode);
|
_inc.Add(typeCode);
|
||||||
}
|
}
|
||||||
public void Exc(EcsTypeCode typeCode)
|
public void Exc(EcsTypeCode typeCode)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(typeCode); }
|
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(typeCode); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { return; }
|
||||||
#endif
|
#endif
|
||||||
_exc.Add(typeCode);
|
_exc.Add(typeCode);
|
||||||
}
|
}
|
||||||
|
@ -327,8 +327,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int NewEntity(int entityID)
|
public int NewEntity(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (entityID < _entities.Length && IsUsed(entityID)) { Throw.World_EntityIsAlreadyСontained(entityID); }
|
if (IsUsed(entityID)) { Throw.World_EntityIsAlreadyСontained(entityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsUsed(entityID)) { return 0; }
|
||||||
#endif
|
#endif
|
||||||
_entityDispenser.Use(entityID);
|
_entityDispenser.Use(entityID);
|
||||||
CreateConcreteEntity(entityID);
|
CreateConcreteEntity(entityID);
|
||||||
@ -377,8 +379,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void DelEntity(int entityID)
|
public void DelEntity(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (IsUsed(entityID) == false) { Throw.World_EntityIsNotContained(entityID); }
|
if (IsUsed(entityID) == false) { Throw.World_EntityIsAlreadyСontained(entityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsUsed(entityID) == false) { return; }
|
||||||
#endif
|
#endif
|
||||||
UpVersion();
|
UpVersion();
|
||||||
_delEntBuffer[_delEntBufferCount++] = entityID;
|
_delEntBuffer[_delEntBufferCount++] = entityID;
|
||||||
@ -407,8 +411,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void InitEntitySlot(int entityID, short gen)
|
public void InitEntitySlot(int entityID, short gen)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
|
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (Count > 0) { return; }
|
||||||
#endif
|
#endif
|
||||||
_entityDispenser.Upsize(entityID);
|
_entityDispenser.Upsize(entityID);
|
||||||
_entities[entityID].gen = gen;
|
_entities[entityID].gen = gen;
|
||||||
@ -427,8 +433,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool IsAlive(entlong entity)
|
public bool IsAlive(entlong entity)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (entity.GetWorldIDUnchecked() != ID) { Throw.World_MaskDoesntBelongWorld(); }
|
if (entity.GetWorldIDUnchecked() != ID) { Throw.World_MaskDoesntBelongWorld(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (entity.GetWorldIDUnchecked() != ID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
ref var slot = ref _entities[entity.GetIDUnchecked()];
|
ref var slot = ref _entities[entity.GetIDUnchecked()];
|
||||||
return slot.gen == entity.GetIDUnchecked() && slot.isUsed;
|
return slot.gen == entity.GetIDUnchecked() && slot.isUsed;
|
||||||
@ -464,8 +472,10 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public bool IsMatchesMask(EcsMask mask, int entityID)
|
public bool IsMatchesMask(EcsMask mask, int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (mask.WorldID != ID) { Throw.World_MaskDoesntBelongWorld(); }
|
if (mask.WorldID != ID) { Throw.World_MaskDoesntBelongWorld(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (mask.WorldID != ID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0, iMax = mask._incs.Length; i < iMax; i++)
|
for (int i = 0, iMax = mask._incs.Length; i < iMax; i++)
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ namespace DCFApixels.DragonECS
|
|||||||
internal PoolSlot[] _poolSlots;
|
internal PoolSlot[] _poolSlots;
|
||||||
private int _poolsCount;
|
private int _poolsCount;
|
||||||
|
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
private int _lockedPoolCount = 0;
|
private int _lockedPoolCount = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -152,8 +152,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region FindOrAutoCreatePool/InitPool
|
#region FindOrAutoCreatePool/InitPool
|
||||||
public void InitPool(IEcsPoolImplementation poolImplementation)
|
public void InitPool(IEcsPoolImplementation poolImplementation)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
|
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (Count > 0) { return; }
|
||||||
#endif
|
#endif
|
||||||
InitPool_Internal(poolImplementation);
|
InitPool_Internal(poolImplementation);
|
||||||
}
|
}
|
||||||
@ -165,7 +167,7 @@ namespace DCFApixels.DragonECS
|
|||||||
if (_poolTypeCode_2_CmpTypeIDs.TryGetValue(poolTypeCode, out int cmpTypeID))
|
if (_poolTypeCode_2_CmpTypeIDs.TryGetValue(poolTypeCode, out int cmpTypeID))
|
||||||
{
|
{
|
||||||
var pool = _pools[cmpTypeID];
|
var pool = _pools[cmpTypeID];
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
if ((pool is TPool) == false) { Throw.UndefinedException(); }
|
if ((pool is TPool) == false) { Throw.UndefinedException(); }
|
||||||
#endif
|
#endif
|
||||||
return (TPool)pool;
|
return (TPool)pool;
|
||||||
@ -282,12 +284,8 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
DelEntity(entityID);
|
DelEntity(entityID);
|
||||||
}
|
}
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
CheckUnregisterValid(count, entityID);
|
||||||
if (count < 0) Throw.World_InvalidIncrementComponentsBalance();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private bool TryRegisterEntityComponent(int entityID, int componentTypeID, EcsMaskChunck maskBit)
|
private bool TryRegisterEntityComponent(int entityID, int componentTypeID, EcsMaskChunck maskBit)
|
||||||
{
|
{
|
||||||
@ -323,13 +321,29 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
DelEntity(entityID);
|
DelEntity(entityID);
|
||||||
}
|
}
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
CheckUnregisterValid(count, entityID);
|
||||||
if (count < 0) Throw.World_InvalidIncrementComponentsBalance();
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
private void CheckUnregisterValid(int count, int entityID)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
if (count < 0) { Throw.World_InvalidIncrementComponentsBalance(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (count < 0)
|
||||||
|
{
|
||||||
|
for (int i = entityID << _entityComponentMaskLengthBitShift, iMax = i + _entityComponentMaskLength; i < iMax; i++)
|
||||||
|
{
|
||||||
|
_entityComponentMasks[i] = 0;
|
||||||
|
}
|
||||||
|
//TODO добавить очистку пулов
|
||||||
|
_entities[entityID].componentsCount = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private int GetPoolComponentCount(int componentTypeID)
|
private int GetPoolComponentCount(int componentTypeID)
|
||||||
@ -402,7 +416,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#region LockPool/UnLockPool
|
#region LockPool/UnLockPool
|
||||||
public void LockPool_Debug(int componentTypeID)
|
public void LockPool_Debug(int componentTypeID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
ref var slot = ref _poolSlots[componentTypeID];
|
ref var slot = ref _poolSlots[componentTypeID];
|
||||||
if (slot.lockedCounter == 0)
|
if (slot.lockedCounter == 0)
|
||||||
{
|
{
|
||||||
@ -416,7 +430,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void UnlockPool_Debug(int componentTypeID)
|
public void UnlockPool_Debug(int componentTypeID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
ref var slot = ref _poolSlots[componentTypeID];
|
ref var slot = ref _poolSlots[componentTypeID];
|
||||||
slot.lockedCounter--;
|
slot.lockedCounter--;
|
||||||
if (slot.lockedCounter <= 0)
|
if (slot.lockedCounter <= 0)
|
||||||
@ -434,7 +448,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public bool CheckPoolLocked_Debug(int componentTypeID)
|
public bool CheckPoolLocked_Debug(int componentTypeID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
return _poolSlots[componentTypeID].lockedCounter != 0;
|
return _poolSlots[componentTypeID].lockedCounter != 0;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
@ -447,7 +461,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
public long version;
|
public long version;
|
||||||
public int count;
|
public int count;
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
public int lockedCounter;
|
public int lockedCounter;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,15 @@ namespace DCFApixels.DragonECS
|
|||||||
{// ts
|
{// ts
|
||||||
return _worlds[worldID];
|
return _worlds[worldID];
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static bool TryGetWorld(short worldID, out EcsWorld world)
|
||||||
|
{// ts
|
||||||
|
world = _worlds[worldID];
|
||||||
|
return
|
||||||
|
world != null &&
|
||||||
|
world.IsDestroyed != false &&
|
||||||
|
worldID != 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void ReleaseData(short worldID)
|
private void ReleaseData(short worldID)
|
||||||
{// ts
|
{// ts
|
||||||
@ -146,7 +155,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static ref T GetForWorldUnchecked(short worldID)
|
public static ref T GetForWorldUnchecked(short worldID)
|
||||||
{// ts
|
{// ts
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_mapping[worldID] <= 0) { Throw.ArgumentOutOfRange(); }
|
if (_mapping[worldID] <= 0) { Throw.ArgumentOutOfRange(); }
|
||||||
#endif
|
#endif
|
||||||
return ref _items[_mapping[worldID]];
|
return ref _items[_mapping[worldID]];
|
||||||
|
@ -74,7 +74,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ExecuteFor_Iternal(EcsSpan span)
|
private void ExecuteFor_Iternal(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
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
|
||||||
|
@ -73,7 +73,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ExecuteFor_Iternal(EcsSpan span)
|
private void ExecuteFor_Iternal(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
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
|
||||||
|
@ -16,7 +16,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private Dictionary<Type, InjectionNodeBase> _nodes = new Dictionary<Type, InjectionNodeBase>(32);
|
private Dictionary<Type, InjectionNodeBase> _nodes = new Dictionary<Type, InjectionNodeBase>(32);
|
||||||
private bool _isInit = false;
|
private bool _isInit = false;
|
||||||
|
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
private HashSet<Type> _requiredInjectionTypes = new HashSet<Type>();
|
private HashSet<Type> _requiredInjectionTypes = new HashSet<Type>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ namespace DCFApixels.DragonECS
|
|||||||
branch = new InjectionBranch(this, objType);
|
branch = new InjectionBranch(this, objType);
|
||||||
InitBranch(branch);
|
InitBranch(branch);
|
||||||
|
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
foreach (var requiredInjectionType in _requiredInjectionTypes)
|
foreach (var requiredInjectionType in _requiredInjectionTypes)
|
||||||
{
|
{
|
||||||
if (requiredInjectionType.IsAssignableFrom(objType))
|
if (requiredInjectionType.IsAssignableFrom(objType))
|
||||||
@ -144,7 +144,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
_isInit = true;
|
_isInit = true;
|
||||||
|
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
var systems = _pipeline.AllSystems;
|
var systems = _pipeline.AllSystems;
|
||||||
var injectType = typeof(IEcsInject<>);
|
var injectType = typeof(IEcsInject<>);
|
||||||
foreach (var system in systems)
|
foreach (var system in systems)
|
||||||
|
@ -40,8 +40,8 @@ namespace DCFApixels.DragonECS
|
|||||||
private int _componentTypeID;
|
private int _componentTypeID;
|
||||||
private EcsMaskChunck _maskBit;
|
private EcsMaskChunck _maskBit;
|
||||||
|
|
||||||
private int[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID
|
private int[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID.
|
||||||
private T[] _items; //dense
|
private T[] _items; // dense; _items[0] - fake component.
|
||||||
private int _itemsCount = 0;
|
private int _itemsCount = 0;
|
||||||
private int _capacity = 0;
|
private int _capacity = 0;
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private readonly IEcsComponentCopy<T> _componentCopyHandler = EcsComponentCopyHandler<T>.instance;
|
private readonly IEcsComponentCopy<T> _componentCopyHandler = EcsComponentCopyHandler<T>.instance;
|
||||||
private readonly bool _isHasComponentCopyHandler = EcsComponentCopyHandler<T>.isHasHandler;
|
private readonly bool _isHasComponentCopyHandler = EcsComponentCopyHandler<T>.isHasHandler;
|
||||||
|
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
private StructList<IEcsPoolEventListener> _listeners = new StructList<IEcsPoolEventListener>(2);
|
private StructList<IEcsPoolEventListener> _listeners = new StructList<IEcsPoolEventListener>(2);
|
||||||
private int _listenersCachedCount = 0;
|
private int _listenersCachedCount = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -100,16 +100,19 @@ namespace DCFApixels.DragonECS
|
|||||||
public ref T Add(int entityID)
|
public ref T Add(int entityID)
|
||||||
{
|
{
|
||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (itemIndex > 0) { return ref Get(entityID); }
|
||||||
|
if (_isLocked) { return ref _items[0]; }
|
||||||
#endif
|
#endif
|
||||||
itemIndex = GetFreeItemIndex(entityID);
|
itemIndex = GetFreeItemIndex(entityID);
|
||||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
ref T result = ref _items[itemIndex];
|
ref T result = ref _items[itemIndex];
|
||||||
_sparseEntities[itemIndex] = entityID;
|
_sparseEntities[itemIndex] = entityID;
|
||||||
EnableComponent(ref result);
|
EnableComponent(ref result);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnAddAndGet(entityID, _listenersCachedCount);
|
_listeners.InvokeOnAddAndGet(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -125,10 +128,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref T Get(int entityID)
|
public ref T Get(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG // <20><> <20><><EFBFBD><EFBFBD><EFBFBD> STAB_MODE
|
||||||
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnGet(entityID, _listenersCachedCount);
|
_listeners.InvokeOnGet(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
return ref _items[_mapping[entityID]];
|
return ref _items[_mapping[entityID]];
|
||||||
@ -136,7 +139,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref readonly T Read(int entityID)
|
public ref readonly T Read(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG // <20><> <20><><EFBFBD><EFBFBD><EFBFBD> STAB_MODE
|
||||||
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
return ref _items[_mapping[entityID]];
|
return ref _items[_mapping[entityID]];
|
||||||
@ -153,22 +156,23 @@ namespace DCFApixels.DragonECS
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
|
||||||
#endif
|
|
||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
if (itemIndex <= 0)
|
if (itemIndex <= 0)
|
||||||
{ //Add block
|
{ //Add block
|
||||||
|
#if DEBUG
|
||||||
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_isLocked) { return ref _items[0]; }
|
||||||
|
#endif
|
||||||
itemIndex = GetFreeItemIndex(entityID);
|
itemIndex = GetFreeItemIndex(entityID);
|
||||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
_sparseEntities[itemIndex] = entityID;
|
_sparseEntities[itemIndex] = entityID;
|
||||||
EnableComponent(ref _items[itemIndex]);
|
EnableComponent(ref _items[itemIndex]);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnAdd(entityID, _listenersCachedCount);
|
_listeners.InvokeOnAdd(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
} //Add block end
|
} //Add block end
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnGet(entityID, _listenersCachedCount);
|
_listeners.InvokeOnGet(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -188,12 +192,13 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void Del(int entityID)
|
public void Del(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
|
||||||
#endif
|
|
||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (itemIndex <= 0) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (itemIndex <= 0) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (itemIndex <= 0) { return; }
|
||||||
|
if (_isLocked) { return; }
|
||||||
#endif
|
#endif
|
||||||
DisableComponent(ref _items[itemIndex]);
|
DisableComponent(ref _items[itemIndex]);
|
||||||
_sparseEntities[itemIndex] = 0;
|
_sparseEntities[itemIndex] = 0;
|
||||||
@ -221,23 +226,29 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void Copy(int fromEntityID, int toEntityID)
|
public void Copy(int fromEntityID, int toEntityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (!Has(fromEntityID)) { return; }
|
||||||
#endif
|
#endif
|
||||||
CopyComponent(ref Get(fromEntityID), ref TryAddOrGet(toEntityID));
|
CopyComponent(ref Get(fromEntityID), ref TryAddOrGet(toEntityID));
|
||||||
}
|
}
|
||||||
public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
|
public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (!Has(fromEntityID)) { return; }
|
||||||
#endif
|
#endif
|
||||||
CopyComponent(ref Get(fromEntityID), ref toWorld.GetPool<T>().TryAddOrGet(toEntityID));
|
CopyComponent(ref Get(fromEntityID), ref toWorld.GetPool<T>().TryAddOrGet(toEntityID));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearAll()
|
public void ClearAll()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_isLocked) { return; }
|
||||||
#endif
|
#endif
|
||||||
if (_itemsCount <= 0) { return; }
|
if (_itemsCount <= 0) { return; }
|
||||||
_itemsCount = 0;
|
_itemsCount = 0;
|
||||||
@ -248,7 +259,7 @@ namespace DCFApixels.DragonECS
|
|||||||
DisableComponent(ref _items[itemIndex]);
|
DisableComponent(ref _items[itemIndex]);
|
||||||
itemIndex = 0;
|
itemIndex = 0;
|
||||||
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -441,7 +452,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Listeners
|
#region Listeners
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
public void AddListener(IEcsPoolEventListener listener)
|
public void AddListener(IEcsPoolEventListener listener)
|
||||||
{
|
{
|
||||||
if (listener == null) { EcsPoolThrowHelper.ThrowNullListener(); }
|
if (listener == null) { EcsPoolThrowHelper.ThrowNullListener(); }
|
||||||
|
@ -164,7 +164,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Listeners
|
#region Listeners
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
void IEcsReadonlyPool.AddListener(IEcsPoolEventListener listener) { }
|
void IEcsReadonlyPool.AddListener(IEcsPoolEventListener listener) { }
|
||||||
void IEcsReadonlyPool.RemoveListener(IEcsPoolEventListener listener) { }
|
void IEcsReadonlyPool.RemoveListener(IEcsPoolEventListener listener) { }
|
||||||
#endif
|
#endif
|
||||||
@ -193,7 +193,7 @@ namespace DCFApixels.DragonECS
|
|||||||
void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID);
|
void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
#region Add/Remove Listeners
|
#region Add/Remove Listeners
|
||||||
void AddListener(IEcsPoolEventListener listener);
|
void AddListener(IEcsPoolEventListener listener);
|
||||||
void RemoveListener(IEcsPoolEventListener listener);
|
void RemoveListener(IEcsPoolEventListener listener);
|
||||||
@ -249,6 +249,18 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
return self == null || self == EcsNullPool.instance;
|
return self == null || self == EcsNullPool.instance;
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static ref T NewEntity<T>(this IEcsStructPool<T> self) where T : struct
|
||||||
|
{
|
||||||
|
var e = self.World.NewEntity();
|
||||||
|
return ref self.Add(e);
|
||||||
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static ref T NewEntity<T>(this IEcsStructPool<T> self, out int entityID) where T : struct
|
||||||
|
{
|
||||||
|
entityID = self.World.NewEntity();
|
||||||
|
return ref self.Add(entityID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -262,7 +274,7 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>Called after deleting an entity from the pool</summary>
|
/// <summary>Called after deleting an entity from the pool</summary>
|
||||||
void OnDel(int entityID);
|
void OnDel(int entityID);
|
||||||
}
|
}
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
public static class PoolEventListExtensions
|
public static class PoolEventListExtensions
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
#endif
|
#endif
|
||||||
using DCFApixels.DragonECS.Core;
|
using DCFApixels.DragonECS.Core;
|
||||||
|
using DCFApixels.DragonECS.Internal;
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
using DCFApixels.DragonECS.PoolsCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using DCFApixels.DragonECS.Internal;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
#if ENABLE_IL2CPP
|
#if ENABLE_IL2CPP
|
||||||
using Unity.IL2CPP.CompilerServices;
|
using Unity.IL2CPP.CompilerServices;
|
||||||
#endif
|
#endif
|
||||||
@ -42,7 +42,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private bool[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID
|
private bool[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID
|
||||||
private int _count = 0;
|
private int _count = 0;
|
||||||
|
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
private StructList<IEcsPoolEventListener> _listeners = new StructList<IEcsPoolEventListener>(2);
|
private StructList<IEcsPoolEventListener> _listeners = new StructList<IEcsPoolEventListener>(2);
|
||||||
private int _listenersCachedCount = 0;
|
private int _listenersCachedCount = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -103,14 +103,16 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Method
|
#region Method
|
||||||
public void Add(int entityID)
|
public void Add(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID)) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
if (Has(entityID)) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (Has(entityID) || _isLocked) { return; }
|
||||||
#endif
|
#endif
|
||||||
_count++;
|
_count++;
|
||||||
_mapping[entityID] = true;
|
_mapping[entityID] = true;
|
||||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnAdd(entityID, _listenersCachedCount);
|
_listeners.InvokeOnAdd(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -128,14 +130,16 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void Del(int entityID)
|
public void Del(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (!Has(entityID) || _isLocked) { return; }
|
||||||
#endif
|
#endif
|
||||||
_mapping[entityID] = false;
|
_mapping[entityID] = false;
|
||||||
_count--;
|
_count--;
|
||||||
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -149,15 +153,19 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void Copy(int fromEntityID, int toEntityID)
|
public void Copy(int fromEntityID, int toEntityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (!Has(fromEntityID)) { return; }
|
||||||
#endif
|
#endif
|
||||||
TryAdd(toEntityID);
|
TryAdd(toEntityID);
|
||||||
}
|
}
|
||||||
public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
|
public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (!Has(fromEntityID)) { return; }
|
||||||
#endif
|
#endif
|
||||||
toWorld.GetPool<T>().TryAdd(toEntityID);
|
toWorld.GetPool<T>().TryAdd(toEntityID);
|
||||||
}
|
}
|
||||||
@ -189,8 +197,10 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public void ClearAll()
|
public void ClearAll()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_isLocked) { return; }
|
||||||
#endif
|
#endif
|
||||||
if (_count <= 0) { return; }
|
if (_count <= 0) { return; }
|
||||||
var span = _source.Where(out SingleTagAspect<T> _);
|
var span = _source.Where(out SingleTagAspect<T> _);
|
||||||
@ -199,7 +209,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
_mapping[entityID] = false;
|
_mapping[entityID] = false;
|
||||||
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -245,14 +255,14 @@ namespace DCFApixels.DragonECS
|
|||||||
void IEcsPool.AddRaw(int entityID, object dataRaw) { Add(entityID); }
|
void IEcsPool.AddRaw(int entityID, object dataRaw) { Add(entityID); }
|
||||||
object IEcsReadonlyPool.GetRaw(int entityID)
|
object IEcsReadonlyPool.GetRaw(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
return _fakeComponent;
|
return _fakeComponent;
|
||||||
}
|
}
|
||||||
void IEcsPool.SetRaw(int entityID, object dataRaw)
|
void IEcsPool.SetRaw(int entityID, object dataRaw)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -263,14 +273,14 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
ref readonly T IEcsStructPool<T>.Read(int entityID)
|
ref readonly T IEcsStructPool<T>.Read(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
return ref _fakeComponent;
|
return ref _fakeComponent;
|
||||||
}
|
}
|
||||||
ref T IEcsStructPool<T>.Get(int entityID)
|
ref T IEcsStructPool<T>.Get(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
return ref _fakeComponent;
|
return ref _fakeComponent;
|
||||||
@ -278,7 +288,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Listeners
|
#region Listeners
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
public void AddListener(IEcsPoolEventListener listener)
|
public void AddListener(IEcsPoolEventListener listener)
|
||||||
{
|
{
|
||||||
if (listener == null) { EcsPoolThrowHelper.ThrowNullListener(); }
|
if (listener == null) { EcsPoolThrowHelper.ThrowNullListener(); }
|
||||||
@ -363,14 +373,14 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
|
|
||||||
[Obsolete("Use " + nameof(EcsAspect) + "." + nameof(EcsAspect.Builder) + "." + nameof(GetPool) + "<T>()")]
|
[Obsolete("Use " + nameof(EcsWorld) + "." + nameof(GetPool) + "<T>()")]
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static EcsTagPool<TTagComponent> GetTagPool<TTagComponent>(this EcsWorld self) where TTagComponent : struct, IEcsTagComponent
|
public static EcsTagPool<TTagComponent> GetTagPool<TTagComponent>(this EcsWorld self) where TTagComponent : struct, IEcsTagComponent
|
||||||
{
|
{
|
||||||
return self.GetPoolInstance<EcsTagPool<TTagComponent>>();
|
return self.GetPoolInstance<EcsTagPool<TTagComponent>>();
|
||||||
}
|
}
|
||||||
[Obsolete("Use " + nameof(EcsAspect) + "." + nameof(EcsAspect.Builder) + "." + nameof(GetPoolUnchecked) + "<T>()")]
|
[Obsolete("Use " + nameof(EcsWorld) + "." + nameof(GetPoolUnchecked) + "<T>()")]
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static EcsTagPool<TTagComponent> GetTagPoolUnchecked<TTagComponent>(this EcsWorld self) where TTagComponent : struct, IEcsTagComponent
|
public static EcsTagPool<TTagComponent> GetTagPoolUnchecked<TTagComponent>(this EcsWorld self) where TTagComponent : struct, IEcsTagComponent
|
||||||
|
@ -59,8 +59,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false) { return EcsConsts.NULL_ENTITY_ID; }
|
||||||
#endif
|
#endif
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
@ -70,8 +72,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false) { return default; }
|
||||||
#endif
|
#endif
|
||||||
return _gen;
|
return _gen;
|
||||||
}
|
}
|
||||||
@ -81,8 +85,8 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
#endif
|
#endif
|
||||||
return GetWorld_Internal();
|
return GetWorld_Internal();
|
||||||
}
|
}
|
||||||
@ -92,8 +96,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false) { return EcsConsts.NULL_WORLD_ID; }
|
||||||
#endif
|
#endif
|
||||||
return _world;
|
return _world;
|
||||||
}
|
}
|
||||||
@ -144,8 +150,15 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Unpack(out int id, out EcsWorld world)
|
public void Unpack(out int id, out EcsWorld world)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false)
|
||||||
|
{
|
||||||
|
world = EcsWorld.GetWorld(EcsConsts.NULL_WORLD_ID);
|
||||||
|
id = EcsConsts.NULL_ENTITY_ID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
world = EcsWorld.GetWorld(_world);
|
world = EcsWorld.GetWorld(_world);
|
||||||
id = _id;
|
id = _id;
|
||||||
@ -153,8 +166,16 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Unpack(out int id, out short gen, out EcsWorld world)
|
public void Unpack(out int id, out short gen, out EcsWorld world)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false)
|
||||||
|
{
|
||||||
|
world = EcsWorld.GetWorld(EcsConsts.NULL_WORLD_ID);
|
||||||
|
gen = default;
|
||||||
|
id = EcsConsts.NULL_ENTITY_ID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
world = EcsWorld.GetWorld(_world);
|
world = EcsWorld.GetWorld(_world);
|
||||||
gen = _gen;
|
gen = _gen;
|
||||||
@ -163,8 +184,15 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Unpack(out int id, out short worldID)
|
public void Unpack(out int id, out short worldID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false)
|
||||||
|
{
|
||||||
|
worldID = EcsConsts.NULL_WORLD_ID;
|
||||||
|
id = EcsConsts.NULL_ENTITY_ID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
worldID = _world;
|
worldID = _world;
|
||||||
id = _id;
|
id = _id;
|
||||||
@ -172,8 +200,16 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Unpack(out int id, out short gen, out short worldID)
|
public void Unpack(out int id, out short gen, out short worldID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false)
|
||||||
|
{
|
||||||
|
worldID = EcsConsts.NULL_WORLD_ID;
|
||||||
|
gen = default;
|
||||||
|
id = EcsConsts.NULL_ENTITY_ID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
worldID = _world;
|
worldID = _world;
|
||||||
gen = _gen;
|
gen = _gen;
|
||||||
@ -296,7 +332,13 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
#region Other
|
#region Other
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private EcsWorld GetWorld_Internal() { return EcsWorld.GetWorld(_world); }
|
private EcsWorld GetWorld_Internal()
|
||||||
|
{
|
||||||
|
#if DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false) { EcsWorld.GetWorld(EcsConsts.NULL_WORLD_ID); }
|
||||||
|
#endif
|
||||||
|
return EcsWorld.GetWorld(_world);
|
||||||
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public override int GetHashCode() { return unchecked((int)_full) ^ (int)(_full >> 32); }
|
public override int GetHashCode() { return unchecked((int)_full) ^ (int)(_full >> 32); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
Loading…
Reference in New Issue
Block a user