This commit is contained in:
DCFApixels 2025-05-21 23:00:48 +08:00
parent 71bf7064e1
commit 2771d628d6
12 changed files with 15 additions and 37 deletions

View File

@ -279,7 +279,6 @@ namespace DCFApixels.DragonECS
[Il2CppSetOption(Option.ArrayBoundsChecks, false)] [Il2CppSetOption(Option.ArrayBoundsChecks, false)]
#endif #endif
[DebuggerTypeProxy(typeof(DebuggerProxy))] [DebuggerTypeProxy(typeof(DebuggerProxy))]
//TODO переработать EcsGroup в структуру-обертку, чтобы когда вызывается Release то можно было занулить эту структуру, а может не перерабатывать, есть проблема с боксингом
public unsafe class EcsGroup : IDisposable, IEnumerable<int>, ISet<int>, IEntityStorage public unsafe class EcsGroup : IDisposable, IEnumerable<int>, ISet<int>, IEntityStorage
{ {
internal const int PAGE_SIZE = PageSlot.SIZE; internal const int PAGE_SIZE = PageSlot.SIZE;

View File

@ -410,7 +410,6 @@ namespace DCFApixels.DragonECS.Core
{ {
self.Print(""); self.Print("");
} }
//TODO PrintJson возможно будет добавлено когда-то
} }
#endregion #endregion

View File

@ -431,12 +431,10 @@ namespace DCFApixels.DragonECS
{ {
public readonly short worldID; public readonly short worldID;
public readonly EcsMaskIterator.Enumerable iterator; public readonly EcsMaskIterator.Enumerable iterator;
private EcsSpan _span;
public Iterator(EcsMaskIterator iterator, EcsSpan span) public Iterator(EcsMaskIterator iterator, EcsSpan span)
{ {
worldID = iterator.World.ID; worldID = iterator.World.ID;
_span = span;
this.iterator = iterator.Iterate(span); this.iterator = iterator.Iterate(span);
} }

View File

@ -536,10 +536,6 @@ namespace DCFApixels.DragonECS
#endif #endif
public class EcsMaskIterator : IDisposable public class EcsMaskIterator : IDisposable
{ {
// TODO есть идея перенести эти ChunckBuffer-ы в стек,
// для этого нужно проработать дизайн так чтобы память в стеке выделялась за пределами итератора и GetEnumerator,
// а далее передавались поинтеры, в противном случае использовался бы стандартный подход
public readonly EcsWorld World; public readonly EcsWorld World;
public readonly EcsMask Mask; public readonly EcsMask Mask;
@ -644,7 +640,6 @@ namespace DCFApixels.DragonECS
UnsafeArraySortHalperX<int>.InsertionSort(sortIncBuffer.ptr, sortIncBuffer.Length, ref comparer); UnsafeArraySortHalperX<int>.InsertionSort(sortIncBuffer.ptr, sortIncBuffer.Length, ref comparer);
ConvertToChuncks(preSortingBuffer, sortIncBuffer, _sortIncChunckBuffer); ConvertToChuncks(preSortingBuffer, sortIncBuffer, _sortIncChunckBuffer);
} }
if (_sortIncChunckBuffer.Length > 0) if (_sortIncChunckBuffer.Length > 0)
{ {
maxEntites = counts[_sortIncBuffer.ptr[0]].count; maxEntites = counts[_sortIncBuffer.ptr[0]].count;
@ -667,11 +662,12 @@ namespace DCFApixels.DragonECS
if (_sortAnyChunckBuffer.Length > 1) if (_sortAnyChunckBuffer.Length > 1)
{ {
//TODO проверить для Any
ExcCountComparer comparer = new ExcCountComparer(counts); ExcCountComparer comparer = new ExcCountComparer(counts);
UnsafeArraySortHalperX<int>.InsertionSort(sortAnyBuffer.ptr, sortAnyBuffer.Length, ref comparer); UnsafeArraySortHalperX<int>.InsertionSort(sortAnyBuffer.ptr, sortAnyBuffer.Length, ref comparer);
ConvertToChuncks(preSortingBuffer, sortAnyBuffer, _sortAnyChunckBuffer); ConvertToChuncks(preSortingBuffer, sortAnyBuffer, _sortAnyChunckBuffer);
} }
// Any не влияет на maxEntites если есть Inc и сложно высчитывается если нет Inc
return maxEntites; return maxEntites;
} }
private unsafe bool TryGetEntityStorage(out IEntityStorage storage) private unsafe bool TryGetEntityStorage(out IEntityStorage storage)
@ -759,6 +755,7 @@ namespace DCFApixels.DragonECS
{ {
private readonly EcsMaskIterator _iterator; private readonly EcsMaskIterator _iterator;
private readonly EcsSpan _span; private readonly EcsSpan _span;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Enumerable(EcsMaskIterator iterator, EcsSpan span) public Enumerable(EcsMaskIterator iterator, EcsSpan span)
{ {
_iterator = iterator; _iterator = iterator;
@ -879,28 +876,23 @@ namespace DCFApixels.DragonECS
} }
} }
//можно подумать над оптимизацией через кеширование bool значения, if с bool работает быстрее прочего if(_sortAnyChunckBuffer.Length != 0)
if(_sortAnyChunckBuffer.Length > 0)
{ {
int anyCount = 0;
for (int i = 0; i < _sortAnyChunckBuffer.Length; i++) for (int i = 0; i < _sortAnyChunckBuffer.Length; i++)
{ {
var bit = _sortAnyChunckBuffer.ptr[i]; var bit = _sortAnyChunckBuffer.ptr[i];
if ((_entityComponentMasks[entityLineStartIndex + bit.chunkIndex] & bit.mask) == bit.mask) if ((_entityComponentMasks[entityLineStartIndex + bit.chunkIndex] & bit.mask) == bit.mask)
{ {
anyCount++; return true;
} }
} }
if (anyCount == 0)
{
goto skip; goto skip;
} }
}
return true; return true;
skip: continue; skip: continue;
} }
return false; return false; //exit
} }
} }
#endregion #endregion

View File

@ -78,8 +78,6 @@ namespace DCFApixels.DragonECS
bool IsEmpty { get; } bool IsEmpty { get; }
} }
//TODO инъекция в раннеры
//TODO добавить функцию фильтрации систем по string, за счет создания отдельных ранеров для отдельных string
[MetaColor(MetaColor.DragonRose)] [MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.OTHER_GROUP)] [MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.OTHER_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "...")] [MetaDescription(EcsConsts.AUTHOR, "...")]

View File

@ -133,7 +133,6 @@ namespace DCFApixels.DragonECS
#endregion #endregion
#region Checks #region Checks
//TODO доработать проверки с учетом Any
public bool IsSubmaskOf(EcsStaticMask otherMask) public bool IsSubmaskOf(EcsStaticMask otherMask)
{ {
return IsSubmask(otherMask, this); return IsSubmask(otherMask, this);

View File

@ -604,26 +604,25 @@ namespace DCFApixels.DragonECS
return false; return false;
} }
} }
//TODO оптимизировать
if (anyChuncks.Length > 0) if (anyChuncks.Length > 0)
{ {
int count = 0;
for (int i = 0; i < anyChuncks.Length; i++) for (int i = 0; i < anyChuncks.Length; i++)
{ {
var bit = anyChuncks[i]; var bit = anyChuncks[i];
if ((_entityComponentMasks[componentMaskStartIndex + bit.chunkIndex] & bit.mask) == bit.mask) if ((_entityComponentMasks[componentMaskStartIndex + bit.chunkIndex] & bit.mask) == bit.mask)
{ {
count++; #if DEBUG && DRAGONECS_DEEP_DEBUG
if (true != deepDebug) { Throw.DeepDebugException(); }
#endif
return true;
} }
} }
if (count == 0)
{
#if DEBUG && DRAGONECS_DEEP_DEBUG #if DEBUG && DRAGONECS_DEEP_DEBUG
if (false != deepDebug) { Throw.DeepDebugException(); } if (false != deepDebug) { Throw.DeepDebugException(); }
#endif #endif
return false; return false;
} }
}
#if DEBUG && DRAGONECS_DEEP_DEBUG #if DEBUG && DRAGONECS_DEEP_DEBUG

View File

@ -182,7 +182,6 @@ namespace DCFApixels.DragonECS
} }
} }
short itemIndex = _mapping[worldID]; short itemIndex = _mapping[worldID];
if (itemIndex == 0) if (itemIndex == 0)
{ {
lock (_worldLock) lock (_worldLock)

View File

@ -107,8 +107,6 @@ namespace DCFApixels.DragonECS.Core
protected abstract void OnDestroy(); protected abstract void OnDestroy();
} }
//TODO добавить Any
#if ENABLE_IL2CPP #if ENABLE_IL2CPP
[Il2CppSetOption(Option.NullChecks, false)] [Il2CppSetOption(Option.NullChecks, false)]
[Il2CppSetOption(Option.ArrayBoundsChecks, false)] [Il2CppSetOption(Option.ArrayBoundsChecks, false)]

View File

@ -121,7 +121,6 @@ namespace DCFApixels.DragonECS.Core.Internal
internal static class ArrayUtility internal static class ArrayUtility
{ {
//TODO потестить
public static void ResizeOrCreate<T>(ref T[] array, int newSize) public static void ResizeOrCreate<T>(ref T[] array, int newSize)
{ {
if (array == null) if (array == null)

View File

@ -12,8 +12,6 @@ using Unity.IL2CPP.CompilerServices;
namespace DCFApixels.DragonECS.Core.Internal namespace DCFApixels.DragonECS.Core.Internal
{ {
//TODO разработать возможность ручного устанавливания ID типам.
//это может быть полезно как детерминированность для сети
#if ENABLE_IL2CPP #if ENABLE_IL2CPP
[Il2CppSetOption(Option.NullChecks, false)] [Il2CppSetOption(Option.NullChecks, false)]
[Il2CppSetOption(Option.ArrayBoundsChecks, false)] [Il2CppSetOption(Option.ArrayBoundsChecks, false)]

View File

@ -81,7 +81,7 @@ namespace DCFApixels.DragonECS.Core.Internal
public static readonly EcsNullPool instance = new EcsNullPool(); public static readonly EcsNullPool instance = new EcsNullPool();
#region Properties #region Properties
int IEcsReadonlyPool.ComponentTypeID { get { return 0; } }//TODO Првоерить что NullComponent всегда имеет id 0 int IEcsReadonlyPool.ComponentTypeID { get { return 0; } }
Type IEcsReadonlyPool.ComponentType { get { return typeof(NullComponent); } } Type IEcsReadonlyPool.ComponentType { get { return typeof(NullComponent); } }
EcsWorld IEcsReadonlyPool.World EcsWorld IEcsReadonlyPool.World
{ {