Merge branch 'main' into test-pool

This commit is contained in:
DCFApixels 2025-03-16 13:10:22 +08:00
commit f809fd8c71
22 changed files with 457 additions and 240 deletions

View File

@ -881,13 +881,13 @@ using (_marker.Auto())
</br>
# Define Symbols
+ `DISABLE_POOLS_EVENTS` - выключает реактивное поведение в пулах.
+ `ENABLE_DRAGONECS_DEBUGGER` - включает работу EcsDebug в релизном билде.
+ `ENABLE_DRAGONECS_ASSERT_CHECKS` - включает опускаемые в релизном билде проверки.
+ `DRAGONECS_DISABLE_POOLS_EVENTS` - выключает реактивное поведение в пулах.
+ `DRAGONECS_ENABLE_DEBUG_SERVICE` - включает работу EcsDebug в релизном билде.
+ `DRAGONECS_STABILITY_MODE` - включает опускаемые в релизном билде проверки.
+ `DRAGONECS_DISABLE_CATH_EXCEPTIONS` - Выключает поведение по умолчанию по обработке исключений. По умолчанию фреймворк будет ловить исключения с выводом информации из исключений через EcsDebug и продолжать работу.
+ `REFLECTION_DISABLED` - Полностью ограничивает работу фреймворка с Reflection.
+ `DISABLE_DEBUG` - Для среды где не поддерживается ручное отключение DEBUG, например Unity.
+ `ENABLE_DUMMY_SPAN` - На случай если в среде не поддерживаются Span типы, включает его замену.
+ `DISABLE_CATH_EXCEPTIONS` - Выключает поведение по умолчанию по обработке исключений. По умолчанию фреймворк будет ловить исключения с выводом информации из исключений через EcsDebug и продолжать работу.
</br>

View File

@ -844,13 +844,13 @@ using (_marker.Auto())
</br>
# Define Symbols
+ `DISABLE_POOLS_EVENTS` - 禁用池子事件的响应行为。
+ `ENABLE_DRAGONECS_DEBUGGER` - 在发布版中启用 EcsDebug 的工作。
+ `ENABLE_DRAGONECS_ASSERT_CHECKS` - 在发布版中启用可忽略的检查和异常。
+ `DRAGONECS_DISABLE_POOLS_EVENTS` - 禁用池子事件的响应行为。
+ `DRAGONECS_ENABLE_DEBUG_SERVICE` - 在发布版中启用 EcsDebug 的工作。
+ `DRAGONECS_STABILITY_MODE` - 默认情况下,为了优化,框架在发布版本中跳过许多异常检查。此定义不是跳过检查,而是将其替换为能够解决错误的代码。这提高了稳定性,但降低了执行速度。
+ `DRAGONECS_DISABLE_CATH_EXCEPTIONS` - 禁用默认的异常处理行为。默认情况下,框架将捕获异常并通过 EcsDebug 输出异常信息,然后继续执行。
+ `REFLECTION_DISABLED` - 完全限制框架内部代码中的 Reflection 使用。
+ `DISABLE_DEBUG` - 用于不支持手动禁用 DEBUG 的环境,例如 Unity。
+ `ENABLE_DUMMY_SPAN` - 如果环境不支持 Span 类型,则启用它的替代。
+ `DISABLE_CATH_EXCEPTIONS` - 禁用默认的异常处理行为。默认情况下,框架将捕获异常并通过 EcsDebug 输出异常信息,然后继续执行。
</br>

View File

@ -851,13 +851,14 @@ using (_marker.Auto())
</br>
# Define Symbols
+ `DISABLE_POOLS_EVENTS` - disables reactive behavior in pools.
+ `ENABLE_DRAGONECS_DEBUGGER` - enables EcsDebug functionality in release builds.
+ `ENABLE_DRAGONECS_ASSERT_CHECKS` - enables omitted checks in the release build.
+ `DRAGONECS_DISABLE_POOLS_EVENTS` - Disables reactive behavior in pools.
+ `DRAGONECS_ENABLE_DEBUG_SERVICE` - Enables EcsDebug functionality in release builds.
+ `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.
+ `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.
+ `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>

View File

@ -8,7 +8,7 @@
"displayName": "DragonECS",
"description": "C# Entity Component System Framework",
"unity": "2020.3",
"version": "0.9.1",
"version": "0.9.4",
"repository": {
"type": "git",
"url": "https://github.com/DCFApixels/DragonECS.git"

View File

@ -149,7 +149,7 @@ namespace DCFApixels.DragonECS.Internal
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
@ -166,10 +166,11 @@ namespace DCFApixels.DragonECS.Internal
try { item.Run(); }
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
throw;
#endif
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw e;
#else
EcsDebug.PrintError(e);
#endif
}
}
#endif

View File

@ -234,8 +234,16 @@ namespace DCFApixels.DragonECS
}
internal void ReleaseGroup(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
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
group._isReleased = true;
group.Clear();
@ -307,8 +315,10 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
#elif DRAGONECS_STABILITY_MODE
if (index < 0 || index >= Count) { return EcsConsts.NULL_ENTITY_ID; }
#endif
return _dense[++index];
}
@ -316,7 +326,7 @@ namespace DCFApixels.DragonECS
// set
// {
// // TODO добавить лок енумератора на изменение
//#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
//#if DEBUG || DRAGONECS_STABILITY_MODE
// if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
//#endif
// var oldValue = _dense[index];
@ -369,8 +379,10 @@ namespace DCFApixels.DragonECS
#region Add/Remove
public void AddUnchecked(int entityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (Has(entityID)) { Throw.Group_AlreadyContains(entityID); }
#elif DRAGONECS_STABILITY_MODE
if (Has(entityID)) { return; }
#endif
Add_Internal(entityID);
}
@ -413,8 +425,10 @@ namespace DCFApixels.DragonECS
public void RemoveUnchecked(int entityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (Has(entityID) == false) { Throw.Group_DoesNotContain(entityID); }
#elif DRAGONECS_STABILITY_MODE
if (Has(entityID) == false) { return; }
#endif
Remove_Internal(entityID);
}
@ -526,13 +540,16 @@ namespace DCFApixels.DragonECS
#region CopyFrom/Clone/Slice/ToSpan/ToArray
public void CopyFrom(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (group.World != _source) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
if (_count > 0)
#elif DRAGONECS_STABILITY_MODE
if (group.World != _source)
{
Clear();
return;
}
#endif
Clear();
foreach (var entityID in group)
{
Add_Internal(entityID);
@ -578,8 +595,11 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public EcsSpan Slice(int start, int length)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
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
return new EcsSpan(WorldID, _dense, start + 1, length);
}
@ -622,8 +642,10 @@ namespace DCFApixels.DragonECS
/// <summary>as Union sets</summary>
public void UnionWith(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (_source != group._source) { return; }
#endif
foreach (var entityID in group) { UnionWithStep(entityID); }
}
@ -633,8 +655,10 @@ namespace DCFApixels.DragonECS
/// <summary>as Union sets</summary>
public void UnionWith(EcsSpan span)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (WorldID != span.WorldID) { return; }
#endif
foreach (var entityID in span) { UnionWithStep(entityID); }
}
@ -656,8 +680,10 @@ namespace DCFApixels.DragonECS
/// <summary>as Except sets</summary>
public void ExceptWith(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (_source != group._source) { return; }
#endif
if (group.Count > Count) //мини оптимизация, итеррируемся по короткому списку
{
@ -681,8 +707,10 @@ namespace DCFApixels.DragonECS
/// <summary>as Except sets</summary>
public void ExceptWith(EcsSpan span)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#if DEBUG
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (WorldID != span.WorldID) { return; }
#endif
foreach (var entityID in span) { ExceptWithStep_Internal(entityID); }
}
@ -704,8 +732,10 @@ namespace DCFApixels.DragonECS
/// <summary>as Intersect sets</summary>
public void IntersectWith(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (_source != group._source) { return; }
#endif
for (int i = _count; i > 0; i--)//итерация в обратном порядке исключает ошибки при удалении элементов
{
@ -722,8 +752,10 @@ namespace DCFApixels.DragonECS
/// <summary>as Intersect sets</summary>
public void IntersectWith(EcsSpan span)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#if DEBUG
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (WorldID != span.WorldID) { return; }
#endif
foreach (var entityID in span)
{
@ -765,8 +797,10 @@ namespace DCFApixels.DragonECS
/// <summary>as Symmetric Except sets</summary>
public void SymmetricExceptWith(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (_source != group._source) { return; }
#endif
foreach (var entityID in group) { SymmetricExceptWithStep_Internal(entityID); }
}
@ -777,8 +811,10 @@ namespace DCFApixels.DragonECS
/// <summary>as Symmetric Except sets</summary>
public void SymmetricExceptWith(EcsSpan span)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#if DEBUG
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (WorldID != span.WorldID) { return; }
#endif
foreach (var entityID in span) { SymmetricExceptWithStep_Internal(entityID); }
}
@ -827,8 +863,10 @@ namespace DCFApixels.DragonECS
#region SetEquals
public bool SetEquals(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group.World) { Throw.Group_ArgumentDifferentWorldsException(); }
#if DEBUG
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (_source != group._source) { return false; }
#endif
if (group.Count != Count) { return false; }
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(EcsSpan span)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#if DEBUG
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (WorldID != span.WorldID) { return false; }
#endif
if (span.Count != Count) { return false; }
foreach (var entityID in span)
@ -874,8 +914,10 @@ namespace DCFApixels.DragonECS
#region Overlaps
public bool Overlaps(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group.World) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (_source != group._source) { return false; }
#endif
if (group.Count > Count)
{
@ -903,8 +945,10 @@ namespace DCFApixels.DragonECS
public bool Overlaps(EcsReadonlyGroup group) { return Overlaps(group.GetSource_Internal()); }
public bool Overlaps(EcsSpan span)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (WorldID != span.WorldID) { return false; }
#endif
foreach (var entityID in span)
{
@ -931,8 +975,10 @@ namespace DCFApixels.DragonECS
#region IsSubsetOf/IsProperSubsetOf
public bool IsSubsetOf(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (_source != group._source) { return false; }
#endif
if (Count == 0) { return true; }
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(EcsSpan span)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (WorldID != span.WorldID) { return false; }
#endif
if (Count == 0) { return true; }
if (span.Count < Count) { return false; }
@ -960,8 +1008,10 @@ namespace DCFApixels.DragonECS
public bool IsProperSubsetOf(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (_source != group._source) { return false; }
#endif
if (Count == 0) { return true; }
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(EcsSpan span)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (WorldID != span.WorldID) { return false; }
#endif
if (Count == 0) { return true; }
if (span.Count <= Count) { return false; }
@ -1035,8 +1087,10 @@ namespace DCFApixels.DragonECS
#region IsSupersetOf/IsProperSupersetOf
public bool IsSupersetOf(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (_source != group._source) { return false; }
#endif
if (group.Count > Count) { return false; }
return IsSupersetOf_Internal(group);
@ -1045,8 +1099,10 @@ namespace DCFApixels.DragonECS
public bool IsSupersetOf(EcsReadonlyGroup group) { return IsSupersetOf(group.GetSource_Internal()); }
public bool IsSupersetOf(EcsSpan span)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (WorldID != span.WorldID) { return false; }
#endif
if (span.Count > Count) { return false; }
return IsSupersetOf_Internal(span);
@ -1061,8 +1117,10 @@ namespace DCFApixels.DragonECS
public bool IsProperSupersetOf(EcsGroup group)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (_source != group._source) { return false; }
#endif
if (group.Count >= Count) { return false; }
return IsSupersetOf_Internal(group);
@ -1071,8 +1129,10 @@ namespace DCFApixels.DragonECS
public bool IsProperSupersetOf(EcsReadonlyGroup group) { return IsProperSupersetOf(group.GetSource_Internal()); }
public bool IsProperSupersetOf(EcsSpan span)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#if DEBUG
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (WorldID != span.WorldID) { return false; }
#endif
if (span.Count >= Count) { return false; }
return IsSupersetOf_Internal(span);
@ -1129,8 +1189,10 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Union(EcsGroup a, EcsGroup b)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (a._source != b._source) { return a.World.GetFreeGroup(); }
#endif
EcsGroup result = a._source.GetFreeGroup();
foreach (var entityID in a)
@ -1153,8 +1215,10 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Union(EcsSpan a, EcsSpan b)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
#endif
EcsGroup result = a.World.GetFreeGroup();
foreach (var entityID in a)
@ -1174,8 +1238,10 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Except(EcsGroup a, EcsGroup b)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (a._source != b._source) { return a.World.GetFreeGroup(); }
#endif
EcsGroup result = a._source.GetFreeGroup();
foreach (var entityID in a)
@ -1191,8 +1257,10 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Except(EcsSpan a, EcsGroup b)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a.WorldID != b._source.ID) { Throw.Group_ArgumentDifferentWorldsException(); }
#if DEBUG
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
#endif
EcsGroup result = b._source.GetFreeGroup();
foreach (var entityID in a)
@ -1208,8 +1276,10 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Except(EcsSpan a, EcsSpan b)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
#endif
EcsGroup result = a.World.GetFreeGroup();
result.CopyFrom(a);
@ -1229,8 +1299,10 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Intersect(EcsGroup a, EcsGroup b)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (a._source != b._source) { return a.World.GetFreeGroup(); }
#endif
EcsGroup result = a._source.GetFreeGroup();
foreach (var entityID in a)
@ -1246,8 +1318,10 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Intersect(EcsSpan a, EcsGroup b)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a.WorldID != b._source.ID) { Throw.Group_ArgumentDifferentWorldsException(); }
#if DEBUG
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
#endif
EcsGroup result = b._source.GetFreeGroup();
foreach (var entityID in a)
@ -1270,8 +1344,10 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Intersect(EcsSpan a, EcsSpan b)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
#endif
EcsGroup result = b.World.GetFreeGroup();
result.CopyFrom(a);
@ -1291,8 +1367,10 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup SymmetricExcept(EcsGroup a, EcsGroup b)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (a._source != b._source) { return a.World.GetFreeGroup(); }
#endif
EcsGroup result = a._source.GetFreeGroup();
foreach (var entityID in a)
@ -1315,8 +1393,10 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup SymmetricExcept(EcsSpan a, EcsSpan b)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#elif DRAGONECS_STABILITY_MODE
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
#endif
EcsGroup result = a.World.GetFreeGroup();
result.CopyFrom(a);

View File

@ -1,4 +1,6 @@
namespace DCFApixels.DragonECS
using System;
namespace DCFApixels.DragonECS
{
public static class EcsConsts
{
@ -23,6 +25,8 @@
public const int MAGIC_PRIME = 314159;
public const int NULL_ENTITY_ID = 0;
public const short NULL_WORLD_ID = 0;
/// meta subgroups
public const string PACK_GROUP = "_" + FRAMEWORK_NAME + "/_Core";
@ -41,30 +45,34 @@
public const string MODULES_GROUP = "Modules";
}
//TODO заменить ENABLE_DRAGONECS_ASSERT_CHEKS на DEV_MODE и добавить еще PERF_MODE и STAB_MODE
public static class EcsDefines
{
public const bool DISABLE_POOLS_EVENTS =
#if DISABLE_POOLS_EVENTS
true;
#else
false;
#endif
public const bool ENABLE_DRAGONECS_DEBUGGER =
#if ENABLE_DRAGONECS_DEBUGGER
public const bool DRAGONECS_ENABLE_DEBUG_SERVICE =
#if DRAGONECS_ENABLE_DEBUG_SERVICE
true;
#else
false;
#endif
public const bool ENABLE_DRAGONECS_ASSERT_CHEKS =
#if ENABLE_DRAGONECS_ASSERT_CHEKS
public const bool DRAGONECS_DISABLE_POOLS_EVENTS =
#if DRAGONECS_DISABLE_POOLS_EVENTS
true;
#else
false;
#endif
public const bool REFLECTION_DISABLED =
#if REFLECTION_DISABLED
public const bool DRAGONECS_DISABLE_CATH_EXCEPTIONS =
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
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;
#else
false;
@ -75,35 +83,46 @@
#else
false;
#endif
public const bool ENABLE_DUMMY_SPAN =
#if ENABLE_DUMMY_SPAN
public const bool REFLECTION_DISABLED =
#if REFLECTION_DISABLED
true;
#else
false;
#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 =
#if DISABLE_CATH_EXCEPTIONS
true;
#else
false;
#endif
public const bool DRAGONECS_PERF_MODE =
#if DRAGONECS_PERF_MODE
true;
[Obsolete("DRAGONECS_STABILITY_MODE")]
public const bool ENABLE_DRAGONECS_ASSERT_CHEKS =
#if ENABLE_DRAGONECS_ASSERT_CHEKS
true;
#else
false;
#endif
public const bool DRAGONECS_STAB_MODE =
#if DRAGONECS_STAB_MODE
true;
#else
false;
#endif
public const bool DRAGONECS_DEEP_DEBUG =
#if DRAGONECS_DEEP_DEBUG
[Obsolete]
public const bool ENABLE_DUMMY_SPAN =
#if ENABLE_DUMMY_SPAN
true;
#else
false;

View File

@ -13,39 +13,39 @@ namespace DCFApixels.DragonECS
using static EcsConsts;
public readonly struct EcsProfilerMarker
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
public readonly int id;
#endif
internal EcsProfilerMarker(int id)
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
this.id = id;
#endif
}
public EcsProfilerMarker(string name)
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
id = DebugService.CurrentThreadInstance.RegisterMark(name);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Begin()
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void End()
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
DebugService.CurrentThreadInstance.ProfilerMarkEnd(id);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public AutoScope Auto()
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
return new AutoScope(id);
#else
return default;
@ -53,13 +53,13 @@ namespace DCFApixels.DragonECS
}
public readonly ref struct AutoScope
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
private readonly int _id;
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public AutoScope(int id)
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
_id = id;
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
#endif
@ -67,7 +67,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose()
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
DebugService.CurrentThreadInstance.ProfilerMarkEnd(_id);
#endif
}
@ -94,7 +94,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintWarning(object v)
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(DEBUG_WARNING_TAG, v);
DebugService.CurrentThreadInstance.PrintWarning(v);
#endif
@ -102,7 +102,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintError(object v)
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(DEBUG_ERROR_TAG, v);
DebugService.CurrentThreadInstance.PrintError(v);
#endif
@ -110,7 +110,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintErrorAndBreak(object v)
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(DEBUG_ERROR_TAG, v);
DebugService.CurrentThreadInstance.PrintErrorAndBreak(v);
#endif
@ -118,7 +118,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintPass(object v)
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(DEBUG_PASS_TAG, v);
DebugService.CurrentThreadInstance.PrintPass(v);
#endif
@ -126,7 +126,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Print()
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(string.Empty, null);
DebugService.CurrentThreadInstance.Print();
#endif
@ -134,7 +134,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Print(object v)
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(string.Empty, v);
DebugService.CurrentThreadInstance.Print(v);
#endif
@ -142,7 +142,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Print(string tag, object v)
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(tag, v);
DebugService.CurrentThreadInstance.Print(tag, v);
#endif
@ -150,7 +150,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Break()
{
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
DebugService.CurrentThreadInstance.Break();
#endif
}

View File

@ -301,12 +301,12 @@ namespace DCFApixels.DragonECS
#endregion
#region Build
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
private static EcsProfilerMarker _buildMarker = new EcsProfilerMarker("EcsPipeline.Build");
#endif
public EcsPipeline Build()
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
_buildMarker.Begin();
#endif
var it = new LinkedListIterator<SystemNode>(_systemNodes, _systemNodesCount, _startIndex);
@ -372,7 +372,7 @@ namespace DCFApixels.DragonECS
{
item.Declare(pipeline);
}
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
_buildMarker.End();
#endif
return pipeline;

View File

@ -45,7 +45,7 @@ namespace DCFApixels.DragonECS
private bool _isInit = false;
private bool _isDestoryed = false;
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
private static EcsProfilerMarker _initMarker = new EcsProfilerMarker("EcsPipeline.Init");
#endif
@ -188,7 +188,7 @@ namespace DCFApixels.DragonECS
EcsDebug.PrintWarning($"This {nameof(EcsPipeline)} has already been initialized");
return;
}
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
_initMarker.Begin();
#endif
@ -199,7 +199,7 @@ namespace DCFApixels.DragonECS
_isInit = true;
GC.Collect();
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
_initMarker.End();
#endif
}
@ -207,7 +207,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Run()
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || DRAGONECS_STABILITY_MODE
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Run)); }
if (_isDestoryed) { Throw.Pipeline_MethodCalledAfterDestruction(nameof(Run)); }
#endif
@ -215,7 +215,7 @@ namespace DCFApixels.DragonECS
}
public void Destroy()
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || DRAGONECS_STABILITY_MODE
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Destroy)); }
#endif
if (_isDestoryed)

View File

@ -7,7 +7,6 @@ using System;
using System.Linq;
using System.Runtime.CompilerServices;
using static DCFApixels.DragonECS.EcsDebugUtility;
#pragma warning disable CS0162 // Обнаружен недостижимый код
namespace DCFApixels.DragonECS
{
@ -132,6 +131,7 @@ namespace DCFApixels.DragonECS
protected virtual void OnSetup() { }
#endregion
#region RunHelper
#if DEBUG
public
@ -210,7 +210,7 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
@ -226,10 +226,11 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
throw;
#endif
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw e;
#else
EcsDebug.PrintError(e);
#endif
}
}
#endif
@ -249,7 +250,7 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
@ -265,10 +266,11 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
throw;
#endif
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw e;
#else
EcsDebug.PrintError(e);
#endif
}
}
#endif
@ -375,7 +377,7 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
@ -398,10 +400,11 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
throw;
#endif
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw e;
#else
EcsDebug.PrintError(e);
#endif
}
finally
{
@ -429,7 +432,7 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
@ -452,10 +455,11 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
throw;
#endif
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw e;
#else
EcsDebug.PrintError(e);
#endif
}
finally
{

View File

@ -342,15 +342,19 @@ namespace DCFApixels.DragonECS
#region Inc/Exc/Combine/Except
public void Inc(EcsTypeCode typeCode)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(typeCode); }
#elif DRAGONECS_STABILITY_MODE
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { return; }
#endif
_inc.Add(typeCode);
}
public void Exc(EcsTypeCode typeCode)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(typeCode); }
#elif DRAGONECS_STABILITY_MODE
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { return; }
#endif
_exc.Add(typeCode);
}

View File

@ -327,8 +327,10 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int NewEntity(int entityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (entityID < _entities.Length && IsUsed(entityID)) { Throw.World_EntityIsAlreadyСontained(entityID); }
#if DEBUG
if (IsUsed(entityID)) { Throw.World_EntityIsAlreadyСontained(entityID); }
#elif DRAGONECS_STABILITY_MODE
if (IsUsed(entityID)) { return 0; }
#endif
_entityDispenser.Use(entityID);
CreateConcreteEntity(entityID);
@ -377,8 +379,10 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void DelEntity(int entityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (IsUsed(entityID) == false) { Throw.World_EntityIsNotContained(entityID); }
#if DEBUG
if (IsUsed(entityID) == false) { Throw.World_EntityIsAlreadyСontained(entityID); }
#elif DRAGONECS_STABILITY_MODE
if (IsUsed(entityID) == false) { return; }
#endif
UpVersion();
_delEntBuffer[_delEntBufferCount++] = entityID;
@ -407,8 +411,10 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void InitEntitySlot(int entityID, short gen)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
#elif DRAGONECS_STABILITY_MODE
if (Count > 0) { return; }
#endif
_entityDispenser.Upsize(entityID);
_entities[entityID].gen = gen;
@ -427,8 +433,10 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool IsAlive(entlong entity)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (entity.GetWorldIDUnchecked() != ID) { Throw.World_MaskDoesntBelongWorld(); }
#elif DRAGONECS_STABILITY_MODE
if (entity.GetWorldIDUnchecked() != ID) { return false; }
#endif
ref var slot = ref _entities[entity.GetIDUnchecked()];
return slot.gen == entity.GetIDUnchecked() && slot.isUsed;
@ -464,8 +472,10 @@ namespace DCFApixels.DragonECS
}
public bool IsMatchesMask(EcsMask mask, int entityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (mask.WorldID != ID) { Throw.World_MaskDoesntBelongWorld(); }
#elif DRAGONECS_STABILITY_MODE
if (mask.WorldID != ID) { return false; }
#endif
for (int i = 0, iMax = mask._incs.Length; i < iMax; i++)
{

View File

@ -18,7 +18,7 @@ namespace DCFApixels.DragonECS
internal PoolSlot[] _poolSlots;
private int _poolsCount;
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || DRAGONECS_STABILITY_MODE
private int _lockedPoolCount = 0;
#endif
@ -152,8 +152,10 @@ namespace DCFApixels.DragonECS
#region FindOrAutoCreatePool/InitPool
public void InitPool(IEcsPoolImplementation poolImplementation)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
#elif DRAGONECS_STABILITY_MODE
if (Count > 0) { return; }
#endif
InitPool_Internal(poolImplementation);
}
@ -165,7 +167,7 @@ namespace DCFApixels.DragonECS
if (_poolTypeCode_2_CmpTypeIDs.TryGetValue(poolTypeCode, out int cmpTypeID))
{
var pool = _pools[cmpTypeID];
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || DRAGONECS_STABILITY_MODE
if ((pool is TPool) == false) { Throw.UndefinedException(); }
#endif
return (TPool)pool;
@ -282,12 +284,8 @@ namespace DCFApixels.DragonECS
{
DelEntity(entityID);
}
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (count < 0) Throw.World_InvalidIncrementComponentsBalance();
#endif
CheckUnregisterValid(count, entityID);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool TryRegisterEntityComponent(int entityID, int componentTypeID, EcsMaskChunck maskBit)
{
@ -323,13 +321,29 @@ namespace DCFApixels.DragonECS
{
DelEntity(entityID);
}
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (count < 0) Throw.World_InvalidIncrementComponentsBalance();
#endif
CheckUnregisterValid(count, entityID);
return true;
}
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)]
private int GetPoolComponentCount(int componentTypeID)
@ -402,7 +416,7 @@ namespace DCFApixels.DragonECS
#region LockPool/UnLockPool
public void LockPool_Debug(int componentTypeID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || DRAGONECS_STABILITY_MODE
ref var slot = ref _poolSlots[componentTypeID];
if (slot.lockedCounter == 0)
{
@ -416,7 +430,7 @@ namespace DCFApixels.DragonECS
}
public void UnlockPool_Debug(int componentTypeID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || DRAGONECS_STABILITY_MODE
ref var slot = ref _poolSlots[componentTypeID];
slot.lockedCounter--;
if (slot.lockedCounter <= 0)
@ -434,7 +448,7 @@ namespace DCFApixels.DragonECS
}
public bool CheckPoolLocked_Debug(int componentTypeID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || DRAGONECS_STABILITY_MODE
return _poolSlots[componentTypeID].lockedCounter != 0;
#else
return false;
@ -447,7 +461,7 @@ namespace DCFApixels.DragonECS
{
public long version;
public int count;
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || DRAGONECS_STABILITY_MODE
public int lockedCounter;
#endif
}

View File

@ -41,6 +41,15 @@ namespace DCFApixels.DragonECS
{// ts
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)
{// ts
@ -146,7 +155,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T GetForWorldUnchecked(short worldID)
{// ts
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (_mapping[worldID] <= 0) { Throw.ArgumentOutOfRange(); }
#endif
return ref _items[_mapping[worldID]];

View File

@ -74,7 +74,7 @@ namespace DCFApixels.DragonECS.Internal
[MethodImpl(MethodImplOptions.AggressiveInlining)]
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.WorldID != World.ID) { Throw.Quiery_ArgumentDifferentWorldsException(); }
#endif

View File

@ -73,7 +73,7 @@ namespace DCFApixels.DragonECS.Internal
[MethodImpl(MethodImplOptions.AggressiveInlining)]
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.WorldID != World.ID) { Throw.Quiery_ArgumentDifferentWorldsException(); }
#endif

View File

@ -16,7 +16,7 @@ namespace DCFApixels.DragonECS
private Dictionary<Type, InjectionNodeBase> _nodes = new Dictionary<Type, InjectionNodeBase>(32);
private bool _isInit = false;
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
private HashSet<Type> _requiredInjectionTypes = new HashSet<Type>();
#endif
@ -50,7 +50,7 @@ namespace DCFApixels.DragonECS
branch = new InjectionBranch(this, objType);
InitBranch(branch);
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
foreach (var requiredInjectionType in _requiredInjectionTypes)
{
if (requiredInjectionType.IsAssignableFrom(objType))
@ -144,7 +144,7 @@ namespace DCFApixels.DragonECS
}
_isInit = true;
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
var systems = _pipeline.AllSystems;
var injectType = typeof(IEcsInject<>);
foreach (var system in systems)

View File

@ -40,8 +40,8 @@ namespace DCFApixels.DragonECS
private int _componentTypeID;
private EcsMaskChunck _maskBit;
private int[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID
private T[] _items; //dense
private int[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID.
private T[] _items; // dense; _items[0] - fake component.
private int _itemsCount = 0;
private int _capacity = 0;
@ -56,7 +56,7 @@ namespace DCFApixels.DragonECS
private readonly IEcsComponentCopy<T> _componentCopyHandler = EcsComponentCopyHandler<T>.instance;
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 int _listenersCachedCount = 0;
#endif
@ -100,16 +100,19 @@ namespace DCFApixels.DragonECS
public ref T Add(int entityID)
{
ref int itemIndex = ref _mapping[entityID];
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#elif DRAGONECS_STABILITY_MODE
if (itemIndex > 0) { return ref Get(entityID); }
if (_isLocked) { return ref _items[0]; }
#endif
itemIndex = GetFreeItemIndex(entityID);
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
ref T result = ref _items[itemIndex];
_sparseEntities[itemIndex] = entityID;
EnableComponent(ref result);
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
_listeners.InvokeOnAddAndGet(entityID, _listenersCachedCount);
#endif
@ -125,10 +128,10 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
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); }
#endif
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
_listeners.InvokeOnGet(entityID, _listenersCachedCount);
#endif
return ref _items[_mapping[entityID]];
@ -136,7 +139,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
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); }
#endif
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];
if (itemIndex <= 0)
{ //Add block
#if DEBUG
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#elif DRAGONECS_STABILITY_MODE
if (_isLocked) { return ref _items[0]; }
#endif
itemIndex = GetFreeItemIndex(entityID);
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
_sparseEntities[itemIndex] = entityID;
EnableComponent(ref _items[itemIndex]);
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
_listeners.InvokeOnAdd(entityID, _listenersCachedCount);
#endif
} //Add block end
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
_listeners.InvokeOnGet(entityID, _listenersCachedCount);
#endif
@ -188,12 +192,13 @@ namespace DCFApixels.DragonECS
}
public void Del(int entityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#endif
ref int itemIndex = ref _mapping[entityID];
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (itemIndex <= 0) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#elif DRAGONECS_STABILITY_MODE
if (itemIndex <= 0) { return; }
if (_isLocked) { return; }
#endif
DisableComponent(ref _items[itemIndex]);
_sparseEntities[itemIndex] = 0;
@ -221,23 +226,29 @@ namespace DCFApixels.DragonECS
}
public void Copy(int fromEntityID, int toEntityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
#elif DRAGONECS_STABILITY_MODE
if (!Has(fromEntityID)) { return; }
#endif
CopyComponent(ref Get(fromEntityID), ref TryAddOrGet(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); }
#elif DRAGONECS_STABILITY_MODE
if (!Has(fromEntityID)) { return; }
#endif
CopyComponent(ref Get(fromEntityID), ref toWorld.GetPool<T>().TryAddOrGet(toEntityID));
}
public void ClearAll()
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#elif DRAGONECS_STABILITY_MODE
if (_isLocked) { return; }
#endif
if (_itemsCount <= 0) { return; }
_itemsCount = 0;
@ -248,7 +259,7 @@ namespace DCFApixels.DragonECS
DisableComponent(ref _items[itemIndex]);
itemIndex = 0;
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
#endif
}
@ -441,7 +452,7 @@ namespace DCFApixels.DragonECS
#endregion
#region Listeners
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
public void AddListener(IEcsPoolEventListener listener)
{
if (listener == null) { EcsPoolThrowHelper.ThrowNullListener(); }

View File

@ -164,7 +164,7 @@ namespace DCFApixels.DragonECS.Internal
#endregion
#region Listeners
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
void IEcsReadonlyPool.AddListener(IEcsPoolEventListener listener) { }
void IEcsReadonlyPool.RemoveListener(IEcsPoolEventListener listener) { }
#endif
@ -193,7 +193,7 @@ namespace DCFApixels.DragonECS
void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID);
#endregion
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
#region Add/Remove Listeners
void AddListener(IEcsPoolEventListener listener);
void RemoveListener(IEcsPoolEventListener listener);
@ -249,6 +249,18 @@ namespace DCFApixels.DragonECS
{
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
@ -262,7 +274,7 @@ namespace DCFApixels.DragonECS
/// <summary>Called after deleting an entity from the pool</summary>
void OnDel(int entityID);
}
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
public static class PoolEventListExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]

View File

@ -2,14 +2,14 @@
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Diagnostics;
using DCFApixels.DragonECS.Internal;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
#if ENABLE_IL2CPP
using Unity.IL2CPP.CompilerServices;
#endif
@ -42,7 +42,7 @@ namespace DCFApixels.DragonECS
private bool[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID
private int _count = 0;
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
private StructList<IEcsPoolEventListener> _listeners = new StructList<IEcsPoolEventListener>(2);
private int _listenersCachedCount = 0;
#endif
@ -103,14 +103,16 @@ namespace DCFApixels.DragonECS
#region Method
public void Add(int entityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (Has(entityID)) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#elif DRAGONECS_STABILITY_MODE
if (Has(entityID) || _isLocked) { return; }
#endif
_count++;
_mapping[entityID] = true;
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
_listeners.InvokeOnAdd(entityID, _listenersCachedCount);
#endif
}
@ -128,14 +130,16 @@ namespace DCFApixels.DragonECS
}
public void Del(int entityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#elif DRAGONECS_STABILITY_MODE
if (!Has(entityID) || _isLocked) { return; }
#endif
_mapping[entityID] = false;
_count--;
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
#endif
}
@ -149,15 +153,19 @@ namespace DCFApixels.DragonECS
}
public void Copy(int fromEntityID, int toEntityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
#elif DRAGONECS_STABILITY_MODE
if (!Has(fromEntityID)) { return; }
#endif
TryAdd(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); }
#elif DRAGONECS_STABILITY_MODE
if (!Has(fromEntityID)) { return; }
#endif
toWorld.GetPool<T>().TryAdd(toEntityID);
}
@ -189,8 +197,10 @@ namespace DCFApixels.DragonECS
public void ClearAll()
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#elif DRAGONECS_STABILITY_MODE
if (_isLocked) { return; }
#endif
if (_count <= 0) { return; }
var span = _source.Where(out SingleTagAspect<T> _);
@ -199,7 +209,7 @@ namespace DCFApixels.DragonECS
{
_mapping[entityID] = false;
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
#endif
}
@ -245,14 +255,14 @@ namespace DCFApixels.DragonECS
void IEcsPool.AddRaw(int entityID, object dataRaw) { Add(entityID); }
object IEcsReadonlyPool.GetRaw(int entityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
#endif
return _fakeComponent;
}
void IEcsPool.SetRaw(int entityID, object dataRaw)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
#endif
}
@ -263,14 +273,14 @@ namespace DCFApixels.DragonECS
}
ref readonly T IEcsStructPool<T>.Read(int entityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
#endif
return ref _fakeComponent;
}
ref T IEcsStructPool<T>.Get(int entityID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
#endif
return ref _fakeComponent;
@ -278,7 +288,7 @@ namespace DCFApixels.DragonECS
#endregion
#region Listeners
#if !DISABLE_POOLS_EVENTS
#if !DRAGONECS_DISABLE_POOLS_EVENTS
public void AddListener(IEcsPoolEventListener listener)
{
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)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static EcsTagPool<TTagComponent> GetTagPool<TTagComponent>(this EcsWorld self) where TTagComponent : struct, IEcsTagComponent
{
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)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static EcsTagPool<TTagComponent> GetTagPoolUnchecked<TTagComponent>(this EcsWorld self) where TTagComponent : struct, IEcsTagComponent

View File

@ -59,8 +59,10 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#if DEBUG
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
#elif DRAGONECS_STABILITY_MODE
if (IsAlive == false) { return EcsConsts.NULL_ENTITY_ID; }
#endif
return _id;
}
@ -70,8 +72,10 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#if DEBUG
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
#elif DRAGONECS_STABILITY_MODE
if (IsAlive == false) { return default; }
#endif
return _gen;
}
@ -81,8 +85,8 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#if DEBUG
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
#endif
return GetWorld_Internal();
}
@ -92,8 +96,10 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#if DEBUG
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
#elif DRAGONECS_STABILITY_MODE
if (IsAlive == false) { return EcsConsts.NULL_WORLD_ID; }
#endif
return _world;
}
@ -144,8 +150,15 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Unpack(out int id, out EcsWorld world)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#if DEBUG
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
world = EcsWorld.GetWorld(_world);
id = _id;
@ -153,8 +166,16 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Unpack(out int id, out short gen, out EcsWorld world)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#if DEBUG
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
world = EcsWorld.GetWorld(_world);
gen = _gen;
@ -163,8 +184,15 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Unpack(out int id, out short worldID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#if DEBUG
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
worldID = _world;
id = _id;
@ -172,8 +200,16 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Unpack(out int id, out short gen, out short worldID)
{
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#if DEBUG
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
worldID = _world;
gen = _gen;
@ -296,7 +332,13 @@ namespace DCFApixels.DragonECS
#region Other
[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)]
public override int GetHashCode() { return unchecked((int)_full) ^ (int)(_full >> 32); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]