From dd562986f03cb91b7a9d6fd4e7e594a5f393b27e Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Tue, 30 May 2023 16:07:45 +0800 Subject: [PATCH] remove useless --- src/Pools/EcsPool.cs | 5 -- src/Pools/EcsPoolBase.cs | 4 +- src/Utils/EntityLinkedList.cs | 132 ---------------------------------- 3 files changed, 2 insertions(+), 139 deletions(-) delete mode 100644 src/Utils/EntityLinkedList.cs diff --git a/src/Pools/EcsPool.cs b/src/Pools/EcsPool.cs index 0cc1082..bf3dfac 100644 --- a/src/Pools/EcsPool.cs +++ b/src/Pools/EcsPool.cs @@ -56,8 +56,6 @@ namespace DCFApixels.DragonECS #region Methods public ref T Add(int entityID) { - // using (_addMark.Auto()) - // { ref int itemIndex = ref _mapping[entityID]; #if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS if (itemIndex > 0) ThrowAlreadyHasComponent(entityID); @@ -76,12 +74,10 @@ namespace DCFApixels.DragonECS this.IncrementEntityComponentCount(entityID); _listeners.InvokeOnAddAndGet(entityID); return ref _items[itemIndex]; - // } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T Get(int entityID) { - // using (_writeMark.Auto()) #if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS if (!Has(entityID)) ThrowNotHaveComponent(entityID); #endif @@ -91,7 +87,6 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref readonly T Read(int entityID) { - // using (_readMark.Auto()) #if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS if (!Has(entityID)) ThrowNotHaveComponent(entityID); #endif diff --git a/src/Pools/EcsPoolBase.cs b/src/Pools/EcsPoolBase.cs index 5dfe6c6..853226f 100644 --- a/src/Pools/EcsPoolBase.cs +++ b/src/Pools/EcsPoolBase.cs @@ -201,9 +201,9 @@ namespace DCFApixels.DragonECS #region Callbacks Interface public interface IEcsPoolEventListener { - /// Called after adding an entity to the pool, but before changing values. + /// Called after adding an entity to the pool, but before changing values void OnAdd(int entityID); - /// Is called when EcsPool.Get or EcsPool.Add is called, but before changing values. + /// Is called when EcsPool.Get or EcsPool.Add is called, but before changing values void OnGet(int entityID); /// Called after deleting an entity from the pool void OnDel(int entityID); diff --git a/src/Utils/EntityLinkedList.cs b/src/Utils/EntityLinkedList.cs deleted file mode 100644 index bafe85f..0000000 --- a/src/Utils/EntityLinkedList.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace DCFApixels.DragonECS -{ - public class EntityLinkedList - { - private const int ENTER = 0; - - private Node[] _nodes; - private int _count; - private int _lastNodeIndex; - - #region Properties - public int Count => _count; - public int Capacity => _nodes.Length; - public int Last => _lastNodeIndex; - #endregion - - #region Constructors - public EntityLinkedList(int capacity) - { - _nodes = new Node[capacity + 10]; - Clear(); - } - #endregion - - public void Resize(int newCapacity) - { - Array.Resize(ref _nodes, newCapacity + 10); - } - - public void Clear() - { - //ArrayUtility.Fill(_nodes, Node.Empty); - for (int i = 0; i < _nodes.Length; i++) - _nodes[i].next = 0; - _lastNodeIndex = ENTER; - _count = 0; - } - - public void Set(int nodeIndex, int entityID) => _nodes[nodeIndex].entityID = entityID; - public int Get(int nodeIndex) => _nodes[nodeIndex].entityID; - - /// Insert after - /// new node index - public int Insert(int nodeIndex, int entityID) - { - _nodes[++_count].Set(entityID, _nodes[nodeIndex].next); - _nodes[nodeIndex].next = _count; - _lastNodeIndex = _count; - return _count; - } - - public int Add(int entityID) => Insert(_lastNodeIndex, entityID); - - public Enumerator GetEnumerator() => new Enumerator(_nodes); - public EnumerableSpan Span(int startNodeIndex, int count) => new EnumerableSpan(this, startNodeIndex, count); - - #region Utils - [StructLayout(LayoutKind.Sequential, Pack = 4, Size = 8)] - public struct Node - { - public static readonly Node Empty = new Node() { entityID = 0, next = -1 }; - public int entityID; - /// next node index - public int next; - - public void Set(int entityID, int next) - { - this.entityID = entityID; - this.next = next; - } - } - - public struct Enumerator - { - private readonly Node[] _nodes; - private int _index; - private int _next; - public Enumerator(Node[] nodes) - { - _nodes = nodes; - _index = -1; - _next = ENTER; - } - public int Current => _nodes[_index].entityID; - public bool MoveNext() - { - _index = _next; - _next = _nodes[_next].next; - return _index > 0; - } - } - - public readonly ref struct EnumerableSpan - { - private readonly EntityLinkedList _source; - private readonly int _startNodeIndex; - private readonly int _count; - public EnumerableSpan(EntityLinkedList source, int startNodeIndex, int count) - { - _source = source; - _startNodeIndex = startNodeIndex; - _count = count; - } - public SpanEnumerator GetEnumerator() => new SpanEnumerator(_source._nodes, _startNodeIndex, _count); - } - public struct SpanEnumerator - { - private readonly Node[] _nodes; - private int _index; - private int _count; - private int _next; - public SpanEnumerator(Node[] nodes, int startIndex, int count) - { - _nodes = nodes; - _index = -1; - _count = count; - _next = startIndex; - } - public int Current => _nodes[_index].entityID; - public bool MoveNext() - { - _index = _next; - _next = _nodes[_next].next; - return _index > 0 && _count-- > 0; - } - } - #endregion - } -}