From 0be714a0d76e2e927188584716ea96cf2d9ca488 Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sat, 15 Mar 2025 15:00:07 +0800
Subject: [PATCH 01/13] add DRAGONECS_STABILITY_MODE/ defines refactoring
---
src/Builtin/BaseProcesses.cs | 4 +-
src/Collections/EcsGroup.cs | 196 ++++++++++++++++-------
src/Consts.cs | 80 +++++----
src/DebugUtils/EcsDebug.cs | 34 ++--
src/EcsPipeline.Builder.cs | 6 +-
src/EcsPipeline.cs | 10 +-
src/EcsRunner.cs | 16 +-
src/EcsStaticMask.cs | 8 +-
src/EcsWorld.cs | 24 ++-
src/EcsWorld.pools.cs | 44 +++--
src/EcsWorld.static.cs | 11 +-
src/Executors/EcsWhereExecutor.cs | 2 +-
src/Executors/EcsWhereToGroupExecutor.cs | 2 +-
src/Injections/Injector.cs | 6 +-
src/Pools/EcsPool.cs | 54 ++++---
src/Pools/EcsPoolBase.cs | 6 +-
src/Pools/EcsTagPool.cs | 44 +++--
src/entlong.cs | 76 +++++++--
18 files changed, 413 insertions(+), 210 deletions(-)
diff --git a/src/Builtin/BaseProcesses.cs b/src/Builtin/BaseProcesses.cs
index f83fb09..c736ccc 100644
--- a/src/Builtin/BaseProcesses.cs
+++ b/src/Builtin/BaseProcesses.cs
@@ -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,7 +166,7 @@ namespace DCFApixels.DragonECS.Internal
try { item.Run(); }
catch (Exception e)
{
-#if DISABLE_CATH_EXCEPTIONS
+#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
diff --git a/src/Collections/EcsGroup.cs b/src/Collections/EcsGroup.cs
index aaa2829..7334897 100644
--- a/src/Collections/EcsGroup.cs
+++ b/src/Collections/EcsGroup.cs
@@ -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
/// as Union sets
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
/// as Union sets
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
/// as Except sets
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
/// as Except sets
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
/// as Intersect sets
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
/// as Intersect sets
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
/// as Symmetric Except sets
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
/// as Symmetric Except sets
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
/// new group from pool
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
/// new group from pool
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
/// new group from pool
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
/// new group from pool
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
/// new group from pool
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
/// new group from pool
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
/// new group from pool
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
/// new group from pool
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
/// new group from pool
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
/// new group from pool
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);
diff --git a/src/Consts.cs b/src/Consts.cs
index 1cf09da..2fdd0f7 100644
--- a/src/Consts.cs
+++ b/src/Consts.cs
@@ -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";
@@ -44,27 +48,32 @@
//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_DRAGONECS_DEBUGGER =
+#if DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
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 +84,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]
+ public const bool ENABLE_DRAGONECS_DEBUGGER =
+#if DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
+ true;
+#else
+ false;
+#endif
+ [Obsolete]
+ public const bool DISABLE_POOLS_EVENTS =
+#if DRAGONECS_DISABLE_POOLS_EVENTS
+ true;
+#else
+ false;
+#endif
+ [Obsolete]
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]
+ 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;
diff --git a/src/DebugUtils/EcsDebug.cs b/src/DebugUtils/EcsDebug.cs
index 2fa721f..7b70d1e 100644
--- a/src/DebugUtils/EcsDebug.cs
+++ b/src/DebugUtils/EcsDebug.cs
@@ -13,39 +13,39 @@ namespace DCFApixels.DragonECS
using static EcsConsts;
public readonly struct EcsProfilerMarker
{
-#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
public readonly int id;
#endif
internal EcsProfilerMarker(int id)
{
-#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
this.id = id;
#endif
}
public EcsProfilerMarker(string name)
{
-#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
id = DebugService.CurrentThreadInstance.RegisterMark(name);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Begin()
{
-#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void End()
{
-#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
DebugService.CurrentThreadInstance.ProfilerMarkEnd(id);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public AutoScope Auto()
{
-#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
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_DRAGONECS_DEBUGGER
private readonly int _id;
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public AutoScope(int id)
{
-#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
_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_DRAGONECS_DEBUGGER
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_DRAGONECS_DEBUGGER
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_DRAGONECS_DEBUGGER
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_DRAGONECS_DEBUGGER
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_DRAGONECS_DEBUGGER
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_DRAGONECS_DEBUGGER
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_DRAGONECS_DEBUGGER
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_DRAGONECS_DEBUGGER
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_DRAGONECS_DEBUGGER
DebugService.CurrentThreadInstance.Break();
#endif
}
diff --git a/src/EcsPipeline.Builder.cs b/src/EcsPipeline.Builder.cs
index a44a608..d66f6d3 100644
--- a/src/EcsPipeline.Builder.cs
+++ b/src/EcsPipeline.Builder.cs
@@ -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(_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;
diff --git a/src/EcsPipeline.cs b/src/EcsPipeline.cs
index 3c0d1be..6ad2331 100644
--- a/src/EcsPipeline.cs
+++ b/src/EcsPipeline.cs
@@ -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)
diff --git a/src/EcsRunner.cs b/src/EcsRunner.cs
index 47f2cff..757540d 100644
--- a/src/EcsRunner.cs
+++ b/src/EcsRunner.cs
@@ -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,7 +226,7 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
-#if DISABLE_CATH_EXCEPTIONS
+#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
@@ -249,7 +249,7 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
-#if DISABLE_CATH_EXCEPTIONS
+#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
@@ -265,7 +265,7 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
-#if DISABLE_CATH_EXCEPTIONS
+#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
@@ -375,7 +375,7 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
-#if DISABLE_CATH_EXCEPTIONS
+#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
@@ -398,7 +398,7 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
-#if DISABLE_CATH_EXCEPTIONS
+#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
@@ -429,7 +429,7 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
-#if DISABLE_CATH_EXCEPTIONS
+#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
@@ -452,7 +452,7 @@ namespace DCFApixels.DragonECS
}
catch (Exception e)
{
-#if DISABLE_CATH_EXCEPTIONS
+#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
diff --git a/src/EcsStaticMask.cs b/src/EcsStaticMask.cs
index a84672f..b07197d 100644
--- a/src/EcsStaticMask.cs
+++ b/src/EcsStaticMask.cs
@@ -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);
}
diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs
index a99bab7..e4d6ff9 100644
--- a/src/EcsWorld.cs
+++ b/src/EcsWorld.cs
@@ -331,8 +331,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);
@@ -381,8 +383,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;
@@ -411,8 +415,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;
@@ -431,8 +437,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;
@@ -468,8 +476,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++)
{
diff --git a/src/EcsWorld.pools.cs b/src/EcsWorld.pools.cs
index 6ed215b..178aa78 100644
--- a/src/EcsWorld.pools.cs
+++ b/src/EcsWorld.pools.cs
@@ -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,11 +284,12 @@ namespace DCFApixels.DragonECS
{
DelEntity(entityID);
}
-#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
- if (count < 0) Throw.World_InvalidIncrementComponentsBalance();
-#endif
+ CheckUnregisterValid(count, entityID);
+ }
+ private Span GetEntityComponentMask(int entityID)
+ {
+ return new Span(_entityComponentMasks, entityID << _entityComponentMaskLengthBitShift, _entityComponentMaskLength);
}
-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool TryRegisterEntityComponent(int entityID, int componentTypeID, EcsMaskChunck maskBit)
@@ -323,13 +326,26 @@ 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)
+ {
+ var mask = GetEntityComponentMask(entityID);
+ for (int i = 0; i < mask.Length; i++) { mask[i] = 0; }
+ //TODO добавить очистку пулов
+ _entities[entityID].componentsCount = 0;
+ }
+#endif
+ }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int GetPoolComponentCount(int componentTypeID)
@@ -402,7 +418,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 +432,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 +450,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 +463,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
}
diff --git a/src/EcsWorld.static.cs b/src/EcsWorld.static.cs
index 8e76d0e..6e26f9f 100644
--- a/src/EcsWorld.static.cs
+++ b/src/EcsWorld.static.cs
@@ -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]];
diff --git a/src/Executors/EcsWhereExecutor.cs b/src/Executors/EcsWhereExecutor.cs
index 9ee401c..c35a6d6 100644
--- a/src/Executors/EcsWhereExecutor.cs
+++ b/src/Executors/EcsWhereExecutor.cs
@@ -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
diff --git a/src/Executors/EcsWhereToGroupExecutor.cs b/src/Executors/EcsWhereToGroupExecutor.cs
index 150fde9..7765503 100644
--- a/src/Executors/EcsWhereToGroupExecutor.cs
+++ b/src/Executors/EcsWhereToGroupExecutor.cs
@@ -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
diff --git a/src/Injections/Injector.cs b/src/Injections/Injector.cs
index 151f612..7d3958f 100644
--- a/src/Injections/Injector.cs
+++ b/src/Injections/Injector.cs
@@ -16,7 +16,7 @@ namespace DCFApixels.DragonECS
private Dictionary _nodes = new Dictionary(32);
private bool _isInit = false;
-#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
+#if DEBUG
private HashSet _requiredInjectionTypes = new HashSet();
#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)
diff --git a/src/Pools/EcsPool.cs b/src/Pools/EcsPool.cs
index 455e46f..f22a3a8 100644
--- a/src/Pools/EcsPool.cs
+++ b/src/Pools/EcsPool.cs
@@ -39,8 +39,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[] _recycledItems;
private int _recycledItemsCount = 0;
@@ -50,7 +50,7 @@ namespace DCFApixels.DragonECS
private readonly IEcsComponentCopy _componentCopyHandler = EcsComponentCopyHandler.instance;
private readonly bool _isHasComponentCopyHandler = EcsComponentCopyHandler.isHasHandler;
-#if !DISABLE_POOLS_EVENTS
+#if !DRAGONECS_DISABLE_POOLS_EVENTS
private StructList _listeners = new StructList(2);
private int _listenersCachedCount = 0;
#endif
@@ -94,9 +94,12 @@ 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(entityID); }
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
+#elif DRAGONECS_STABILITY_MODE
+ if (itemIndex > 0) { return ref Get(entityID); }
+ if (_isLocked) { return ref _items[0]; }
#endif
if (_recycledItemsCount > 0)
{
@@ -114,7 +117,7 @@ namespace DCFApixels.DragonECS
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
ref T result = ref _items[itemIndex];
EnableComponent(ref result);
-#if !DISABLE_POOLS_EVENTS
+#if !DRAGONECS_DISABLE_POOLS_EVENTS
_listeners.InvokeOnAddAndGet(entityID, _listenersCachedCount);
#endif
return ref result;
@@ -122,10 +125,10 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref T Get(int entityID)
{
-#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
+#if DEBUG // STAB_MODE
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent(entityID); }
#endif
-#if !DISABLE_POOLS_EVENTS
+#if !DRAGONECS_DISABLE_POOLS_EVENTS
_listeners.InvokeOnGet(entityID, _listenersCachedCount);
#endif
return ref _items[_mapping[entityID]];
@@ -133,7 +136,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref readonly T Read(int entityID)
{
-#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
+#if DEBUG // STAB_MODE
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent(entityID); }
#endif
return ref _items[_mapping[entityID]];
@@ -143,8 +146,10 @@ namespace DCFApixels.DragonECS
ref int itemIndex = ref _mapping[entityID];
if (itemIndex <= 0)
{ //Add block
-#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
+#if DEBUG
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
+#elif DRAGONECS_STABILITY_MODE
+ if (_isLocked) { return ref _items[0]; }
#endif
if (_recycledItemsCount > 0)
{
@@ -161,11 +166,11 @@ namespace DCFApixels.DragonECS
}
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
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
return ref _items[itemIndex];
@@ -177,12 +182,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(entityID); }
+ if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
+#elif DRAGONECS_STABILITY_MODE
+ if (itemIndex <= 0) { return; }
+ if (_isLocked) { return; }
#endif
DisableComponent(ref _items[itemIndex]);
if (_recycledItemsCount >= _recycledItems.Length)
@@ -193,7 +199,7 @@ namespace DCFApixels.DragonECS
itemIndex = 0;
_itemsCount--;
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
-#if !DISABLE_POOLS_EVENTS
+#if !DRAGONECS_DISABLE_POOLS_EVENTS
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
#endif
}
@@ -206,23 +212,29 @@ namespace DCFApixels.DragonECS
}
public void Copy(int fromEntityID, int toEntityID)
{
-#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
+#if DEBUG
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent(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(fromEntityID); }
+#elif DRAGONECS_STABILITY_MODE
+ if (!Has(fromEntityID)) { return; }
#endif
CopyComponent(ref Get(fromEntityID), ref toWorld.GetPool().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
_recycledItemsCount = 0; // , Del
if (_itemsCount <= 0) { return; }
@@ -234,7 +246,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
}
@@ -290,7 +302,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(); }
diff --git a/src/Pools/EcsPoolBase.cs b/src/Pools/EcsPoolBase.cs
index 8b2a067..a34e156 100644
--- a/src/Pools/EcsPoolBase.cs
+++ b/src/Pools/EcsPoolBase.cs
@@ -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);
@@ -262,7 +262,7 @@ namespace DCFApixels.DragonECS
/// Called after deleting an entity from the pool
void OnDel(int entityID);
}
-#if !DISABLE_POOLS_EVENTS
+#if !DRAGONECS_DISABLE_POOLS_EVENTS
public static class PoolEventListExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/Pools/EcsTagPool.cs b/src/Pools/EcsTagPool.cs
index 5bc9694..a438546 100644
--- a/src/Pools/EcsTagPool.cs
+++ b/src/Pools/EcsTagPool.cs
@@ -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 _listeners = new StructList(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(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(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(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(fromEntityID); }
+#elif DRAGONECS_STABILITY_MODE
+ if (!Has(fromEntityID)) { return; }
#endif
toWorld.GetPool().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 _);
@@ -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(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(entityID); }
#endif
}
@@ -263,14 +273,14 @@ namespace DCFApixels.DragonECS
}
ref readonly T IEcsStructPool.Read(int entityID)
{
-#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
+#if DEBUG
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent(entityID); }
#endif
return ref _fakeComponent;
}
ref T IEcsStructPool.Get(int entityID)
{
-#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
+#if DEBUG
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent(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(); }
diff --git a/src/entlong.cs b/src/entlong.cs
index 43994c1..d7e64d3 100644
--- a/src/entlong.cs
+++ b/src/entlong.cs
@@ -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)]
From f7164de15214145cb03a754168c5d85b8073696d Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sat, 15 Mar 2025 15:06:00 +0800
Subject: [PATCH 02/13] Update Consts.cs
---
src/Consts.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/Consts.cs b/src/Consts.cs
index 2fdd0f7..21427fc 100644
--- a/src/Consts.cs
+++ b/src/Consts.cs
@@ -45,7 +45,6 @@ namespace DCFApixels.DragonECS
public const string MODULES_GROUP = "Modules";
}
- //TODO заменить ENABLE_DRAGONECS_ASSERT_CHEKS на DEV_MODE и добавить еще PERF_MODE и STAB_MODE
public static class EcsDefines
{
public const bool DRAGONECS_ENABLE_DRAGONECS_DEBUGGER =
From 7637fae7cce547ee1b64c692fa8849e1270a74de Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sat, 15 Mar 2025 15:20:11 +0800
Subject: [PATCH 03/13] fix
---
src/Consts.cs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/Consts.cs b/src/Consts.cs
index 21427fc..7d3c657 100644
--- a/src/Consts.cs
+++ b/src/Consts.cs
@@ -92,28 +92,28 @@ namespace DCFApixels.DragonECS
- [Obsolete]
+ [Obsolete("DRAGONECS_ENABLE_DRAGONECS_DEBUGGER")]
public const bool ENABLE_DRAGONECS_DEBUGGER =
-#if DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
+#if ENABLE_DRAGONECS_DEBUGGER
true;
#else
false;
#endif
- [Obsolete]
+ [Obsolete("DRAGONECS_DISABLE_POOLS_EVENTS")]
public const bool DISABLE_POOLS_EVENTS =
-#if DRAGONECS_DISABLE_POOLS_EVENTS
+#if DISABLE_POOLS_EVENTS
true;
#else
false;
#endif
- [Obsolete]
+ [Obsolete("DRAGONECS_DISABLE_CATH_EXCEPTIONS")]
public const bool DISABLE_CATH_EXCEPTIONS =
#if DISABLE_CATH_EXCEPTIONS
true;
#else
false;
#endif
- [Obsolete]
+ [Obsolete("DRAGONECS_STABILITY_MODE")]
public const bool ENABLE_DRAGONECS_ASSERT_CHEKS =
#if ENABLE_DRAGONECS_ASSERT_CHEKS
true;
From b5c4a6949e9ec92125bb9bf7aeb840b2e75a8e98 Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sat, 15 Mar 2025 15:24:44 +0800
Subject: [PATCH 04/13] remove System.Span dependency
---
src/EcsWorld.pools.cs | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/EcsWorld.pools.cs b/src/EcsWorld.pools.cs
index 178aa78..6d4dba1 100644
--- a/src/EcsWorld.pools.cs
+++ b/src/EcsWorld.pools.cs
@@ -286,11 +286,6 @@ namespace DCFApixels.DragonECS
}
CheckUnregisterValid(count, entityID);
}
- private Span GetEntityComponentMask(int entityID)
- {
- return new Span(_entityComponentMasks, entityID << _entityComponentMaskLengthBitShift, _entityComponentMaskLength);
- }
-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool TryRegisterEntityComponent(int entityID, int componentTypeID, EcsMaskChunck maskBit)
{
@@ -336,17 +331,20 @@ namespace DCFApixels.DragonECS
{
#if DEBUG
if (count < 0) { Throw.World_InvalidIncrementComponentsBalance(); }
-#elif DRAGONECS_STABILITY_MODE
+//#elif DRAGONECS_STABILITY_MODE
if (count < 0)
{
- var mask = GetEntityComponentMask(entityID);
- for (int i = 0; i < mask.Length; i++) { mask[i] = 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)
{
From 833ca7a30f608b2184bc0c9e8d890500f04b8e1e Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sat, 15 Mar 2025 15:24:58 +0800
Subject: [PATCH 05/13] fix
---
src/EcsWorld.pools.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/EcsWorld.pools.cs b/src/EcsWorld.pools.cs
index 6d4dba1..1c1d047 100644
--- a/src/EcsWorld.pools.cs
+++ b/src/EcsWorld.pools.cs
@@ -331,7 +331,7 @@ namespace DCFApixels.DragonECS
{
#if DEBUG
if (count < 0) { Throw.World_InvalidIncrementComponentsBalance(); }
-//#elif DRAGONECS_STABILITY_MODE
+#elif DRAGONECS_STABILITY_MODE
if (count < 0)
{
for (int i = entityID << _entityComponentMaskLengthBitShift, iMax = i + _entityComponentMaskLength; i < iMax; i++)
From 4a7faa58b15b347b8262e89c19c22c45f90e9290 Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sat, 15 Mar 2025 16:20:50 +0800
Subject: [PATCH 06/13] fix warnings
---
src/Builtin/BaseProcesses.cs | 5 +++--
src/EcsRunner.cs | 22 +++++++++++++---------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/src/Builtin/BaseProcesses.cs b/src/Builtin/BaseProcesses.cs
index c736ccc..e1cfd1c 100644
--- a/src/Builtin/BaseProcesses.cs
+++ b/src/Builtin/BaseProcesses.cs
@@ -167,9 +167,10 @@ namespace DCFApixels.DragonECS.Internal
catch (Exception e)
{
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
- throw;
-#endif
+ throw e;
+#else
EcsDebug.PrintError(e);
+#endif
}
}
#endif
diff --git a/src/EcsRunner.cs b/src/EcsRunner.cs
index 757540d..1b457ae 100644
--- a/src/EcsRunner.cs
+++ b/src/EcsRunner.cs
@@ -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
@@ -227,9 +227,10 @@ namespace DCFApixels.DragonECS
catch (Exception e)
{
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
- throw;
-#endif
+ throw e;
+#else
EcsDebug.PrintError(e);
+#endif
}
}
#endif
@@ -266,9 +267,10 @@ namespace DCFApixels.DragonECS
catch (Exception e)
{
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
- throw;
-#endif
+ throw e;
+#else
EcsDebug.PrintError(e);
+#endif
}
}
#endif
@@ -399,9 +401,10 @@ namespace DCFApixels.DragonECS
catch (Exception e)
{
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
- throw;
-#endif
+ throw e;
+#else
EcsDebug.PrintError(e);
+#endif
}
finally
{
@@ -453,9 +456,10 @@ namespace DCFApixels.DragonECS
catch (Exception e)
{
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
- throw;
-#endif
+ throw e;
+#else
EcsDebug.PrintError(e);
+#endif
}
finally
{
From 0367f67949ff5bc02b7bc217079fa82aab193c1f Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sat, 15 Mar 2025 16:39:03 +0800
Subject: [PATCH 07/13] refinces refactoring
---
src/Consts.cs | 6 +++---
src/DebugUtils/EcsDebug.cs | 34 +++++++++++++++++-----------------
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/Consts.cs b/src/Consts.cs
index 7d3c657..4377352 100644
--- a/src/Consts.cs
+++ b/src/Consts.cs
@@ -47,8 +47,8 @@ namespace DCFApixels.DragonECS
public static class EcsDefines
{
- public const bool DRAGONECS_ENABLE_DRAGONECS_DEBUGGER =
-#if DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
+ public const bool DRAGONECS_ENABLE_DEBUG_SERVICE =
+#if DRAGONECS_ENABLE_DEBUG_SERVICE
true;
#else
false;
@@ -92,7 +92,7 @@ namespace DCFApixels.DragonECS
- [Obsolete("DRAGONECS_ENABLE_DRAGONECS_DEBUGGER")]
+ [Obsolete("DRAGONECS_ENABLE_DEBUG_SERVICE")]
public const bool ENABLE_DRAGONECS_DEBUGGER =
#if ENABLE_DRAGONECS_DEBUGGER
true;
diff --git a/src/DebugUtils/EcsDebug.cs b/src/DebugUtils/EcsDebug.cs
index 7b70d1e..3eac63d 100644
--- a/src/DebugUtils/EcsDebug.cs
+++ b/src/DebugUtils/EcsDebug.cs
@@ -13,39 +13,39 @@ namespace DCFApixels.DragonECS
using static EcsConsts;
public readonly struct EcsProfilerMarker
{
-#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
public readonly int id;
#endif
internal EcsProfilerMarker(int id)
{
-#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
this.id = id;
#endif
}
public EcsProfilerMarker(string name)
{
-#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
id = DebugService.CurrentThreadInstance.RegisterMark(name);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Begin()
{
-#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void End()
{
-#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
DebugService.CurrentThreadInstance.ProfilerMarkEnd(id);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public AutoScope Auto()
{
-#if DEBUG || DRAGONECS_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 || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
private readonly int _id;
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public AutoScope(int id)
{
-#if DEBUG || DRAGONECS_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 || DRAGONECS_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 || DRAGONECS_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 || DRAGONECS_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 || DRAGONECS_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 || DRAGONECS_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 || DRAGONECS_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 || DRAGONECS_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 || DRAGONECS_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 || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
+#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
DebugService.CurrentThreadInstance.Break();
#endif
}
From 98c753ec88dfb318b3425ad09acf961b07b730fc Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sat, 15 Mar 2025 17:06:45 +0800
Subject: [PATCH 08/13] update readme
---
README-RU.md | 8 ++++----
README-ZH.md | 8 ++++----
README.md | 9 +++++----
3 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/README-RU.md b/README-RU.md
index 63fe803..45df20a 100644
--- a/README-RU.md
+++ b/README-RU.md
@@ -881,13 +881,13 @@ using (_marker.Auto())
# 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 и продолжать работу.
diff --git a/README-ZH.md b/README-ZH.md
index 8b1e58c..7266641 100644
--- a/README-ZH.md
+++ b/README-ZH.md
@@ -844,13 +844,13 @@ using (_marker.Auto())
# 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 输出异常信息,然后继续执行。
diff --git a/README.md b/README.md
index 9bdb823..8edb090 100644
--- a/README.md
+++ b/README.md
@@ -851,13 +851,14 @@ using (_marker.Auto())
# 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.
+
From 04a2d44596ad1be529cab8383eea687b3df98ad5 Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sat, 15 Mar 2025 17:07:34 +0800
Subject: [PATCH 09/13] up version 0.9.2
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index ca0a8f2..54bccf2 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"displayName": "DragonECS",
"description": "C# Entity Component System Framework",
"unity": "2020.3",
- "version": "0.9.1",
+ "version": "0.9.2",
"repository": {
"type": "git",
"url": "https://github.com/DCFApixels/DragonECS.git"
From 1cc630edba38c65d0a1b8c0e50d6c68a2a68834c Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sat, 15 Mar 2025 22:27:57 +0800
Subject: [PATCH 10/13] add IEcsStructPool.NewEntity()
---
src/Pools/EcsPoolBase.cs | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/Pools/EcsPoolBase.cs b/src/Pools/EcsPoolBase.cs
index a34e156..172f933 100644
--- a/src/Pools/EcsPoolBase.cs
+++ b/src/Pools/EcsPoolBase.cs
@@ -249,6 +249,18 @@ namespace DCFApixels.DragonECS
{
return self == null || self == EcsNullPool.instance;
}
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static ref T NewEntity(this IEcsStructPool self) where T : struct
+ {
+ var e = self.World.NewEntity();
+ return ref self.Add(e);
+ }
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static ref T NewEntity(this IEcsStructPool self, out int entityID) where T : struct
+ {
+ entityID = self.World.NewEntity();
+ return ref self.Add(entityID);
+ }
}
#endregion
From c8d4de16e4cb74afad5bf0016e5220154f353a7c Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sat, 15 Mar 2025 22:28:25 +0800
Subject: [PATCH 11/13] up version to 0.9.3
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 54bccf2..9ddb3e4 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"displayName": "DragonECS",
"description": "C# Entity Component System Framework",
"unity": "2020.3",
- "version": "0.9.2",
+ "version": "0.9.3",
"repository": {
"type": "git",
"url": "https://github.com/DCFApixels/DragonECS.git"
From 24b5734e55d2826b1bbcb4fe9be56d34fb0ce3f6 Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sun, 16 Mar 2025 12:58:56 +0800
Subject: [PATCH 12/13] fix Obsolete message
---
src/Pools/EcsTagPool.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Pools/EcsTagPool.cs b/src/Pools/EcsTagPool.cs
index a438546..b7626d3 100644
--- a/src/Pools/EcsTagPool.cs
+++ b/src/Pools/EcsTagPool.cs
@@ -373,14 +373,14 @@ namespace DCFApixels.DragonECS
//---------------------------------------------------
- [Obsolete("Use " + nameof(EcsAspect) + "." + nameof(EcsAspect.Builder) + "." + nameof(GetPool) + "()")]
+ [Obsolete("Use " + nameof(EcsWorld) + "." + nameof(GetPool) + "()")]
[EditorBrowsable(EditorBrowsableState.Never)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static EcsTagPool GetTagPool(this EcsWorld self) where TTagComponent : struct, IEcsTagComponent
{
return self.GetPoolInstance>();
}
- [Obsolete("Use " + nameof(EcsAspect) + "." + nameof(EcsAspect.Builder) + "." + nameof(GetPoolUnchecked) + "()")]
+ [Obsolete("Use " + nameof(EcsWorld) + "." + nameof(GetPoolUnchecked) + "()")]
[EditorBrowsable(EditorBrowsableState.Never)]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static EcsTagPool GetTagPoolUnchecked(this EcsWorld self) where TTagComponent : struct, IEcsTagComponent
From 8ad85548a2e17692a15b76ddd255a4a279467820 Mon Sep 17 00:00:00 2001
From: DCFApixels <99481254+DCFApixels@users.noreply.github.com>
Date: Sun, 16 Mar 2025 12:59:34 +0800
Subject: [PATCH 13/13] up version to 0.9.4
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 9ddb3e4..ace3df9 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"displayName": "DragonECS",
"description": "C# Entity Component System Framework",
"unity": "2020.3",
- "version": "0.9.3",
+ "version": "0.9.4",
"repository": {
"type": "git",
"url": "https://github.com/DCFApixels/DragonECS.git"