Merge branch 'dev' into test-pool

This commit is contained in:
DCFApixels 2025-03-14 17:05:04 +08:00
commit e2f51af5fc
57 changed files with 450 additions and 243 deletions

View File

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.PoolsCore;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.PoolsCore;
namespace DCFApixels.DragonECS
{

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.RunnersCore;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.RunnersCore;
using System;
namespace DCFApixels.DragonECS
@ -115,7 +118,7 @@ namespace DCFApixels.DragonECS.Internal
}
}
private Pair[] _pairs;
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
private EcsProfilerMarker[] _markers;
#endif
protected override void OnSetup()
@ -125,7 +128,7 @@ namespace DCFApixels.DragonECS.Internal
{
_pairs[i] = new Pair(Process[i]);
}
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
_markers = new EcsProfilerMarker[Process.Length];
for (int i = 0; i < Process.Length; i++)
{
@ -135,7 +138,7 @@ namespace DCFApixels.DragonECS.Internal
}
public void Run()
{
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
for (int i = 0, n = _pairs.Length < _markers.Length ? _pairs.Length : _markers.Length; i < n; i++)
{
var pair = _pairs[i];

View File

@ -1,4 +1,7 @@
using System.Diagnostics;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System.Diagnostics;
namespace DCFApixels.DragonECS
{

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
using System;
using System.Collections;
using System.Collections.Generic;
@ -231,7 +234,7 @@ namespace DCFApixels.DragonECS
}
internal void ReleaseGroup(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (group.World != this) { Throw.World_GroupDoesNotBelongWorld(); }
#endif
group._isReleased = true;
@ -304,7 +307,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
#endif
return _dense[++index];
@ -313,7 +316,7 @@ namespace DCFApixels.DragonECS
// set
// {
// // TODO добавить лок енумератора на изменение
//#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
//#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
// if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
//#endif
// var oldValue = _dense[index];
@ -366,7 +369,7 @@ namespace DCFApixels.DragonECS
#region Add/Remove
public void AddUnchecked(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (Has(entityID)) { Throw.Group_AlreadyContains(entityID); }
#endif
Add_Internal(entityID);
@ -410,7 +413,7 @@ namespace DCFApixels.DragonECS
public void RemoveUnchecked(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (Has(entityID) == false) { Throw.Group_DoesNotContain(entityID); }
#endif
Remove_Internal(entityID);
@ -428,7 +431,7 @@ namespace DCFApixels.DragonECS
private void ChangeIndexInSparse(int entityID, int index)
{
ref PageSlot page = ref _sparsePages[entityID >> PageSlot.SHIFT];
#if DEBUG && DEV_MODE
#if DEBUG && DRAGONECS_DEEP_DEBUG
if (page.Count == 0) { throw new Exception(); }
#endif
if (page.Count == 1)
@ -438,7 +441,7 @@ namespace DCFApixels.DragonECS
else
{
int localEntityID = entityID & PageSlot.MASK;
#if DEBUG && DEV_MODE
#if DEBUG && DRAGONECS_DEEP_DEBUG
if (page.Indexes[localEntityID] == 0) { throw new Exception(); }
#endif
page.Indexes[localEntityID] = index;
@ -523,7 +526,7 @@ namespace DCFApixels.DragonECS
#region CopyFrom/Clone/Slice/ToSpan/ToArray
public void CopyFrom(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (group.World != _source) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
if (_count > 0)
@ -575,7 +578,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public EcsSpan Slice(int start, int length)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (start < 0 || start + length > _count) { Throw.ArgumentOutOfRange(); }
#endif
return new EcsSpan(WorldID, _dense, start + 1, length);
@ -619,7 +622,7 @@ namespace DCFApixels.DragonECS
/// <summary>as Union sets</summary>
public void UnionWith(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
#endif
foreach (var entityID in group) { UnionWithStep(entityID); }
@ -630,7 +633,7 @@ namespace DCFApixels.DragonECS
/// <summary>as Union sets</summary>
public void UnionWith(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#endif
foreach (var entityID in span) { UnionWithStep(entityID); }
@ -653,7 +656,7 @@ namespace DCFApixels.DragonECS
/// <summary>as Except sets</summary>
public void ExceptWith(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
if (group.Count > Count) //мини оптимизация, итеррируемся по короткому списку
@ -678,7 +681,7 @@ namespace DCFApixels.DragonECS
/// <summary>as Except sets</summary>
public void ExceptWith(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
foreach (var entityID in span) { ExceptWithStep_Internal(entityID); }
@ -701,7 +704,7 @@ namespace DCFApixels.DragonECS
/// <summary>as Intersect sets</summary>
public void IntersectWith(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
for (int i = _count; i > 0; i--)//итерация в обратном порядке исключает ошибки при удалении элементов
@ -719,7 +722,7 @@ namespace DCFApixels.DragonECS
/// <summary>as Intersect sets</summary>
public void IntersectWith(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
foreach (var entityID in span)
@ -762,7 +765,7 @@ namespace DCFApixels.DragonECS
/// <summary>as Symmetric Except sets</summary>
public void SymmetricExceptWith(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
foreach (var entityID in group) { SymmetricExceptWithStep_Internal(entityID); }
@ -774,7 +777,7 @@ namespace DCFApixels.DragonECS
/// <summary>as Symmetric Except sets</summary>
public void SymmetricExceptWith(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
foreach (var entityID in span) { SymmetricExceptWithStep_Internal(entityID); }
@ -824,7 +827,7 @@ namespace DCFApixels.DragonECS
#region SetEquals
public bool SetEquals(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group.World) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
if (group.Count != Count) { return false; }
@ -841,7 +844,7 @@ namespace DCFApixels.DragonECS
public bool SetEquals(EcsReadonlyGroup group) { return SetEquals(group.GetSource_Internal()); }
public bool SetEquals(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
if (span.Count != Count) { return false; }
@ -871,7 +874,7 @@ namespace DCFApixels.DragonECS
#region Overlaps
public bool Overlaps(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group.World) Throw.Group_ArgumentDifferentWorldsException();
#endif
if (group.Count > Count)
@ -900,7 +903,7 @@ namespace DCFApixels.DragonECS
public bool Overlaps(EcsReadonlyGroup group) { return Overlaps(group.GetSource_Internal()); }
public bool Overlaps(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#endif
foreach (var entityID in span)
@ -928,7 +931,7 @@ namespace DCFApixels.DragonECS
#region IsSubsetOf/IsProperSubsetOf
public bool IsSubsetOf(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
#endif
if (Count == 0) { return true; }
@ -939,7 +942,7 @@ namespace DCFApixels.DragonECS
public bool IsSubsetOf(EcsReadonlyGroup group) { return IsSubsetOf(group.GetSource_Internal()); }
public bool IsSubsetOf(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#endif
if (Count == 0) { return true; }
@ -957,7 +960,7 @@ namespace DCFApixels.DragonECS
public bool IsProperSubsetOf(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
#endif
if (Count == 0) { return true; }
@ -968,7 +971,7 @@ namespace DCFApixels.DragonECS
public bool IsProperSubsetOf(EcsReadonlyGroup group) { return IsProperSubsetOf(group.GetSource_Internal()); }
public bool IsProperSubsetOf(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#endif
if (Count == 0) { return true; }
@ -1004,7 +1007,7 @@ namespace DCFApixels.DragonECS
{
HashSet<int> thisHS = new HashSet<int>();
ToCollection(thisHS);
#if DEBUG && DEV_MODE
#if DEBUG && DRAGONECS_DEEP_DEBUG
if (thisHS.Contains(entityID) && Has(entityID) == false) { throw new Exception(); }
#endif
if (Has(entityID))
@ -1032,7 +1035,7 @@ namespace DCFApixels.DragonECS
#region IsSupersetOf/IsProperSupersetOf
public bool IsSupersetOf(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
#endif
if (group.Count > Count) { return false; }
@ -1042,7 +1045,7 @@ namespace DCFApixels.DragonECS
public bool IsSupersetOf(EcsReadonlyGroup group) { return IsSupersetOf(group.GetSource_Internal()); }
public bool IsSupersetOf(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#endif
if (span.Count > Count) { return false; }
@ -1058,7 +1061,7 @@ namespace DCFApixels.DragonECS
public bool IsProperSupersetOf(EcsGroup group)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
#endif
if (group.Count >= Count) { return false; }
@ -1068,7 +1071,7 @@ namespace DCFApixels.DragonECS
public bool IsProperSupersetOf(EcsReadonlyGroup group) { return IsProperSupersetOf(group.GetSource_Internal()); }
public bool IsProperSupersetOf(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
#endif
if (span.Count >= Count) { return false; }
@ -1126,7 +1129,7 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Union(EcsGroup a, EcsGroup b)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
EcsGroup result = a._source.GetFreeGroup();
@ -1150,7 +1153,7 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Union(EcsSpan a, EcsSpan b)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
EcsGroup result = a.World.GetFreeGroup();
@ -1171,7 +1174,7 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Except(EcsGroup a, EcsGroup b)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
EcsGroup result = a._source.GetFreeGroup();
@ -1188,7 +1191,7 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Except(EcsSpan a, EcsGroup b)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a.WorldID != b._source.ID) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
EcsGroup result = b._source.GetFreeGroup();
@ -1205,7 +1208,7 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Except(EcsSpan a, EcsSpan b)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
EcsGroup result = a.World.GetFreeGroup();
@ -1226,7 +1229,7 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Intersect(EcsGroup a, EcsGroup b)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
EcsGroup result = a._source.GetFreeGroup();
@ -1243,7 +1246,7 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Intersect(EcsSpan a, EcsGroup b)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a.WorldID != b._source.ID) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
EcsGroup result = b._source.GetFreeGroup();
@ -1267,7 +1270,7 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup Intersect(EcsSpan a, EcsSpan b)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
EcsGroup result = b.World.GetFreeGroup();
@ -1288,7 +1291,7 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup SymmetricExcept(EcsGroup a, EcsGroup b)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
EcsGroup result = a._source.GetFreeGroup();
@ -1312,7 +1315,7 @@ namespace DCFApixels.DragonECS
/// <returns>new group from pool</returns>
public static EcsGroup SymmetricExcept(EcsSpan a, EcsSpan b)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
#endif
EcsGroup result = a.World.GetFreeGroup();

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
using System;
using System.Collections.Generic;
using System.ComponentModel;

View File

@ -88,9 +88,17 @@
#else
false;
#endif
public const bool DEV_MODE =
#if DEV_MODE
true;
public const bool DRAGONECS_PERF_MODE =
#if DRAGONECS_PERF_MODE
true;
#else
false;
#endif
public const bool DRAGONECS_STAB_MODE =
#if DRAGONECS_STAB_MODE
true;
#else
false;
#endif

View File

@ -1,3 +1,6 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System.Runtime.CompilerServices;
namespace DCFApixels.DragonECS

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
using System;
using System.Collections;
using System.Collections.Generic;
@ -10,39 +13,39 @@ namespace DCFApixels.DragonECS
using static EcsConsts;
public readonly struct EcsProfilerMarker
{
#if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER)
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
public readonly int id;
#endif
internal EcsProfilerMarker(int id)
{
#if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER)
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
this.id = id;
#endif
}
public EcsProfilerMarker(string name)
{
#if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER)
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
id = DebugService.CurrentThreadInstance.RegisterMark(name);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Begin()
{
#if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER)
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void End()
{
#if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER)
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
DebugService.CurrentThreadInstance.ProfilerMarkEnd(id);
#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public AutoScope Auto()
{
#if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER)
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
return new AutoScope(id);
#else
return default;
@ -50,13 +53,13 @@ namespace DCFApixels.DragonECS
}
public readonly ref struct AutoScope
{
#if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER)
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
private readonly int _id;
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public AutoScope(int id)
{
#if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER)
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
_id = id;
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
#endif
@ -64,7 +67,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose()
{
#if ((DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER)
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
DebugService.CurrentThreadInstance.ProfilerMarkEnd(_id);
#endif
}
@ -91,7 +94,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintWarning(object v)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
OnPrint(DEBUG_WARNING_TAG, v);
DebugService.CurrentThreadInstance.PrintWarning(v);
#endif
@ -99,7 +102,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintError(object v)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
OnPrint(DEBUG_ERROR_TAG, v);
DebugService.CurrentThreadInstance.PrintError(v);
#endif
@ -107,7 +110,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintErrorAndBreak(object v)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
OnPrint(DEBUG_ERROR_TAG, v);
DebugService.CurrentThreadInstance.PrintErrorAndBreak(v);
#endif
@ -115,7 +118,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintPass(object v)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
OnPrint(DEBUG_PASS_TAG, v);
DebugService.CurrentThreadInstance.PrintPass(v);
#endif
@ -123,7 +126,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Print()
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
OnPrint(string.Empty, null);
DebugService.CurrentThreadInstance.Print();
#endif
@ -131,7 +134,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Print(object v)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
OnPrint(string.Empty, v);
DebugService.CurrentThreadInstance.Print(v);
#endif
@ -139,7 +142,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Print(string tag, object v)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
OnPrint(tag, v);
DebugService.CurrentThreadInstance.Print(tag, v);
#endif
@ -147,7 +150,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Break()
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_DEBUGGER
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
DebugService.CurrentThreadInstance.Break();
#endif
}

View File

@ -1,6 +1,9 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Collections.Generic;
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED
#if DEBUG || !REFLECTION_DISABLED
using System.Reflection;
#endif
@ -8,7 +11,7 @@ namespace DCFApixels.DragonECS
{
public static class EcsDebugUtility
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED
#if DEBUG || !REFLECTION_DISABLED
private const BindingFlags RFL_FLAGS = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
#endif
@ -31,7 +34,7 @@ namespace DCFApixels.DragonECS
}
private static string GetGenericTypeName_Internal(Type type, int maxDepth, bool isFull)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
string typeName = isFull ? type.FullName : type.Name;
if (!type.IsGenericType || maxDepth == 0)
{
@ -68,7 +71,7 @@ namespace DCFApixels.DragonECS
internal static string AutoToString(object target, Type type, bool isWriteName)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#pragma warning disable IL2070 // 'this' argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The parameter of method does not have matching annotations.
var fields = type.GetFields(RFL_FLAGS);
#pragma warning restore IL2070

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
namespace DCFApixels.DragonECS.Core
{

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal;
using System;
using System.Runtime.InteropServices;

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using System;
namespace DCFApixels.DragonECS

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using System;
using System.Collections.Generic;
using System.Diagnostics;

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal;
using System;
using System.Runtime.InteropServices;

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using System;
namespace DCFApixels.DragonECS

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using System;
using System.Collections.Generic;

View File

@ -1,10 +1,13 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED
#if DEBUG || !REFLECTION_DISABLED
using System.Reflection;
#endif
@ -326,7 +329,7 @@ namespace DCFApixels.DragonECS
}
private static bool CheckEcsMemener(Type checkedType)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED
#if DEBUG || !REFLECTION_DISABLED
return checkedType.IsInterface == false && checkedType.IsAbstract == false && typeof(IEcsMember).IsAssignableFrom(checkedType);
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(CheckEcsMemener)} method does not work.");
@ -335,7 +338,7 @@ namespace DCFApixels.DragonECS
}
public static bool IsHasMeta(Type type)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED
#if DEBUG || !REFLECTION_DISABLED
return CheckEcsMemener(type) || Attribute.GetCustomAttributes(type, typeof(EcsMetaAttribute), false).Length > 0;
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(IsHasMeta)} method does not work.");
@ -344,7 +347,7 @@ namespace DCFApixels.DragonECS
}
public static bool IsHasMetaID(Type type)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED
#if DEBUG || !REFLECTION_DISABLED
return type.HasAttribute<MetaIDAttribute>();
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(IsHasMetaID)} method does not work.");
@ -413,7 +416,7 @@ namespace DCFApixels.DragonECS
}
public static (string, bool) GetMetaName(Type type)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
bool isCustom = type.TryGetAttribute(out MetaNameAttribute atr) && string.IsNullOrEmpty(atr.name) == false;
if (isCustom)
{
@ -455,7 +458,7 @@ namespace DCFApixels.DragonECS
}
public static (MetaColor, bool) GetColor(TypeMeta meta)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
bool isCustom = meta.Type.TryGetAttribute(out MetaColorAttribute atr);
return (isCustom ? atr.color : AutoColor(meta), isCustom);
#else
@ -468,7 +471,7 @@ namespace DCFApixels.DragonECS
#region GetGroup
public static MetaGroup GetGroup(Type type)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
return type.TryGetAttribute(out MetaGroupAttribute atr) ? atr.Data : MetaGroup.FromNameSpace(type);
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(MetaGenerator)}.{nameof(GetGroup)} method does not work.");
@ -480,7 +483,7 @@ namespace DCFApixels.DragonECS
#region GetDescription
public static MetaDescription GetDescription(Type type)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
bool isCustom = type.TryGetAttribute(out MetaDescriptionAttribute atr);
return isCustom ? atr.Data : MetaDescription.Empty;
#else
@ -493,7 +496,7 @@ namespace DCFApixels.DragonECS
#region GetTags
public static IReadOnlyList<string> GetTags(Type type)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
var atr = type.GetCustomAttribute<MetaTagsAttribute>();
return atr != null ? atr.Tags : Array.Empty<string>();
#else
@ -504,12 +507,12 @@ namespace DCFApixels.DragonECS
#endregion
#region GetMetaID
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
private static Dictionary<string, Type> _idTypePairs = new Dictionary<string, Type>();
#endif
public static string GetMetaID(Type type)
{
#if (DEBUG && !DISABLE_DEBUG) || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
var atr = type.GetCustomAttribute<MetaIDAttribute>();
if (atr == null)

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal;
using System;
using System.Collections.Generic;
@ -358,7 +361,7 @@ namespace DCFApixels.DragonECS
#region Debug utils
private static string CreateLogString(short worldID, int[] inc, int[] exc)
{
#if (DEBUG && !DISABLE_DEBUG)
#if DEBUG
string converter(int o) { return EcsDebugUtility.GetGenericTypeName(EcsWorld.GetWorld(worldID).AllPools[o].ComponentType, 1); }
return $"Inc({string.Join(", ", inc.Select(converter))}) Exc({string.Join(", ", exc.Select(converter))})";
#else

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
using DCFApixels.DragonECS.RunnersCore;
using System;
using System.Collections;
@ -298,13 +301,13 @@ namespace DCFApixels.DragonECS
#endregion
#region Build
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
private static EcsProfilerMarker _buildBarker = new EcsProfilerMarker("EcsPipeline.Build");
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
private static EcsProfilerMarker _buildMarker = new EcsProfilerMarker("EcsPipeline.Build");
#endif
public EcsPipeline Build()
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
_buildBarker.Begin();
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
_buildMarker.Begin();
#endif
var it = new LinkedListIterator<SystemNode>(_systemNodes, _systemNodesCount, _startIndex);
@ -369,8 +372,8 @@ namespace DCFApixels.DragonECS
{
item.Declare(pipeline);
}
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
_buildBarker.End();
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
_buildMarker.End();
#endif
return pipeline;
}

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
using DCFApixels.DragonECS.RunnersCore;
using System;
using System.Collections;
@ -32,7 +35,6 @@ namespace DCFApixels.DragonECS
public sealed partial class EcsPipeline
{
private readonly IConfigContainer _configs;
private Injector.Builder _injectorBuilder;
private Injector _injector;
private IEcsProcess[] _allSystems;
@ -43,7 +45,7 @@ namespace DCFApixels.DragonECS
private bool _isInit = false;
private bool _isDestoryed = false;
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
private static EcsProfilerMarker _initMarker = new EcsProfilerMarker("EcsPipeline.Init");
#endif
@ -79,8 +81,15 @@ namespace DCFApixels.DragonECS
{
_configs = configs;
_allSystems = systems;
_injectorBuilder = injectorBuilder;
_injectorBuilder.Inject(this);
injectorBuilder.Inject(this);
var members = GetProcess<IEcsPipelineMember>();
for (int i = 0; i < members.Length; i++)
{
members[i].Pipeline = this;
}
_injector = injectorBuilder.Build(this);
}
#endregion
@ -130,14 +139,18 @@ namespace DCFApixels.DragonECS
{
return (TRunner)result;
}
TRunner instance = new TRunner();
TRunner runnerInstance = new TRunner();
#if DEBUG
EcsRunner.CheckRunnerTypeIsValide(runnerType, instance.Interface);
EcsRunner.CheckRunnerTypeIsValide(runnerType, runnerInstance.Interface);
#endif
instance.Init_Internal(this);
_runners.Add(runnerType, instance);
_runners.Add(instance.Interface, instance);
return instance;
runnerInstance.Init_Internal(this);
_runners.Add(runnerType, runnerInstance);
_runners.Add(runnerInstance.Interface, runnerInstance);
Injector.ExtractAllTo(runnerInstance);
// init after.
Injector.Inject(runnerInstance);
return runnerInstance;
}
public T GetRunner<T>() where T : IEcsProcess
{
@ -175,16 +188,9 @@ namespace DCFApixels.DragonECS
EcsDebug.PrintWarning($"This {nameof(EcsPipeline)} has already been initialized");
return;
}
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
_initMarker.Begin();
#endif
var members = GetProcess<IEcsPipelineMember>();
for (int i = 0; i < members.Length; i++)
{
members[i].Pipeline = this;
}
_injector = _injectorBuilder.Build(this);
_injectorBuilder = null;
GetRunnerInstance<EcsPreInitRunner>().PreInit();
GetRunnerInstance<EcsInitRunner>().Init();
@ -193,7 +199,7 @@ namespace DCFApixels.DragonECS
_isInit = true;
GC.Collect();
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
_initMarker.End();
#endif
}
@ -201,7 +207,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Run()
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Run)); }
if (_isDestoryed) { Throw.Pipeline_MethodCalledAfterDestruction(nameof(Run)); }
#endif
@ -209,7 +215,7 @@ namespace DCFApixels.DragonECS
}
public void Destroy()
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Destroy)); }
#endif
if (_isDestoryed)

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
using DCFApixels.DragonECS.RunnersCore;
using System;
using System.Linq;
@ -130,7 +133,7 @@ namespace DCFApixels.DragonECS
#endregion
#region RunHelper
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
public
#else
public readonly
@ -138,7 +141,7 @@ namespace DCFApixels.DragonECS
struct RunHelper
{
private readonly EcsProcess<TProcess> _process;
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
private Delegate _cacheCheck;
private bool _cacheCheckInit;
private readonly EcsProfilerMarker[] _markers;
@ -146,7 +149,7 @@ namespace DCFApixels.DragonECS
#region Constructors
public RunHelper(EcsRunner<TProcess> runner) : this(runner,
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
typeof(TProcess).ToMeta().Name)
#else
string.Empty)
@ -156,7 +159,7 @@ namespace DCFApixels.DragonECS
public RunHelper(EcsRunner<TProcess> runner, string methodName)
{
_process = runner.Process;
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
_cacheCheck = null;
_cacheCheckInit = false;
_markers = new EcsProfilerMarker[_process.Length];
@ -169,7 +172,7 @@ namespace DCFApixels.DragonECS
#endregion
#region Utils
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void CheckCache(Delegate d)
{
@ -196,7 +199,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Run(Action<TProcess> translationCallback)
{
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
CheckCache(translationCallback);
for (int i = 0, n = _process.Length < _markers.Length ? _process.Length : _markers.Length; i < n; i++)
{
@ -235,7 +238,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Run<TData>(ActionWithData<TProcess, TData> translationCallback, ref TData data)
{
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
CheckCache(translationCallback);
for (int i = 0, n = _process.Length < _markers.Length ? _process.Length : _markers.Length; i < n; i++)
{
@ -275,7 +278,7 @@ namespace DCFApixels.DragonECS
#endregion
#region RunHelperWithFinally
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
public
#else
public readonly
@ -283,7 +286,7 @@ namespace DCFApixels.DragonECS
struct RunHelperWithFinally<TProcessFinally> where TProcessFinally : class, IEcsProcess
{
private readonly Pair[] _pairs;
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
private Delegate _cacheCheck;
private Delegate _cacheCheckF;
private bool _cacheCheckInit;
@ -292,7 +295,7 @@ namespace DCFApixels.DragonECS
#region Constructors
public RunHelperWithFinally(EcsRunner<TProcess> runner) : this(runner,
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
typeof(TProcess).ToMeta().Name)
#else
string.Empty)
@ -306,7 +309,7 @@ namespace DCFApixels.DragonECS
{
_pairs[i] = new Pair(runner.Process[i]);
}
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
_cacheCheck = null;
_cacheCheckF = null;
_cacheCheckInit = false;
@ -330,7 +333,7 @@ namespace DCFApixels.DragonECS
runFinally = run as TProcessFinally;
}
}
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void CheckCache(Delegate d, Delegate df)
{
@ -360,7 +363,7 @@ namespace DCFApixels.DragonECS
Action<TProcess> translationCallback,
Action<TProcessFinally> translationFinnalyCallback)
{
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
CheckCache(translationCallback, translationFinnalyCallback);
for (int i = 0, n = _pairs.Length < _markers.Length ? _pairs.Length : _markers.Length; i < n; i++)
{
@ -414,7 +417,7 @@ namespace DCFApixels.DragonECS
ActionWithData<TProcessFinally, TData> translationFinnalyCallback,
ref TData data)
{
#if DEBUG && !DISABLE_DEBUG
#if DEBUG
CheckCache(translationCallback, translationFinnalyCallback);
for (int i = 0, n = _pairs.Length < _markers.Length ? _pairs.Length : _markers.Length; i < n; i++)
{

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal;
using System;
using System.Collections.Concurrent;
@ -339,14 +342,14 @@ namespace DCFApixels.DragonECS
#region Inc/Exc/Combine/Except
public void Inc(EcsTypeCode typeCode)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(); }
#endif
_inc.Add(typeCode);
}
public void Exc(EcsTypeCode typeCode)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(); }
#endif
_exc.Add(typeCode);
@ -451,7 +454,7 @@ namespace DCFApixels.DragonECS
#region Debug utils
private static string CreateLogString(EcsTypeCode[] inc, EcsTypeCode[] exc)
{
#if (DEBUG && !DISABLE_DEBUG)
#if DEBUG
string converter(EcsTypeCode o) { return EcsTypeCodeManager.FindTypeOfCode(o).ToString(); }
return $"Inc({string.Join(", ", inc.Select(converter))}) Exc({string.Join(", ", exc.Select(converter))})";
#else

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.PoolsCore;
namespace DCFApixels.DragonECS

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
@ -215,7 +218,7 @@ namespace DCFApixels.DragonECS
}
if (ID == NULL_WORLD_ID)
{
#if (DEBUG && !DISABLE_DEBUG)
#if DEBUG
Throw.World_WorldCantBeDestroyed();
#endif
return;
@ -324,7 +327,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int NewEntity(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (entityID < _entities.Length && IsUsed(entityID)) { Throw.World_EntityIsAlreadyСontained(entityID); }
#endif
_entityDispenser.Use(entityID);
@ -374,7 +377,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void DelEntity(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (IsUsed(entityID) == false) { Throw.World_EntityIsNotContained(entityID); }
#endif
UpVersion();
@ -404,7 +407,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void InitEntitySlot(int entityID, short gen)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
#endif
_entityDispenser.Upsize(entityID);
@ -424,7 +427,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool IsAlive(entlong entity)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (entity.GetWorldIDUnchecked() != ID) { Throw.World_MaskDoesntBelongWorld(); }
#endif
ref var slot = ref _entities[entity.GetIDUnchecked()];
@ -461,7 +464,7 @@ namespace DCFApixels.DragonECS
}
public bool IsMatchesMask(EcsMask mask, int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (mask.WorldID != ID) { Throw.World_MaskDoesntBelongWorld(); }
#endif
for (int i = 0, iMax = mask._incs.Length; i < iMax; i++)

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Linq;
@ -15,7 +18,7 @@ namespace DCFApixels.DragonECS
internal PoolSlot[] _poolSlots;
private int _poolsCount;
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
private int _lockedPoolCount = 0;
#endif
@ -43,7 +46,7 @@ namespace DCFApixels.DragonECS
ref var result = ref _pools[componentTypeID];
if (result != _nullPool)
{
#if (DEBUG && !DISABLE_DEBUG)
#if DEBUG
if (result.ComponentTypeID != componentTypeID) { Throw.UndefinedException(); }
#endif
return result;
@ -149,7 +152,7 @@ namespace DCFApixels.DragonECS
#region FindOrAutoCreatePool/InitPool
public void InitPool(IEcsPoolImplementation poolImplementation)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
#endif
InitPool_Internal(poolImplementation);
@ -162,7 +165,7 @@ namespace DCFApixels.DragonECS
if (_poolTypeCode_2_CmpTypeIDs.TryGetValue(poolTypeCode, out int cmpTypeID))
{
var pool = _pools[cmpTypeID];
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if ((pool is TPool) == false) { Throw.UndefinedException(); }
#endif
return (TPool)pool;
@ -279,7 +282,7 @@ namespace DCFApixels.DragonECS
{
DelEntity(entityID);
}
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (count < 0) Throw.World_InvalidIncrementComponentsBalance();
#endif
}
@ -320,7 +323,7 @@ namespace DCFApixels.DragonECS
{
DelEntity(entityID);
}
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (count < 0) Throw.World_InvalidIncrementComponentsBalance();
#endif
return true;
@ -399,7 +402,7 @@ namespace DCFApixels.DragonECS
#region LockPool/UnLockPool
public void LockPool_Debug(int componentTypeID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
ref var slot = ref _poolSlots[componentTypeID];
if (slot.lockedCounter == 0)
{
@ -413,7 +416,7 @@ namespace DCFApixels.DragonECS
}
public void UnlockPool_Debug(int componentTypeID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
ref var slot = ref _poolSlots[componentTypeID];
slot.lockedCounter--;
if (slot.lockedCounter <= 0)
@ -431,7 +434,7 @@ namespace DCFApixels.DragonECS
}
public bool CheckPoolLocked_Debug(int componentTypeID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
return _poolSlots[componentTypeID].lockedCounter != 0;
#else
return false;
@ -444,7 +447,7 @@ namespace DCFApixels.DragonECS
{
public long version;
public int count;
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
public int lockedCounter;
#endif
}

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -143,7 +146,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T GetForWorldUnchecked(short worldID)
{// ts
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_mapping[worldID] <= 0) { Throw.ArgumentOutOfRange(); }
#endif
return ref _items[_mapping[worldID]];

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using System;
using System.Runtime.CompilerServices;
#if ENABLE_IL2CPP
@ -71,7 +74,7 @@ namespace DCFApixels.DragonECS.Internal
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ExecuteFor_Iternal(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
if (span.WorldID != World.ID) { Throw.Quiery_ArgumentDifferentWorldsException(); }
#endif

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using System.Runtime.CompilerServices;
#if ENABLE_IL2CPP
using Unity.IL2CPP.CompilerServices;
@ -70,7 +73,7 @@ namespace DCFApixels.DragonECS.Internal
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ExecuteFor_Iternal(EcsSpan span)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
if (span.WorldID != World.ID) { Throw.Quiery_ArgumentDifferentWorldsException(); }
#endif

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal;
using System;
using System.Collections.Generic;

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Core;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Internal;
using System;

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
namespace DCFApixels.DragonECS
{

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Runtime.CompilerServices;
namespace DCFApixels.DragonECS.Internal

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Runtime.CompilerServices;
namespace DCFApixels.DragonECS
@ -6,16 +9,11 @@ namespace DCFApixels.DragonECS
public abstract class InjectionNodeBase
{
private readonly Type _type;
public Type Type
{
get { return _type; }
}
public Type Type { get { return _type; } }
public abstract object CurrentInjectedDependencyRaw { get; }
protected InjectionNodeBase(Type type)
{
_type = type;
}
protected InjectionNodeBase(Type type) { _type = type; }
public abstract void Inject(object obj);
public abstract void ExtractTo(object target);
public abstract void Init(EcsPipeline pipeline);
}
}
@ -23,6 +21,7 @@ namespace DCFApixels.DragonECS.Internal
{
internal sealed class InjectionNode<T> : InjectionNodeBase
{
private EcsPipeline _pipeline;
private EcsProcess<IEcsInject<T>> _process;
private T _currentInjectedDependency;
public sealed override object CurrentInjectedDependencyRaw
@ -38,6 +37,7 @@ namespace DCFApixels.DragonECS.Internal
public InjectionNode() : base(typeof(T)) { }
public sealed override void Init(EcsPipeline pipeline)
{
_pipeline = pipeline;
_process = pipeline.GetProcess<IEcsInject<T>>();
}
public sealed override void Inject(object raw)
@ -48,6 +48,24 @@ namespace DCFApixels.DragonECS.Internal
{
_process[i].Inject(obj);
}
foreach (var runner in _pipeline.AllRunners)
{
ExtractTo_Internal(runner.Value);
}
}
public sealed override void ExtractTo(object target)
{
if (_currentInjectedDependency == null) { return; }
ExtractTo_Internal(target);
}
private void ExtractTo_Internal(object target)
{
var type = target.GetType();
var intrfs = type.GetInterfaces();
if (target is IEcsInject<T> intrf)
{
intrf.Inject(_currentInjectedDependency);
}
}
}
}

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
@ -13,7 +16,7 @@ namespace DCFApixels.DragonECS
private Dictionary<Type, InjectionNodeBase> _nodes = new Dictionary<Type, InjectionNodeBase>(32);
private bool _isInit = false;
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
private HashSet<Type> _requiredInjectionTypes = new HashSet<Type>();
#endif
@ -47,7 +50,7 @@ namespace DCFApixels.DragonECS
branch = new InjectionBranch(this, objType);
InitBranch(branch);
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
foreach (var requiredInjectionType in _requiredInjectionTypes)
{
if (requiredInjectionType.IsAssignableFrom(objType))
@ -62,6 +65,15 @@ namespace DCFApixels.DragonECS
}
branch.Inject(raw);
}
public void ExtractAllTo(object target)
{
if (target is IEcsInjectProcess == false) { return; }
foreach (var node in _nodes)
{
node.Value.ExtractTo(target);
}
}
public T Extract<T>()
{
return (T)Extract_Internal(typeof(T));
@ -132,7 +144,7 @@ namespace DCFApixels.DragonECS
}
_isInit = true;
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
var systems = _pipeline.AllSystems;
var injectType = typeof(IEcsInject<>);
foreach (var system in systems)

View File

@ -1,11 +1,16 @@
namespace DCFApixels.DragonECS
#if DISABLE_DEBUG
#undef DEBUG
#endif
namespace DCFApixels.DragonECS
{
public interface IEcsInjectProcess : IEcsProcess { }
[MetaName(nameof(Inject))]
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.DI_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "The interface of the dependency injection process.")]
[MetaID("4C86537C92019AA24383CBF53CBD456C")]
public interface IEcsInject<T> : IEcsProcess
public interface IEcsInject<T> : IEcsInjectProcess
{
void Inject(T obj);
}

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
#if ENABLE_IL2CPP

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Reflection;
using System.Runtime.CompilerServices;

View File

@ -1,6 +1,9 @@
//SparseArray. Analogous to Dictionary<int, T>, but faster.
//Benchmark result of indexer.get speed test with 300 elements:
//[Dictinary: 5.786us] [SparseArray: 2.047us].
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;

View File

@ -89,13 +89,18 @@ namespace DCFApixels.DragonECS
{
get { return false; }
}
public ref T this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return ref Get(index); }
}
#endregion
#region Methods
public ref T Add(int entityID)
{
ref int itemIndex = ref _mapping[entityID];
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#endif
@ -120,7 +125,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref T Get(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
#endif
#if !DISABLE_POOLS_EVENTS
@ -131,7 +136,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref readonly T Read(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
#endif
return ref _items[_mapping[entityID]];
@ -183,11 +188,11 @@ namespace DCFApixels.DragonECS
}
public void Del(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#endif
ref int itemIndex = ref _mapping[entityID];
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (itemIndex <= 0) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
#endif
DisableComponent(ref _items[itemIndex]);
@ -216,14 +221,14 @@ namespace DCFApixels.DragonECS
}
public void Copy(int fromEntityID, int toEntityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
#endif
CopyComponent(ref Get(fromEntityID), ref TryAddOrGet(toEntityID));
}
public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
#endif
CopyComponent(ref Get(fromEntityID), ref toWorld.GetPool<T>().TryAddOrGet(toEntityID));
@ -231,7 +236,7 @@ namespace DCFApixels.DragonECS
public void ClearAll()
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#endif
if (_itemsCount <= 0) { return; }
@ -269,7 +274,7 @@ namespace DCFApixels.DragonECS
//_sparseEntities = new int[_capacity];
//_denseEntitiesDelayed = new int[_capacity];
//for (int i = 0; i < _capacity; i++)
//{// ìîæíî îïòèìèçèðîâàòü òåì ÷òîáû âìåñòî çàïîëíåíèÿ, â ìåòîäå âûäà÷è free index-à åñëè _denseEntitiesDelayed âîçâðàùàåò 0, òî free index îïðåäåëÿòü ÷åðåç èíêðåìåíò
//{// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> free index-<2D> <20><><EFBFBD><EFBFBD> _denseEntitiesDelayed <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0, <20><> free index <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// _denseEntitiesDelayed[i] = i;
//}
}

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections.Generic;
@ -84,7 +87,7 @@ namespace DCFApixels.DragonECS.Internal
{
get
{
#if (DEBUG && !DISABLE_DEBUG)
#if (DEBUG)
throw new NullInstanceException();
#else
return EcsWorld.GetWorld(0);
@ -102,25 +105,25 @@ namespace DCFApixels.DragonECS.Internal
}
void IEcsPool.Del(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG)
#if (DEBUG)
throw new NullInstanceException();
#endif
}
void IEcsPool.AddEmpty(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG)
#if (DEBUG)
throw new NullInstanceException();
#endif
}
void IEcsPool.AddRaw(int entityID, object dataRaw)
{
#if (DEBUG && !DISABLE_DEBUG)
#if (DEBUG)
throw new NullInstanceException();
#endif
}
object IEcsReadonlyPool.GetRaw(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG)
#if (DEBUG)
throw new NullInstanceException();
#else
return null;
@ -128,25 +131,25 @@ namespace DCFApixels.DragonECS.Internal
}
void IEcsPool.SetRaw(int entity, object dataRaw)
{
#if (DEBUG && !DISABLE_DEBUG)
#if (DEBUG)
throw new NullInstanceException();
#endif
}
void IEcsReadonlyPool.Copy(int fromEntityID, int toEntityID)
{
#if (DEBUG && !DISABLE_DEBUG)
#if (DEBUG)
throw new NullInstanceException();
#endif
}
void IEcsReadonlyPool.Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
{
#if (DEBUG && !DISABLE_DEBUG)
#if (DEBUG)
throw new NullInstanceException();
#endif
}
void IEcsPool.ClearAll()
{
#if (DEBUG && !DISABLE_DEBUG)
#if (DEBUG)
throw new NullInstanceException();
#endif
}

View File

@ -1,3 +1,6 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.PoolsCore;
using System;
@ -7,9 +10,6 @@ using System.Runtime.CompilerServices;
using System.Diagnostics;
using DCFApixels.DragonECS.Internal;
using System.ComponentModel;
#if (DEBUG && !DISABLE_DEBUG)
using System.Reflection;
#endif
#if ENABLE_IL2CPP
using Unity.IL2CPP.CompilerServices;
#endif
@ -52,12 +52,12 @@ namespace DCFApixels.DragonECS
private EcsWorld.PoolsMediator _mediator;
#region CheckValide
#if (DEBUG && !DISABLE_DEBUG)
#if DEBUG
private static bool _isInvalidType;
static EcsTagPool()
{
#pragma warning disable IL2090 // 'this' argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The generic parameter of the source method or type does not have matching annotations.
_isInvalidType = typeof(T).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Length > 0;
_isInvalidType = typeof(T).GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic).Length > 0;
#pragma warning restore IL2090
}
public EcsTagPool()
@ -91,12 +91,19 @@ namespace DCFApixels.DragonECS
{
get { return false; }
}
public bool this[int index]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return Has(index); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set { Set(index, value); }
}
#endregion
#region Method
public void Add(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (Has(entityID)) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#endif
@ -121,7 +128,7 @@ namespace DCFApixels.DragonECS
}
public void Del(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#endif
@ -142,14 +149,14 @@ namespace DCFApixels.DragonECS
}
public void Copy(int fromEntityID, int toEntityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
#endif
TryAdd(toEntityID);
}
public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
#endif
toWorld.GetPool<T>().TryAdd(toEntityID);
@ -182,7 +189,7 @@ namespace DCFApixels.DragonECS
public void ClearAll()
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
#endif
if (_count <= 0) { return; }
@ -238,14 +245,14 @@ namespace DCFApixels.DragonECS
void IEcsPool.AddRaw(int entityID, object dataRaw) { Add(entityID); }
object IEcsReadonlyPool.GetRaw(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
#endif
return _fakeComponent;
}
void IEcsPool.SetRaw(int entityID, object dataRaw)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
#endif
}
@ -256,14 +263,14 @@ namespace DCFApixels.DragonECS
}
ref readonly T IEcsStructPool<T>.Read(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
#endif
return ref _fakeComponent;
}
ref T IEcsStructPool<T>.Get(int entityID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
#endif
return ref _fakeComponent;

View File

@ -1,4 +1,7 @@
using DCFApixels.DragonECS.Internal;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Internal;
using System;
namespace DCFApixels.DragonECS

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Runtime.Serialization;
namespace DCFApixels.DragonECS

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Runtime.CompilerServices;
namespace DCFApixels.DragonECS

View File

@ -1,4 +1,7 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Collections;
using System.Collections.Generic;

View File

@ -1,3 +1,7 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
namespace DCFApixels.DragonECS
{
public interface ITemplateNode

View File

@ -1,4 +1,8 @@
using System;
#if DISABLE_DEBUG
#undef DEBUG
#endif
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

View File

@ -1,4 +1,7 @@
#pragma warning disable IDE1006
#if DISABLE_DEBUG
#undef DEBUG
#endif
#pragma warning disable IDE1006
#pragma warning disable CS8981
using DCFApixels.DragonECS.Internal;
using System;
@ -56,7 +59,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#endif
return _id;
@ -67,7 +70,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#endif
return _gen;
@ -78,7 +81,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#endif
return GetWorld_Internal();
@ -89,7 +92,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#endif
return _world;
@ -141,7 +144,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Unpack(out int id, out EcsWorld world)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#endif
world = EcsWorld.GetWorld(_world);
@ -150,7 +153,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Unpack(out int id, out short gen, out EcsWorld world)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#endif
world = EcsWorld.GetWorld(_world);
@ -160,7 +163,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Unpack(out int id, out short worldID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#endif
worldID = _world;
@ -169,7 +172,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Unpack(out int id, out short gen, out short worldID)
{
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
#endif
worldID = _world;