From 53b7fae2c4f51a9a8e88657cd43d5f5215cf044e Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Fri, 7 Apr 2023 19:23:07 +0800 Subject: [PATCH] remove usless --- src/EcsFilter.cs | 62 ----------------------------- src/EcsGroup.cs | 17 +++----- src/EcsWorld.cs | 6 +-- src/Interfaces/IEcsReadonlyTable.cs | 20 +--------- 4 files changed, 8 insertions(+), 97 deletions(-) delete mode 100644 src/EcsFilter.cs diff --git a/src/EcsFilter.cs b/src/EcsFilter.cs deleted file mode 100644 index d36133a..0000000 --- a/src/EcsFilter.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace DCFApixels.DragonECS -{ - public class EcsFilter - { - private readonly IEcsWorld _source; - internal readonly EcsGroup entities; - private readonly EcsMask _mask; - - #region Properties - public IEcsWorld World - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => _source; - } - public EcsMask Mask - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => _mask; - } - public EcsReadonlyGroup Entities - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => entities.Readonly; - } - public int EntitiesCount - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => entities.Count; - } - #endregion - - #region Constrcutors - internal EcsFilter(IEcsWorld source, EcsMask mask, int capasity) - { - _source = source; - _mask = mask; - entities = new EcsGroup(source, capasity); - } - #endregion - - #region EntityChangedReact - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal void Add(int entityID) - { - entities.UncheckedAdd(entityID); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal void Remove(int entityID) - { - entities.UncheckedRemove(entityID); - } - #endregion - - #region GetEnumerator - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public EcsGroup.Enumerator GetEnumerator() => entities.GetEnumerator(); - #endregion - } -} diff --git a/src/EcsGroup.cs b/src/EcsGroup.cs index ed4425b..c540f4b 100644 --- a/src/EcsGroup.cs +++ b/src/EcsGroup.cs @@ -1,5 +1,4 @@ using System; -using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using delayedOp = System.Int32; @@ -184,11 +183,6 @@ namespace DCFApixels.DragonECS Array.Resize(ref _sparse, newSize); } - //TODO добавить метод Sort - - //TODO добавить автосоритровку при каждом GetEnumerator и проверить будет ли прирост производительности или ее падение. - //Суть в том что так возможно можно будет более плотно подавать данные в проц - public void Sort() { int increment = 1; @@ -202,7 +196,6 @@ namespace DCFApixels.DragonECS } } - #region AddGroup/RemoveGroup public void AddGroup(EcsReadonlyGroup group) { foreach (var item in group) Add(item.id); } @@ -248,7 +241,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public Enumerator GetEnumerator() { - // Sort(); + Sort(); _lockCount++; return new Enumerator(this); } @@ -283,10 +276,10 @@ namespace DCFApixels.DragonECS } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Dispose() => _source.Unlock(); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Reset() { } + public void Dispose() + { + _source.Unlock(); + } } #endregion } diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index cfbc735..407137d 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -65,7 +65,6 @@ namespace DCFApixels.DragonECS private short[] _gens; //старший бит указывает на то жива ли сущьность. //private short[] _componentCounts; //TODO - private IEcsPool[] _pools; private EcsNullPool _nullPool; @@ -154,10 +153,7 @@ namespace DCFApixels.DragonECS } return (EcsPool)_pools[uniqueID]; } - public EcsPool UncheckedGetPool() where T : struct - { - return (EcsPool)_pools[ComponentType.uniqueID]; - } + //public EcsPool UncheckedGetPool() where T : struct => (EcsPool)_pools[ComponentType.uniqueID]; #endregion #region Entities diff --git a/src/Interfaces/IEcsReadonlyTable.cs b/src/Interfaces/IEcsReadonlyTable.cs index 55ae41b..773d043 100644 --- a/src/Interfaces/IEcsReadonlyTable.cs +++ b/src/Interfaces/IEcsReadonlyTable.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace DCFApixels.DragonECS { @@ -11,6 +7,8 @@ namespace DCFApixels.DragonECS #region Properties /// Table Archetype public Type ArchetypeType { get; } + internal int Count { get; } + internal int Capacity { get; } #endregion #region Methods @@ -18,7 +16,6 @@ namespace DCFApixels.DragonECS public int GetComponentID(); public EcsPool GetPool() where T : struct; - public EcsPool UncheckedGetPool() where T : struct; public bool IsMaskCompatible(int entity) where TInc : struct, IInc; public bool IsMaskCompatible(int entity) where TInc : struct, IInc where TExc : struct, IExc; @@ -26,23 +23,10 @@ namespace DCFApixels.DragonECS public bool IsMaskCompatibleWithout(EcsComponentMask mask, int entity, int otherPoolID); #endregion - #region Properties - internal int Count { get; } - internal int Capacity { get; } - #endregion - #region Internal Methods internal void OnEntityComponentAdded(int entityID, int changedPoolID); internal void OnEntityComponentRemoved(int entityID, int changedPoolID); internal void RegisterGroup(EcsGroup group); #endregion } - - public static class IEcsReadonlyEntityComponentTableExtensions - { - public static bool IsNullOrEmpty(this IEcsReadonlyTable self) - { - return self == null || self.Count <= 0; - } - } }