mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-19 02:24:37 +08:00
add DRAGONECS_STABILITY_MODE/ defines refactoring
This commit is contained in:
parent
bdfd5d83de
commit
0be714a0d7
@ -149,7 +149,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -166,7 +166,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
try { item.Run(); }
|
try { item.Run(); }
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
|
@ -234,8 +234,16 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
internal void ReleaseGroup(EcsGroup group)
|
internal void ReleaseGroup(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (group.World != this) { Throw.World_GroupDoesNotBelongWorld(); }
|
if (group.World != this) { Throw.World_GroupDoesNotBelongWorld(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (group.World != this)
|
||||||
|
{
|
||||||
|
if (TryGetWorld(group.WorldID, out EcsWorld sourceWorld))
|
||||||
|
{
|
||||||
|
group.World.ReleaseGroup(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
group._isReleased = true;
|
group._isReleased = true;
|
||||||
group.Clear();
|
group.Clear();
|
||||||
@ -307,8 +315,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
|
if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (index < 0 || index >= Count) { return EcsConsts.NULL_ENTITY_ID; }
|
||||||
#endif
|
#endif
|
||||||
return _dense[++index];
|
return _dense[++index];
|
||||||
}
|
}
|
||||||
@ -316,7 +326,7 @@ namespace DCFApixels.DragonECS
|
|||||||
// set
|
// set
|
||||||
// {
|
// {
|
||||||
// // TODO добавить лок енумератора на изменение
|
// // TODO добавить лок енумератора на изменение
|
||||||
//#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
//#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
// if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
|
// if (index < 0 || index >= Count) { Throw.ArgumentOutOfRange(); }
|
||||||
//#endif
|
//#endif
|
||||||
// var oldValue = _dense[index];
|
// var oldValue = _dense[index];
|
||||||
@ -369,8 +379,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Add/Remove
|
#region Add/Remove
|
||||||
public void AddUnchecked(int entityID)
|
public void AddUnchecked(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID)) { Throw.Group_AlreadyContains(entityID); }
|
if (Has(entityID)) { Throw.Group_AlreadyContains(entityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (Has(entityID)) { return; }
|
||||||
#endif
|
#endif
|
||||||
Add_Internal(entityID);
|
Add_Internal(entityID);
|
||||||
}
|
}
|
||||||
@ -413,8 +425,10 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public void RemoveUnchecked(int entityID)
|
public void RemoveUnchecked(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID) == false) { Throw.Group_DoesNotContain(entityID); }
|
if (Has(entityID) == false) { Throw.Group_DoesNotContain(entityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (Has(entityID) == false) { return; }
|
||||||
#endif
|
#endif
|
||||||
Remove_Internal(entityID);
|
Remove_Internal(entityID);
|
||||||
}
|
}
|
||||||
@ -526,13 +540,16 @@ namespace DCFApixels.DragonECS
|
|||||||
#region CopyFrom/Clone/Slice/ToSpan/ToArray
|
#region CopyFrom/Clone/Slice/ToSpan/ToArray
|
||||||
public void CopyFrom(EcsGroup group)
|
public void CopyFrom(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (group.World != _source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (group.World != _source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
#endif
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
if (_count > 0)
|
if (group.World != _source)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
Clear();
|
||||||
foreach (var entityID in group)
|
foreach (var entityID in group)
|
||||||
{
|
{
|
||||||
Add_Internal(entityID);
|
Add_Internal(entityID);
|
||||||
@ -578,8 +595,11 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public EcsSpan Slice(int start, int length)
|
public EcsSpan Slice(int start, int length)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (start < 0 || start + length > _count) { Throw.ArgumentOutOfRange(); }
|
if (start < 0 || start + length > _count) { Throw.ArgumentOutOfRange(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (start < 0) { start = 0; }
|
||||||
|
if (start + length > _count) { length = _count - start; }
|
||||||
#endif
|
#endif
|
||||||
return new EcsSpan(WorldID, _dense, start + 1, length);
|
return new EcsSpan(WorldID, _dense, start + 1, length);
|
||||||
}
|
}
|
||||||
@ -622,8 +642,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Union sets</summary>
|
/// <summary>as Union sets</summary>
|
||||||
public void UnionWith(EcsGroup group)
|
public void UnionWith(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in group) { UnionWithStep(entityID); }
|
foreach (var entityID in group) { UnionWithStep(entityID); }
|
||||||
}
|
}
|
||||||
@ -633,8 +655,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Union sets</summary>
|
/// <summary>as Union sets</summary>
|
||||||
public void UnionWith(EcsSpan span)
|
public void UnionWith(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in span) { UnionWithStep(entityID); }
|
foreach (var entityID in span) { UnionWithStep(entityID); }
|
||||||
}
|
}
|
||||||
@ -656,8 +680,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Except sets</summary>
|
/// <summary>as Except sets</summary>
|
||||||
public void ExceptWith(EcsGroup group)
|
public void ExceptWith(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return; }
|
||||||
#endif
|
#endif
|
||||||
if (group.Count > Count) //мини оптимизация, итеррируемся по короткому списку
|
if (group.Count > Count) //мини оптимизация, итеррируемся по короткому списку
|
||||||
{
|
{
|
||||||
@ -681,8 +707,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Except sets</summary>
|
/// <summary>as Except sets</summary>
|
||||||
public void ExceptWith(EcsSpan span)
|
public void ExceptWith(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in span) { ExceptWithStep_Internal(entityID); }
|
foreach (var entityID in span) { ExceptWithStep_Internal(entityID); }
|
||||||
}
|
}
|
||||||
@ -704,8 +732,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Intersect sets</summary>
|
/// <summary>as Intersect sets</summary>
|
||||||
public void IntersectWith(EcsGroup group)
|
public void IntersectWith(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return; }
|
||||||
#endif
|
#endif
|
||||||
for (int i = _count; i > 0; i--)//итерация в обратном порядке исключает ошибки при удалении элементов
|
for (int i = _count; i > 0; i--)//итерация в обратном порядке исключает ошибки при удалении элементов
|
||||||
{
|
{
|
||||||
@ -722,8 +752,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Intersect sets</summary>
|
/// <summary>as Intersect sets</summary>
|
||||||
public void IntersectWith(EcsSpan span)
|
public void IntersectWith(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in span)
|
foreach (var entityID in span)
|
||||||
{
|
{
|
||||||
@ -765,8 +797,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Symmetric Except sets</summary>
|
/// <summary>as Symmetric Except sets</summary>
|
||||||
public void SymmetricExceptWith(EcsGroup group)
|
public void SymmetricExceptWith(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in group) { SymmetricExceptWithStep_Internal(entityID); }
|
foreach (var entityID in group) { SymmetricExceptWithStep_Internal(entityID); }
|
||||||
}
|
}
|
||||||
@ -777,8 +811,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>as Symmetric Except sets</summary>
|
/// <summary>as Symmetric Except sets</summary>
|
||||||
public void SymmetricExceptWith(EcsSpan span)
|
public void SymmetricExceptWith(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in span) { SymmetricExceptWithStep_Internal(entityID); }
|
foreach (var entityID in span) { SymmetricExceptWithStep_Internal(entityID); }
|
||||||
}
|
}
|
||||||
@ -827,8 +863,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region SetEquals
|
#region SetEquals
|
||||||
public bool SetEquals(EcsGroup group)
|
public bool SetEquals(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group.World) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (group.Count != Count) { return false; }
|
if (group.Count != Count) { return false; }
|
||||||
foreach (var entityID in group)
|
foreach (var entityID in group)
|
||||||
@ -844,8 +882,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool SetEquals(EcsReadonlyGroup group) { return SetEquals(group.GetSource_Internal()); }
|
public bool SetEquals(EcsReadonlyGroup group) { return SetEquals(group.GetSource_Internal()); }
|
||||||
public bool SetEquals(EcsSpan span)
|
public bool SetEquals(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (span.Count != Count) { return false; }
|
if (span.Count != Count) { return false; }
|
||||||
foreach (var entityID in span)
|
foreach (var entityID in span)
|
||||||
@ -874,8 +914,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Overlaps
|
#region Overlaps
|
||||||
public bool Overlaps(EcsGroup group)
|
public bool Overlaps(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group.World) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (group.Count > Count)
|
if (group.Count > Count)
|
||||||
{
|
{
|
||||||
@ -903,8 +945,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool Overlaps(EcsReadonlyGroup group) { return Overlaps(group.GetSource_Internal()); }
|
public bool Overlaps(EcsReadonlyGroup group) { return Overlaps(group.GetSource_Internal()); }
|
||||||
public bool Overlaps(EcsSpan span)
|
public bool Overlaps(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
foreach (var entityID in span)
|
foreach (var entityID in span)
|
||||||
{
|
{
|
||||||
@ -931,8 +975,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region IsSubsetOf/IsProperSubsetOf
|
#region IsSubsetOf/IsProperSubsetOf
|
||||||
public bool IsSubsetOf(EcsGroup group)
|
public bool IsSubsetOf(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (Count == 0) { return true; }
|
if (Count == 0) { return true; }
|
||||||
if (group.Count < Count) { return false; }
|
if (group.Count < Count) { return false; }
|
||||||
@ -942,8 +988,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool IsSubsetOf(EcsReadonlyGroup group) { return IsSubsetOf(group.GetSource_Internal()); }
|
public bool IsSubsetOf(EcsReadonlyGroup group) { return IsSubsetOf(group.GetSource_Internal()); }
|
||||||
public bool IsSubsetOf(EcsSpan span)
|
public bool IsSubsetOf(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (Count == 0) { return true; }
|
if (Count == 0) { return true; }
|
||||||
if (span.Count < Count) { return false; }
|
if (span.Count < Count) { return false; }
|
||||||
@ -960,8 +1008,10 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public bool IsProperSubsetOf(EcsGroup group)
|
public bool IsProperSubsetOf(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (Count == 0) { return true; }
|
if (Count == 0) { return true; }
|
||||||
if (group.Count <= Count) { return false; }
|
if (group.Count <= Count) { return false; }
|
||||||
@ -971,8 +1021,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool IsProperSubsetOf(EcsReadonlyGroup group) { return IsProperSubsetOf(group.GetSource_Internal()); }
|
public bool IsProperSubsetOf(EcsReadonlyGroup group) { return IsProperSubsetOf(group.GetSource_Internal()); }
|
||||||
public bool IsProperSubsetOf(EcsSpan span)
|
public bool IsProperSubsetOf(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (Count == 0) { return true; }
|
if (Count == 0) { return true; }
|
||||||
if (span.Count <= Count) { return false; }
|
if (span.Count <= Count) { return false; }
|
||||||
@ -1035,8 +1087,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region IsSupersetOf/IsProperSupersetOf
|
#region IsSupersetOf/IsProperSupersetOf
|
||||||
public bool IsSupersetOf(EcsGroup group)
|
public bool IsSupersetOf(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (group.Count > Count) { return false; }
|
if (group.Count > Count) { return false; }
|
||||||
return IsSupersetOf_Internal(group);
|
return IsSupersetOf_Internal(group);
|
||||||
@ -1045,8 +1099,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool IsSupersetOf(EcsReadonlyGroup group) { return IsSupersetOf(group.GetSource_Internal()); }
|
public bool IsSupersetOf(EcsReadonlyGroup group) { return IsSupersetOf(group.GetSource_Internal()); }
|
||||||
public bool IsSupersetOf(EcsSpan span)
|
public bool IsSupersetOf(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (span.Count > Count) { return false; }
|
if (span.Count > Count) { return false; }
|
||||||
return IsSupersetOf_Internal(span);
|
return IsSupersetOf_Internal(span);
|
||||||
@ -1061,8 +1117,10 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public bool IsProperSupersetOf(EcsGroup group)
|
public bool IsProperSupersetOf(EcsGroup group)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source != group._source) Throw.Group_ArgumentDifferentWorldsException();
|
if (_source != group._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_source != group._source) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (group.Count >= Count) { return false; }
|
if (group.Count >= Count) { return false; }
|
||||||
return IsSupersetOf_Internal(group);
|
return IsSupersetOf_Internal(group);
|
||||||
@ -1071,8 +1129,10 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool IsProperSupersetOf(EcsReadonlyGroup group) { return IsProperSupersetOf(group.GetSource_Internal()); }
|
public bool IsProperSupersetOf(EcsReadonlyGroup group) { return IsProperSupersetOf(group.GetSource_Internal()); }
|
||||||
public bool IsProperSupersetOf(EcsSpan span)
|
public bool IsProperSupersetOf(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_source.ID != span.WorldID) Throw.Group_ArgumentDifferentWorldsException();
|
if (WorldID != span.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (WorldID != span.WorldID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
if (span.Count >= Count) { return false; }
|
if (span.Count >= Count) { return false; }
|
||||||
return IsSupersetOf_Internal(span);
|
return IsSupersetOf_Internal(span);
|
||||||
@ -1129,8 +1189,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Union(EcsGroup a, EcsGroup b)
|
public static EcsGroup Union(EcsGroup a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a._source != b._source) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a._source.GetFreeGroup();
|
EcsGroup result = a._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1153,8 +1215,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Union(EcsSpan a, EcsSpan b)
|
public static EcsGroup Union(EcsSpan a, EcsSpan b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a.World.GetFreeGroup();
|
EcsGroup result = a.World.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1174,8 +1238,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Except(EcsGroup a, EcsGroup b)
|
public static EcsGroup Except(EcsGroup a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a._source != b._source) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a._source.GetFreeGroup();
|
EcsGroup result = a._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1191,8 +1257,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Except(EcsSpan a, EcsGroup b)
|
public static EcsGroup Except(EcsSpan a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b._source.ID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = b._source.GetFreeGroup();
|
EcsGroup result = b._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1208,8 +1276,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Except(EcsSpan a, EcsSpan b)
|
public static EcsGroup Except(EcsSpan a, EcsSpan b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a.World.GetFreeGroup();
|
EcsGroup result = a.World.GetFreeGroup();
|
||||||
result.CopyFrom(a);
|
result.CopyFrom(a);
|
||||||
@ -1229,8 +1299,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Intersect(EcsGroup a, EcsGroup b)
|
public static EcsGroup Intersect(EcsGroup a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a._source != b._source) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a._source.GetFreeGroup();
|
EcsGroup result = a._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1246,8 +1318,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Intersect(EcsSpan a, EcsGroup b)
|
public static EcsGroup Intersect(EcsSpan a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b._source.ID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = b._source.GetFreeGroup();
|
EcsGroup result = b._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1270,8 +1344,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup Intersect(EcsSpan a, EcsSpan b)
|
public static EcsGroup Intersect(EcsSpan a, EcsSpan b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = b.World.GetFreeGroup();
|
EcsGroup result = b.World.GetFreeGroup();
|
||||||
result.CopyFrom(a);
|
result.CopyFrom(a);
|
||||||
@ -1291,8 +1367,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup SymmetricExcept(EcsGroup a, EcsGroup b)
|
public static EcsGroup SymmetricExcept(EcsGroup a, EcsGroup b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a._source != b._source) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a._source != b._source) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a._source.GetFreeGroup();
|
EcsGroup result = a._source.GetFreeGroup();
|
||||||
foreach (var entityID in a)
|
foreach (var entityID in a)
|
||||||
@ -1315,8 +1393,10 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <returns>new group from pool</returns>
|
/// <returns>new group from pool</returns>
|
||||||
public static EcsGroup SymmetricExcept(EcsSpan a, EcsSpan b)
|
public static EcsGroup SymmetricExcept(EcsSpan a, EcsSpan b)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
if (a.WorldID != b.WorldID) { Throw.Group_ArgumentDifferentWorldsException(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (a.WorldID != b.WorldID) { return a.World.GetFreeGroup(); }
|
||||||
#endif
|
#endif
|
||||||
EcsGroup result = a.World.GetFreeGroup();
|
EcsGroup result = a.World.GetFreeGroup();
|
||||||
result.CopyFrom(a);
|
result.CopyFrom(a);
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace DCFApixels.DragonECS
|
using System;
|
||||||
|
|
||||||
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
public static class EcsConsts
|
public static class EcsConsts
|
||||||
{
|
{
|
||||||
@ -23,6 +25,8 @@
|
|||||||
|
|
||||||
public const int MAGIC_PRIME = 314159;
|
public const int MAGIC_PRIME = 314159;
|
||||||
|
|
||||||
|
public const int NULL_ENTITY_ID = 0;
|
||||||
|
public const short NULL_WORLD_ID = 0;
|
||||||
/// meta subgroups
|
/// meta subgroups
|
||||||
|
|
||||||
public const string PACK_GROUP = "_" + FRAMEWORK_NAME + "/_Core";
|
public const string PACK_GROUP = "_" + FRAMEWORK_NAME + "/_Core";
|
||||||
@ -44,27 +48,32 @@
|
|||||||
//TODO заменить ENABLE_DRAGONECS_ASSERT_CHEKS на DEV_MODE и добавить еще PERF_MODE и STAB_MODE
|
//TODO заменить ENABLE_DRAGONECS_ASSERT_CHEKS на DEV_MODE и добавить еще PERF_MODE и STAB_MODE
|
||||||
public static class EcsDefines
|
public static class EcsDefines
|
||||||
{
|
{
|
||||||
public const bool DISABLE_POOLS_EVENTS =
|
public const bool DRAGONECS_ENABLE_DRAGONECS_DEBUGGER =
|
||||||
#if DISABLE_POOLS_EVENTS
|
#if DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
public const bool ENABLE_DRAGONECS_DEBUGGER =
|
public const bool DRAGONECS_DISABLE_POOLS_EVENTS =
|
||||||
#if ENABLE_DRAGONECS_DEBUGGER
|
#if DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
public const bool ENABLE_DRAGONECS_ASSERT_CHEKS =
|
public const bool DRAGONECS_DISABLE_CATH_EXCEPTIONS =
|
||||||
#if ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
|
public const bool DRAGONECS_STABILITY_MODE =
|
||||||
public const bool REFLECTION_DISABLED =
|
#if DRAGONECS_STABILITY_MODE
|
||||||
#if REFLECTION_DISABLED
|
true;
|
||||||
|
#else
|
||||||
|
false;
|
||||||
|
#endif
|
||||||
|
public const bool DRAGONECS_DEEP_DEBUG =
|
||||||
|
#if DRAGONECS_DEEP_DEBUG
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
@ -75,35 +84,46 @@
|
|||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
|
public const bool REFLECTION_DISABLED =
|
||||||
public const bool ENABLE_DUMMY_SPAN =
|
#if REFLECTION_DISABLED
|
||||||
#if ENABLE_DUMMY_SPAN
|
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[Obsolete]
|
||||||
|
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 =
|
public const bool DISABLE_CATH_EXCEPTIONS =
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DISABLE_CATH_EXCEPTIONS
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
|
[Obsolete]
|
||||||
|
public const bool ENABLE_DRAGONECS_ASSERT_CHEKS =
|
||||||
public const bool DRAGONECS_PERF_MODE =
|
#if ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
#if DRAGONECS_PERF_MODE
|
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
public const bool DRAGONECS_STAB_MODE =
|
[Obsolete]
|
||||||
#if DRAGONECS_STAB_MODE
|
public const bool ENABLE_DUMMY_SPAN =
|
||||||
true;
|
#if ENABLE_DUMMY_SPAN
|
||||||
#else
|
|
||||||
false;
|
|
||||||
#endif
|
|
||||||
public const bool DRAGONECS_DEEP_DEBUG =
|
|
||||||
#if DRAGONECS_DEEP_DEBUG
|
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
|
@ -13,39 +13,39 @@ namespace DCFApixels.DragonECS
|
|||||||
using static EcsConsts;
|
using static EcsConsts;
|
||||||
public readonly struct EcsProfilerMarker
|
public readonly struct EcsProfilerMarker
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
public readonly int id;
|
public readonly int id;
|
||||||
#endif
|
#endif
|
||||||
internal EcsProfilerMarker(int id)
|
internal EcsProfilerMarker(int id)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
this.id = id;
|
this.id = id;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
public EcsProfilerMarker(string name)
|
public EcsProfilerMarker(string name)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
id = DebugService.CurrentThreadInstance.RegisterMark(name);
|
id = DebugService.CurrentThreadInstance.RegisterMark(name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Begin()
|
public void Begin()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
|
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void End()
|
public void End()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
DebugService.CurrentThreadInstance.ProfilerMarkEnd(id);
|
DebugService.CurrentThreadInstance.ProfilerMarkEnd(id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public AutoScope Auto()
|
public AutoScope Auto()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
return new AutoScope(id);
|
return new AutoScope(id);
|
||||||
#else
|
#else
|
||||||
return default;
|
return default;
|
||||||
@ -53,13 +53,13 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public readonly ref struct AutoScope
|
public readonly ref struct AutoScope
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
private readonly int _id;
|
private readonly int _id;
|
||||||
#endif
|
#endif
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public AutoScope(int id)
|
public AutoScope(int id)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
_id = id;
|
_id = id;
|
||||||
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
|
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
|
||||||
#endif
|
#endif
|
||||||
@ -67,7 +67,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
DebugService.CurrentThreadInstance.ProfilerMarkEnd(_id);
|
DebugService.CurrentThreadInstance.ProfilerMarkEnd(_id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void PrintWarning(object v)
|
public static void PrintWarning(object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
OnPrint(DEBUG_WARNING_TAG, v);
|
OnPrint(DEBUG_WARNING_TAG, v);
|
||||||
DebugService.CurrentThreadInstance.PrintWarning(v);
|
DebugService.CurrentThreadInstance.PrintWarning(v);
|
||||||
#endif
|
#endif
|
||||||
@ -102,7 +102,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void PrintError(object v)
|
public static void PrintError(object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
OnPrint(DEBUG_ERROR_TAG, v);
|
OnPrint(DEBUG_ERROR_TAG, v);
|
||||||
DebugService.CurrentThreadInstance.PrintError(v);
|
DebugService.CurrentThreadInstance.PrintError(v);
|
||||||
#endif
|
#endif
|
||||||
@ -110,7 +110,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void PrintErrorAndBreak(object v)
|
public static void PrintErrorAndBreak(object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
OnPrint(DEBUG_ERROR_TAG, v);
|
OnPrint(DEBUG_ERROR_TAG, v);
|
||||||
DebugService.CurrentThreadInstance.PrintErrorAndBreak(v);
|
DebugService.CurrentThreadInstance.PrintErrorAndBreak(v);
|
||||||
#endif
|
#endif
|
||||||
@ -118,7 +118,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void PrintPass(object v)
|
public static void PrintPass(object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
OnPrint(DEBUG_PASS_TAG, v);
|
OnPrint(DEBUG_PASS_TAG, v);
|
||||||
DebugService.CurrentThreadInstance.PrintPass(v);
|
DebugService.CurrentThreadInstance.PrintPass(v);
|
||||||
#endif
|
#endif
|
||||||
@ -126,7 +126,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Print()
|
public static void Print()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
OnPrint(string.Empty, null);
|
OnPrint(string.Empty, null);
|
||||||
DebugService.CurrentThreadInstance.Print();
|
DebugService.CurrentThreadInstance.Print();
|
||||||
#endif
|
#endif
|
||||||
@ -134,7 +134,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Print(object v)
|
public static void Print(object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
OnPrint(string.Empty, v);
|
OnPrint(string.Empty, v);
|
||||||
DebugService.CurrentThreadInstance.Print(v);
|
DebugService.CurrentThreadInstance.Print(v);
|
||||||
#endif
|
#endif
|
||||||
@ -142,7 +142,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Print(string tag, object v)
|
public static void Print(string tag, object v)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
OnPrint(tag, v);
|
OnPrint(tag, v);
|
||||||
DebugService.CurrentThreadInstance.Print(tag, v);
|
DebugService.CurrentThreadInstance.Print(tag, v);
|
||||||
#endif
|
#endif
|
||||||
@ -150,7 +150,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void Break()
|
public static void Break()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_DEBUGGER
|
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER
|
||||||
DebugService.CurrentThreadInstance.Break();
|
DebugService.CurrentThreadInstance.Break();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -301,12 +301,12 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Build
|
#region Build
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
private static EcsProfilerMarker _buildMarker = new EcsProfilerMarker("EcsPipeline.Build");
|
private static EcsProfilerMarker _buildMarker = new EcsProfilerMarker("EcsPipeline.Build");
|
||||||
#endif
|
#endif
|
||||||
public EcsPipeline Build()
|
public EcsPipeline Build()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
_buildMarker.Begin();
|
_buildMarker.Begin();
|
||||||
#endif
|
#endif
|
||||||
var it = new LinkedListIterator<SystemNode>(_systemNodes, _systemNodesCount, _startIndex);
|
var it = new LinkedListIterator<SystemNode>(_systemNodes, _systemNodesCount, _startIndex);
|
||||||
@ -372,7 +372,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
item.Declare(pipeline);
|
item.Declare(pipeline);
|
||||||
}
|
}
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
_buildMarker.End();
|
_buildMarker.End();
|
||||||
#endif
|
#endif
|
||||||
return pipeline;
|
return pipeline;
|
||||||
|
@ -45,7 +45,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private bool _isInit = false;
|
private bool _isInit = false;
|
||||||
private bool _isDestoryed = false;
|
private bool _isDestoryed = false;
|
||||||
|
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
private static EcsProfilerMarker _initMarker = new EcsProfilerMarker("EcsPipeline.Init");
|
private static EcsProfilerMarker _initMarker = new EcsProfilerMarker("EcsPipeline.Init");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ namespace DCFApixels.DragonECS
|
|||||||
EcsDebug.PrintWarning($"This {nameof(EcsPipeline)} has already been initialized");
|
EcsDebug.PrintWarning($"This {nameof(EcsPipeline)} has already been initialized");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
_initMarker.Begin();
|
_initMarker.Begin();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ namespace DCFApixels.DragonECS
|
|||||||
_isInit = true;
|
_isInit = true;
|
||||||
|
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
_initMarker.End();
|
_initMarker.End();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Run)); }
|
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Run)); }
|
||||||
if (_isDestoryed) { Throw.Pipeline_MethodCalledAfterDestruction(nameof(Run)); }
|
if (_isDestoryed) { Throw.Pipeline_MethodCalledAfterDestruction(nameof(Run)); }
|
||||||
#endif
|
#endif
|
||||||
@ -215,7 +215,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void Destroy()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Destroy)); }
|
if (!_isInit) { Throw.Pipeline_MethodCalledBeforeInitialisation(nameof(Destroy)); }
|
||||||
#endif
|
#endif
|
||||||
if (_isDestoryed)
|
if (_isDestoryed)
|
||||||
|
@ -210,7 +210,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -226,7 +226,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -249,7 +249,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -265,7 +265,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -375,7 +375,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -398,7 +398,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -429,7 +429,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
@ -452,7 +452,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
#if DISABLE_CATH_EXCEPTIONS
|
#if DRAGONECS_DISABLE_CATH_EXCEPTIONS
|
||||||
throw;
|
throw;
|
||||||
#endif
|
#endif
|
||||||
EcsDebug.PrintError(e);
|
EcsDebug.PrintError(e);
|
||||||
|
@ -342,15 +342,19 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Inc/Exc/Combine/Except
|
#region Inc/Exc/Combine/Except
|
||||||
public void Inc(EcsTypeCode typeCode)
|
public void Inc(EcsTypeCode typeCode)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(typeCode); }
|
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(typeCode); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { return; }
|
||||||
#endif
|
#endif
|
||||||
_inc.Add(typeCode);
|
_inc.Add(typeCode);
|
||||||
}
|
}
|
||||||
public void Exc(EcsTypeCode typeCode)
|
public void Exc(EcsTypeCode typeCode)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(typeCode); }
|
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { Throw.ConstraintIsAlreadyContainedInMask(typeCode); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_inc.Contains(typeCode) || _exc.Contains(typeCode)) { return; }
|
||||||
#endif
|
#endif
|
||||||
_exc.Add(typeCode);
|
_exc.Add(typeCode);
|
||||||
}
|
}
|
||||||
|
@ -331,8 +331,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public int NewEntity(int entityID)
|
public int NewEntity(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (entityID < _entities.Length && IsUsed(entityID)) { Throw.World_EntityIsAlreadyСontained(entityID); }
|
if (IsUsed(entityID)) { Throw.World_EntityIsAlreadyСontained(entityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsUsed(entityID)) { return 0; }
|
||||||
#endif
|
#endif
|
||||||
_entityDispenser.Use(entityID);
|
_entityDispenser.Use(entityID);
|
||||||
CreateConcreteEntity(entityID);
|
CreateConcreteEntity(entityID);
|
||||||
@ -381,8 +383,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void DelEntity(int entityID)
|
public void DelEntity(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (IsUsed(entityID) == false) { Throw.World_EntityIsNotContained(entityID); }
|
if (IsUsed(entityID) == false) { Throw.World_EntityIsAlreadyСontained(entityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsUsed(entityID) == false) { return; }
|
||||||
#endif
|
#endif
|
||||||
UpVersion();
|
UpVersion();
|
||||||
_delEntBuffer[_delEntBufferCount++] = entityID;
|
_delEntBuffer[_delEntBufferCount++] = entityID;
|
||||||
@ -411,8 +415,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void InitEntitySlot(int entityID, short gen)
|
public void InitEntitySlot(int entityID, short gen)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
|
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (Count > 0) { return; }
|
||||||
#endif
|
#endif
|
||||||
_entityDispenser.Upsize(entityID);
|
_entityDispenser.Upsize(entityID);
|
||||||
_entities[entityID].gen = gen;
|
_entities[entityID].gen = gen;
|
||||||
@ -431,8 +437,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool IsAlive(entlong entity)
|
public bool IsAlive(entlong entity)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (entity.GetWorldIDUnchecked() != ID) { Throw.World_MaskDoesntBelongWorld(); }
|
if (entity.GetWorldIDUnchecked() != ID) { Throw.World_MaskDoesntBelongWorld(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (entity.GetWorldIDUnchecked() != ID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
ref var slot = ref _entities[entity.GetIDUnchecked()];
|
ref var slot = ref _entities[entity.GetIDUnchecked()];
|
||||||
return slot.gen == entity.GetIDUnchecked() && slot.isUsed;
|
return slot.gen == entity.GetIDUnchecked() && slot.isUsed;
|
||||||
@ -468,8 +476,10 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public bool IsMatchesMask(EcsMask mask, int entityID)
|
public bool IsMatchesMask(EcsMask mask, int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (mask.WorldID != ID) { Throw.World_MaskDoesntBelongWorld(); }
|
if (mask.WorldID != ID) { Throw.World_MaskDoesntBelongWorld(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (mask.WorldID != ID) { return false; }
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0, iMax = mask._incs.Length; i < iMax; i++)
|
for (int i = 0, iMax = mask._incs.Length; i < iMax; i++)
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ namespace DCFApixels.DragonECS
|
|||||||
internal PoolSlot[] _poolSlots;
|
internal PoolSlot[] _poolSlots;
|
||||||
private int _poolsCount;
|
private int _poolsCount;
|
||||||
|
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
private int _lockedPoolCount = 0;
|
private int _lockedPoolCount = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -152,8 +152,10 @@ namespace DCFApixels.DragonECS
|
|||||||
#region FindOrAutoCreatePool/InitPool
|
#region FindOrAutoCreatePool/InitPool
|
||||||
public void InitPool(IEcsPoolImplementation poolImplementation)
|
public void InitPool(IEcsPoolImplementation poolImplementation)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
|
if (Count > 0) { Throw.World_MethodCalledAfterEntityCreation(nameof(InitEntitySlot)); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (Count > 0) { return; }
|
||||||
#endif
|
#endif
|
||||||
InitPool_Internal(poolImplementation);
|
InitPool_Internal(poolImplementation);
|
||||||
}
|
}
|
||||||
@ -165,7 +167,7 @@ namespace DCFApixels.DragonECS
|
|||||||
if (_poolTypeCode_2_CmpTypeIDs.TryGetValue(poolTypeCode, out int cmpTypeID))
|
if (_poolTypeCode_2_CmpTypeIDs.TryGetValue(poolTypeCode, out int cmpTypeID))
|
||||||
{
|
{
|
||||||
var pool = _pools[cmpTypeID];
|
var pool = _pools[cmpTypeID];
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
if ((pool is TPool) == false) { Throw.UndefinedException(); }
|
if ((pool is TPool) == false) { Throw.UndefinedException(); }
|
||||||
#endif
|
#endif
|
||||||
return (TPool)pool;
|
return (TPool)pool;
|
||||||
@ -282,11 +284,12 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
DelEntity(entityID);
|
DelEntity(entityID);
|
||||||
}
|
}
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
CheckUnregisterValid(count, entityID);
|
||||||
if (count < 0) Throw.World_InvalidIncrementComponentsBalance();
|
}
|
||||||
#endif
|
private Span<int> GetEntityComponentMask(int entityID)
|
||||||
|
{
|
||||||
|
return new Span<int>(_entityComponentMasks, entityID << _entityComponentMaskLengthBitShift, _entityComponentMaskLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private bool TryRegisterEntityComponent(int entityID, int componentTypeID, EcsMaskChunck maskBit)
|
private bool TryRegisterEntityComponent(int entityID, int componentTypeID, EcsMaskChunck maskBit)
|
||||||
@ -323,13 +326,26 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
DelEntity(entityID);
|
DelEntity(entityID);
|
||||||
}
|
}
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
CheckUnregisterValid(count, entityID);
|
||||||
if (count < 0) Throw.World_InvalidIncrementComponentsBalance();
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
private void CheckUnregisterValid(int count, int entityID)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
if (count < 0) { Throw.World_InvalidIncrementComponentsBalance(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (count < 0)
|
||||||
|
{
|
||||||
|
var mask = GetEntityComponentMask(entityID);
|
||||||
|
for (int i = 0; i < mask.Length; i++) { mask[i] = 0; }
|
||||||
|
//TODO добавить очистку пулов
|
||||||
|
_entities[entityID].componentsCount = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private int GetPoolComponentCount(int componentTypeID)
|
private int GetPoolComponentCount(int componentTypeID)
|
||||||
@ -402,7 +418,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#region LockPool/UnLockPool
|
#region LockPool/UnLockPool
|
||||||
public void LockPool_Debug(int componentTypeID)
|
public void LockPool_Debug(int componentTypeID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
ref var slot = ref _poolSlots[componentTypeID];
|
ref var slot = ref _poolSlots[componentTypeID];
|
||||||
if (slot.lockedCounter == 0)
|
if (slot.lockedCounter == 0)
|
||||||
{
|
{
|
||||||
@ -416,7 +432,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void UnlockPool_Debug(int componentTypeID)
|
public void UnlockPool_Debug(int componentTypeID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
ref var slot = ref _poolSlots[componentTypeID];
|
ref var slot = ref _poolSlots[componentTypeID];
|
||||||
slot.lockedCounter--;
|
slot.lockedCounter--;
|
||||||
if (slot.lockedCounter <= 0)
|
if (slot.lockedCounter <= 0)
|
||||||
@ -434,7 +450,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public bool CheckPoolLocked_Debug(int componentTypeID)
|
public bool CheckPoolLocked_Debug(int componentTypeID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
return _poolSlots[componentTypeID].lockedCounter != 0;
|
return _poolSlots[componentTypeID].lockedCounter != 0;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
@ -447,7 +463,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
public long version;
|
public long version;
|
||||||
public int count;
|
public int count;
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
public int lockedCounter;
|
public int lockedCounter;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,15 @@ namespace DCFApixels.DragonECS
|
|||||||
{// ts
|
{// ts
|
||||||
return _worlds[worldID];
|
return _worlds[worldID];
|
||||||
}
|
}
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public static bool TryGetWorld(short worldID, out EcsWorld world)
|
||||||
|
{// ts
|
||||||
|
world = _worlds[worldID];
|
||||||
|
return
|
||||||
|
world != null &&
|
||||||
|
world.IsDestroyed != false &&
|
||||||
|
worldID != 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void ReleaseData(short worldID)
|
private void ReleaseData(short worldID)
|
||||||
{// ts
|
{// ts
|
||||||
@ -146,7 +155,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static ref T GetForWorldUnchecked(short worldID)
|
public static ref T GetForWorldUnchecked(short worldID)
|
||||||
{// ts
|
{// ts
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_mapping[worldID] <= 0) { Throw.ArgumentOutOfRange(); }
|
if (_mapping[worldID] <= 0) { Throw.ArgumentOutOfRange(); }
|
||||||
#endif
|
#endif
|
||||||
return ref _items[_mapping[worldID]];
|
return ref _items[_mapping[worldID]];
|
||||||
|
@ -74,7 +74,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ExecuteFor_Iternal(EcsSpan span)
|
private void ExecuteFor_Iternal(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
|
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
|
||||||
if (span.WorldID != World.ID) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
if (span.WorldID != World.ID) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,7 +73,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void ExecuteFor_Iternal(EcsSpan span)
|
private void ExecuteFor_Iternal(EcsSpan span)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG || DRAGONECS_STABILITY_MODE
|
||||||
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
|
if (span.IsNull) { Throw.ArgumentNull(nameof(span)); }
|
||||||
if (span.WorldID != World.ID) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
if (span.WorldID != World.ID) { Throw.Quiery_ArgumentDifferentWorldsException(); }
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,7 +16,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private Dictionary<Type, InjectionNodeBase> _nodes = new Dictionary<Type, InjectionNodeBase>(32);
|
private Dictionary<Type, InjectionNodeBase> _nodes = new Dictionary<Type, InjectionNodeBase>(32);
|
||||||
private bool _isInit = false;
|
private bool _isInit = false;
|
||||||
|
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
private HashSet<Type> _requiredInjectionTypes = new HashSet<Type>();
|
private HashSet<Type> _requiredInjectionTypes = new HashSet<Type>();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ namespace DCFApixels.DragonECS
|
|||||||
branch = new InjectionBranch(this, objType);
|
branch = new InjectionBranch(this, objType);
|
||||||
InitBranch(branch);
|
InitBranch(branch);
|
||||||
|
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
foreach (var requiredInjectionType in _requiredInjectionTypes)
|
foreach (var requiredInjectionType in _requiredInjectionTypes)
|
||||||
{
|
{
|
||||||
if (requiredInjectionType.IsAssignableFrom(objType))
|
if (requiredInjectionType.IsAssignableFrom(objType))
|
||||||
@ -144,7 +144,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
_isInit = true;
|
_isInit = true;
|
||||||
|
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
var systems = _pipeline.AllSystems;
|
var systems = _pipeline.AllSystems;
|
||||||
var injectType = typeof(IEcsInject<>);
|
var injectType = typeof(IEcsInject<>);
|
||||||
foreach (var system in systems)
|
foreach (var system in systems)
|
||||||
|
@ -39,8 +39,8 @@ namespace DCFApixels.DragonECS
|
|||||||
private int _componentTypeID;
|
private int _componentTypeID;
|
||||||
private EcsMaskChunck _maskBit;
|
private EcsMaskChunck _maskBit;
|
||||||
|
|
||||||
private int[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID
|
private int[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID.
|
||||||
private T[] _items; //dense
|
private T[] _items; // dense; _items[0] - fake component.
|
||||||
private int _itemsCount = 0;
|
private int _itemsCount = 0;
|
||||||
private int[] _recycledItems;
|
private int[] _recycledItems;
|
||||||
private int _recycledItemsCount = 0;
|
private int _recycledItemsCount = 0;
|
||||||
@ -50,7 +50,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private readonly IEcsComponentCopy<T> _componentCopyHandler = EcsComponentCopyHandler<T>.instance;
|
private readonly IEcsComponentCopy<T> _componentCopyHandler = EcsComponentCopyHandler<T>.instance;
|
||||||
private readonly bool _isHasComponentCopyHandler = EcsComponentCopyHandler<T>.isHasHandler;
|
private readonly bool _isHasComponentCopyHandler = EcsComponentCopyHandler<T>.isHasHandler;
|
||||||
|
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
private StructList<IEcsPoolEventListener> _listeners = new StructList<IEcsPoolEventListener>(2);
|
private StructList<IEcsPoolEventListener> _listeners = new StructList<IEcsPoolEventListener>(2);
|
||||||
private int _listenersCachedCount = 0;
|
private int _listenersCachedCount = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -94,9 +94,12 @@ namespace DCFApixels.DragonECS
|
|||||||
public ref T Add(int entityID)
|
public ref T Add(int entityID)
|
||||||
{
|
{
|
||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
if (itemIndex > 0) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (itemIndex > 0) { return ref Get(entityID); }
|
||||||
|
if (_isLocked) { return ref _items[0]; }
|
||||||
#endif
|
#endif
|
||||||
if (_recycledItemsCount > 0)
|
if (_recycledItemsCount > 0)
|
||||||
{
|
{
|
||||||
@ -114,7 +117,7 @@ namespace DCFApixels.DragonECS
|
|||||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
ref T result = ref _items[itemIndex];
|
ref T result = ref _items[itemIndex];
|
||||||
EnableComponent(ref result);
|
EnableComponent(ref result);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnAddAndGet(entityID, _listenersCachedCount);
|
_listeners.InvokeOnAddAndGet(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
return ref result;
|
return ref result;
|
||||||
@ -122,10 +125,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref T Get(int entityID)
|
public ref T Get(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG // íå íóæåí STAB_MODE
|
||||||
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnGet(entityID, _listenersCachedCount);
|
_listeners.InvokeOnGet(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
return ref _items[_mapping[entityID]];
|
return ref _items[_mapping[entityID]];
|
||||||
@ -133,7 +136,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref readonly T Read(int entityID)
|
public ref readonly T Read(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG // íå íóæåí STAB_MODE
|
||||||
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
return ref _items[_mapping[entityID]];
|
return ref _items[_mapping[entityID]];
|
||||||
@ -143,8 +146,10 @@ namespace DCFApixels.DragonECS
|
|||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
if (itemIndex <= 0)
|
if (itemIndex <= 0)
|
||||||
{ //Add block
|
{ //Add block
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_isLocked) { return ref _items[0]; }
|
||||||
#endif
|
#endif
|
||||||
if (_recycledItemsCount > 0)
|
if (_recycledItemsCount > 0)
|
||||||
{
|
{
|
||||||
@ -161,11 +166,11 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
EnableComponent(ref _items[itemIndex]);
|
EnableComponent(ref _items[itemIndex]);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnAdd(entityID, _listenersCachedCount);
|
_listeners.InvokeOnAdd(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
} //Add block end
|
} //Add block end
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnGet(entityID, _listenersCachedCount);
|
_listeners.InvokeOnGet(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
return ref _items[itemIndex];
|
return ref _items[itemIndex];
|
||||||
@ -177,12 +182,13 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void Del(int entityID)
|
public void Del(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
|
||||||
#endif
|
|
||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (itemIndex <= 0) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (itemIndex <= 0) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (itemIndex <= 0) { return; }
|
||||||
|
if (_isLocked) { return; }
|
||||||
#endif
|
#endif
|
||||||
DisableComponent(ref _items[itemIndex]);
|
DisableComponent(ref _items[itemIndex]);
|
||||||
if (_recycledItemsCount >= _recycledItems.Length)
|
if (_recycledItemsCount >= _recycledItems.Length)
|
||||||
@ -193,7 +199,7 @@ namespace DCFApixels.DragonECS
|
|||||||
itemIndex = 0;
|
itemIndex = 0;
|
||||||
_itemsCount--;
|
_itemsCount--;
|
||||||
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -206,23 +212,29 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void Copy(int fromEntityID, int toEntityID)
|
public void Copy(int fromEntityID, int toEntityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (!Has(fromEntityID)) { return; }
|
||||||
#endif
|
#endif
|
||||||
CopyComponent(ref Get(fromEntityID), ref TryAddOrGet(toEntityID));
|
CopyComponent(ref Get(fromEntityID), ref TryAddOrGet(toEntityID));
|
||||||
}
|
}
|
||||||
public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
|
public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (!Has(fromEntityID)) { return; }
|
||||||
#endif
|
#endif
|
||||||
CopyComponent(ref Get(fromEntityID), ref toWorld.GetPool<T>().TryAddOrGet(toEntityID));
|
CopyComponent(ref Get(fromEntityID), ref toWorld.GetPool<T>().TryAddOrGet(toEntityID));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearAll()
|
public void ClearAll()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_isLocked) { return; }
|
||||||
#endif
|
#endif
|
||||||
_recycledItemsCount = 0; // ñïåðåäè ïîòîìó ÷òîáû îáíóëÿëîñü, òàê êàê Del íå îáíóëÿåò
|
_recycledItemsCount = 0; // ñïåðåäè ïîòîìó ÷òîáû îáíóëÿëîñü, òàê êàê Del íå îáíóëÿåò
|
||||||
if (_itemsCount <= 0) { return; }
|
if (_itemsCount <= 0) { return; }
|
||||||
@ -234,7 +246,7 @@ namespace DCFApixels.DragonECS
|
|||||||
DisableComponent(ref _items[itemIndex]);
|
DisableComponent(ref _items[itemIndex]);
|
||||||
itemIndex = 0;
|
itemIndex = 0;
|
||||||
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -290,7 +302,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Listeners
|
#region Listeners
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
public void AddListener(IEcsPoolEventListener listener)
|
public void AddListener(IEcsPoolEventListener listener)
|
||||||
{
|
{
|
||||||
if (listener == null) { EcsPoolThrowHelper.ThrowNullListener(); }
|
if (listener == null) { EcsPoolThrowHelper.ThrowNullListener(); }
|
||||||
|
@ -164,7 +164,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Listeners
|
#region Listeners
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
void IEcsReadonlyPool.AddListener(IEcsPoolEventListener listener) { }
|
void IEcsReadonlyPool.AddListener(IEcsPoolEventListener listener) { }
|
||||||
void IEcsReadonlyPool.RemoveListener(IEcsPoolEventListener listener) { }
|
void IEcsReadonlyPool.RemoveListener(IEcsPoolEventListener listener) { }
|
||||||
#endif
|
#endif
|
||||||
@ -193,7 +193,7 @@ namespace DCFApixels.DragonECS
|
|||||||
void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID);
|
void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
#region Add/Remove Listeners
|
#region Add/Remove Listeners
|
||||||
void AddListener(IEcsPoolEventListener listener);
|
void AddListener(IEcsPoolEventListener listener);
|
||||||
void RemoveListener(IEcsPoolEventListener listener);
|
void RemoveListener(IEcsPoolEventListener listener);
|
||||||
@ -262,7 +262,7 @@ namespace DCFApixels.DragonECS
|
|||||||
/// <summary>Called after deleting an entity from the pool</summary>
|
/// <summary>Called after deleting an entity from the pool</summary>
|
||||||
void OnDel(int entityID);
|
void OnDel(int entityID);
|
||||||
}
|
}
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
public static class PoolEventListExtensions
|
public static class PoolEventListExtensions
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
#endif
|
#endif
|
||||||
using DCFApixels.DragonECS.Core;
|
using DCFApixels.DragonECS.Core;
|
||||||
|
using DCFApixels.DragonECS.Internal;
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
using DCFApixels.DragonECS.PoolsCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using DCFApixels.DragonECS.Internal;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
#if ENABLE_IL2CPP
|
#if ENABLE_IL2CPP
|
||||||
using Unity.IL2CPP.CompilerServices;
|
using Unity.IL2CPP.CompilerServices;
|
||||||
#endif
|
#endif
|
||||||
@ -42,7 +42,7 @@ namespace DCFApixels.DragonECS
|
|||||||
private bool[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID
|
private bool[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID
|
||||||
private int _count = 0;
|
private int _count = 0;
|
||||||
|
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
private StructList<IEcsPoolEventListener> _listeners = new StructList<IEcsPoolEventListener>(2);
|
private StructList<IEcsPoolEventListener> _listeners = new StructList<IEcsPoolEventListener>(2);
|
||||||
private int _listenersCachedCount = 0;
|
private int _listenersCachedCount = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -103,14 +103,16 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Method
|
#region Method
|
||||||
public void Add(int entityID)
|
public void Add(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID)) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
if (Has(entityID)) { EcsPoolThrowHelper.ThrowAlreadyHasComponent<T>(entityID); }
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (Has(entityID) || _isLocked) { return; }
|
||||||
#endif
|
#endif
|
||||||
_count++;
|
_count++;
|
||||||
_mapping[entityID] = true;
|
_mapping[entityID] = true;
|
||||||
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.RegisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnAdd(entityID, _listenersCachedCount);
|
_listeners.InvokeOnAdd(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -128,14 +130,16 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void Del(int entityID)
|
public void Del(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (!Has(entityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (!Has(entityID) || _isLocked) { return; }
|
||||||
#endif
|
#endif
|
||||||
_mapping[entityID] = false;
|
_mapping[entityID] = false;
|
||||||
_count--;
|
_count--;
|
||||||
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -149,15 +153,19 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public void Copy(int fromEntityID, int toEntityID)
|
public void Copy(int fromEntityID, int toEntityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (!Has(fromEntityID)) { return; }
|
||||||
#endif
|
#endif
|
||||||
TryAdd(toEntityID);
|
TryAdd(toEntityID);
|
||||||
}
|
}
|
||||||
public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
|
public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
if (!Has(fromEntityID)) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(fromEntityID); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (!Has(fromEntityID)) { return; }
|
||||||
#endif
|
#endif
|
||||||
toWorld.GetPool<T>().TryAdd(toEntityID);
|
toWorld.GetPool<T>().TryAdd(toEntityID);
|
||||||
}
|
}
|
||||||
@ -189,8 +197,10 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
public void ClearAll()
|
public void ClearAll()
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
if (_isLocked) { EcsPoolThrowHelper.ThrowPoolLocked(); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (_isLocked) { return; }
|
||||||
#endif
|
#endif
|
||||||
if (_count <= 0) { return; }
|
if (_count <= 0) { return; }
|
||||||
var span = _source.Where(out SingleTagAspect<T> _);
|
var span = _source.Where(out SingleTagAspect<T> _);
|
||||||
@ -199,7 +209,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
_mapping[entityID] = false;
|
_mapping[entityID] = false;
|
||||||
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
_mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit);
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
_listeners.InvokeOnDel(entityID, _listenersCachedCount);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -245,14 +255,14 @@ namespace DCFApixels.DragonECS
|
|||||||
void IEcsPool.AddRaw(int entityID, object dataRaw) { Add(entityID); }
|
void IEcsPool.AddRaw(int entityID, object dataRaw) { Add(entityID); }
|
||||||
object IEcsReadonlyPool.GetRaw(int entityID)
|
object IEcsReadonlyPool.GetRaw(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
return _fakeComponent;
|
return _fakeComponent;
|
||||||
}
|
}
|
||||||
void IEcsPool.SetRaw(int entityID, object dataRaw)
|
void IEcsPool.SetRaw(int entityID, object dataRaw)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -263,14 +273,14 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
ref readonly T IEcsStructPool<T>.Read(int entityID)
|
ref readonly T IEcsStructPool<T>.Read(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
return ref _fakeComponent;
|
return ref _fakeComponent;
|
||||||
}
|
}
|
||||||
ref T IEcsStructPool<T>.Get(int entityID)
|
ref T IEcsStructPool<T>.Get(int entityID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
if (Has(entityID) == false) { EcsPoolThrowHelper.ThrowNotHaveComponent<T>(entityID); }
|
||||||
#endif
|
#endif
|
||||||
return ref _fakeComponent;
|
return ref _fakeComponent;
|
||||||
@ -278,7 +288,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Listeners
|
#region Listeners
|
||||||
#if !DISABLE_POOLS_EVENTS
|
#if !DRAGONECS_DISABLE_POOLS_EVENTS
|
||||||
public void AddListener(IEcsPoolEventListener listener)
|
public void AddListener(IEcsPoolEventListener listener)
|
||||||
{
|
{
|
||||||
if (listener == null) { EcsPoolThrowHelper.ThrowNullListener(); }
|
if (listener == null) { EcsPoolThrowHelper.ThrowNullListener(); }
|
||||||
|
@ -59,8 +59,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false) { return EcsConsts.NULL_ENTITY_ID; }
|
||||||
#endif
|
#endif
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
@ -70,8 +72,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false) { return default; }
|
||||||
#endif
|
#endif
|
||||||
return _gen;
|
return _gen;
|
||||||
}
|
}
|
||||||
@ -81,8 +85,8 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
#endif
|
#endif
|
||||||
return GetWorld_Internal();
|
return GetWorld_Internal();
|
||||||
}
|
}
|
||||||
@ -92,8 +96,10 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false) { return EcsConsts.NULL_WORLD_ID; }
|
||||||
#endif
|
#endif
|
||||||
return _world;
|
return _world;
|
||||||
}
|
}
|
||||||
@ -144,8 +150,15 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Unpack(out int id, out EcsWorld world)
|
public void Unpack(out int id, out EcsWorld world)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false)
|
||||||
|
{
|
||||||
|
world = EcsWorld.GetWorld(EcsConsts.NULL_WORLD_ID);
|
||||||
|
id = EcsConsts.NULL_ENTITY_ID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
world = EcsWorld.GetWorld(_world);
|
world = EcsWorld.GetWorld(_world);
|
||||||
id = _id;
|
id = _id;
|
||||||
@ -153,8 +166,16 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Unpack(out int id, out short gen, out EcsWorld world)
|
public void Unpack(out int id, out short gen, out EcsWorld world)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false)
|
||||||
|
{
|
||||||
|
world = EcsWorld.GetWorld(EcsConsts.NULL_WORLD_ID);
|
||||||
|
gen = default;
|
||||||
|
id = EcsConsts.NULL_ENTITY_ID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
world = EcsWorld.GetWorld(_world);
|
world = EcsWorld.GetWorld(_world);
|
||||||
gen = _gen;
|
gen = _gen;
|
||||||
@ -163,8 +184,15 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Unpack(out int id, out short worldID)
|
public void Unpack(out int id, out short worldID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false)
|
||||||
|
{
|
||||||
|
worldID = EcsConsts.NULL_WORLD_ID;
|
||||||
|
id = EcsConsts.NULL_ENTITY_ID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
worldID = _world;
|
worldID = _world;
|
||||||
id = _id;
|
id = _id;
|
||||||
@ -172,8 +200,16 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Unpack(out int id, out short gen, out short worldID)
|
public void Unpack(out int id, out short gen, out short worldID)
|
||||||
{
|
{
|
||||||
#if DEBUG || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if DEBUG
|
||||||
if (!IsAlive) { Throw.Ent_ThrowIsNotAlive(this); }
|
if (IsAlive == false) { Throw.Ent_ThrowIsNotAlive(this); }
|
||||||
|
#elif DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false)
|
||||||
|
{
|
||||||
|
worldID = EcsConsts.NULL_WORLD_ID;
|
||||||
|
gen = default;
|
||||||
|
id = EcsConsts.NULL_ENTITY_ID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
worldID = _world;
|
worldID = _world;
|
||||||
gen = _gen;
|
gen = _gen;
|
||||||
@ -296,7 +332,13 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
#region Other
|
#region Other
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private EcsWorld GetWorld_Internal() { return EcsWorld.GetWorld(_world); }
|
private EcsWorld GetWorld_Internal()
|
||||||
|
{
|
||||||
|
#if DRAGONECS_STABILITY_MODE
|
||||||
|
if (IsAlive == false) { EcsWorld.GetWorld(EcsConsts.NULL_WORLD_ID); }
|
||||||
|
#endif
|
||||||
|
return EcsWorld.GetWorld(_world);
|
||||||
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public override int GetHashCode() { return unchecked((int)_full) ^ (int)(_full >> 32); }
|
public override int GetHashCode() { return unchecked((int)_full) ^ (int)(_full >> 32); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
Loading…
Reference in New Issue
Block a user