diff --git a/src/EcsGroup.cs b/src/EcsGroup.cs index 657c816..17082e9 100644 --- a/src/EcsGroup.cs +++ b/src/EcsGroup.cs @@ -246,7 +246,7 @@ namespace DCFApixels.DragonECS #endregion #region Enumerator - public struct Enumerator : IDisposable + public ref struct Enumerator { private readonly EcsGroup _source; private readonly int[] _dense; diff --git a/src/EcsTable.cs b/src/EcsTable.cs index 469070a..7fb53f3 100644 --- a/src/EcsTable.cs +++ b/src/EcsTable.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; @@ -11,8 +12,9 @@ namespace DCFApixels.DragonECS private IEcsPool[] _pools; private EcsNullPool _nullPool; - private int[] _denseEntities; - private int[] _sparceEntities; + private short[] _gens; + private short[] _componentCounts; + private int _entitiesCount; private List[] _filtersByIncludedComponents; @@ -22,12 +24,42 @@ namespace DCFApixels.DragonECS private List _groups; - #region Internal Properties + + #region Properties public int Count => _entitiesCount; - public int Capacity => _denseEntities.Length; + public int Capacity => _gens.Length; + public ReadOnlySpan GetAllPools() => new ReadOnlySpan(_pools); + #endregion + + #region internal Add/Has/Remove + internal void Add(int entityID) + { + int entity; + if (_entitiesCount >= _gens.Length) + { + Array.Resize(ref _gens, _gens.Length << 1); + Array.Resize(ref _componentCounts, _componentCounts.Length << 1); + } + _gens[_entitiesCount++]++; + _componentCounts[_entitiesCount++] = 0; + + // if (_gens.Length <= entityID) + // { + // //TODO есть проблема что если передать слишком большой id такой алогоритм не сработает + // } + + + } + internal void Has(int entityID) + { + + } + internal void Remove(int entityID) + { + + } #endregion - public ReadOnlySpan GetAllPools() => new ReadOnlySpan(_pools); //public int GetComponentID() => ; } diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index abf2751..ca2689b 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Transactions; namespace DCFApixels.DragonECS {