remove useless

This commit is contained in:
Mikhail 2023-05-30 16:07:45 +08:00
parent 8dc8236f7e
commit dd562986f0
3 changed files with 2 additions and 139 deletions

View File

@ -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<T>(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<T>(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<T>(entityID);
#endif

View File

@ -201,9 +201,9 @@ namespace DCFApixels.DragonECS
#region Callbacks Interface
public interface IEcsPoolEventListener
{
/// <summary>Called after adding an entity to the pool, but before changing values.</summary>
/// <summary>Called after adding an entity to the pool, but before changing values</summary>
void OnAdd(int entityID);
/// <summary>Is called when EcsPool.Get or EcsPool.Add is called, but before changing values.</summary>
/// <summary>Is called when EcsPool.Get or EcsPool.Add is called, but before changing values</summary>
void OnGet(int entityID);
/// <summary>Called after deleting an entity from the pool</summary>
void OnDel(int entityID);

View File

@ -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;
/// <summary> Insert after</summary>
/// <returns> new node index</returns>
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;
/// <summary>next node index</summary>
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
}
}