From 53911d4f255893705bd343e61520a82566a9dbce Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Thu, 7 Mar 2024 06:46:44 +0800 Subject: [PATCH] rework configs --- src/Builtin/Worlds.cs | 4 +- src/Configs/EcsPipelineConfig.cs | 98 ---------- src/Configs/EcsPipelineConfigContainer.cs | 30 +++ ...eta => EcsPipelineConfigContainer.cs.meta} | 0 src/Configs/EcsWorldConfig.cs | 184 ------------------ src/Configs/EcsWorldConfigContainer.cs | 58 ++++++ ...s.meta => EcsWorldConfigContainer.cs.meta} | 0 src/Configs/IConfig.cs | 34 ---- src/Configs/IConfigContainer.cs | 110 +++++++++++ ...onfig.cs.meta => IConfigContainer.cs.meta} | 0 src/EcsPipeline.cs | 18 +- src/EcsWorld.cs | 21 +- src/EcsWorld.static.cs | 2 +- src/Pools/EcsPool.cs | 10 +- src/Pools/EcsTagPool.cs | 3 +- 15 files changed, 226 insertions(+), 346 deletions(-) delete mode 100644 src/Configs/EcsPipelineConfig.cs create mode 100644 src/Configs/EcsPipelineConfigContainer.cs rename src/Configs/{EcsPipelineConfig.cs.meta => EcsPipelineConfigContainer.cs.meta} (100%) delete mode 100644 src/Configs/EcsWorldConfig.cs create mode 100644 src/Configs/EcsWorldConfigContainer.cs rename src/Configs/{EcsWorldConfig.cs.meta => EcsWorldConfigContainer.cs.meta} (100%) delete mode 100644 src/Configs/IConfig.cs create mode 100644 src/Configs/IConfigContainer.cs rename src/Configs/{IConfig.cs.meta => IConfigContainer.cs.meta} (100%) diff --git a/src/Builtin/Worlds.cs b/src/Builtin/Worlds.cs index db3c5a2..49ebf7c 100644 --- a/src/Builtin/Worlds.cs +++ b/src/Builtin/Worlds.cs @@ -2,10 +2,10 @@ { public sealed class EcsDefaultWorld : EcsWorld { - public EcsDefaultWorld(IEcsWorldConfig config = null, short worldID = -1) : base(config, worldID) { } + public EcsDefaultWorld(IEcsWorldConfigContainer config = null, short worldID = -1) : base(config, worldID) { } } public sealed class EcsEventWorld : EcsWorld { - public EcsEventWorld(IEcsWorldConfig config = null, short worldID = -1) : base(config, worldID) { } + public EcsEventWorld(IEcsWorldConfigContainer config = null, short worldID = -1) : base(config, worldID) { } } } diff --git a/src/Configs/EcsPipelineConfig.cs b/src/Configs/EcsPipelineConfig.cs deleted file mode 100644 index c5f8859..0000000 --- a/src/Configs/EcsPipelineConfig.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -namespace DCFApixels.DragonECS -{ - public interface IEcsPipelineConfig : IConfig { } - public interface IEcsPipelineConfigWriter : IConfigWriter - { - IEcsPipelineConfig GetPipelineConfig(); - } - [Serializable] - public class EcsPipelineConfig : IEcsPipelineConfigWriter, IEcsPipelineConfig, IEnumerable> - { - public static readonly IEcsWorldConfig Empty = new EmptyConfig(); - - private Dictionary _storage = new Dictionary(); - - public EcsPipelineConfig() { } - public EcsPipelineConfig(IEnumerable> range) - { - _storage = new Dictionary(); - foreach (var item in range) - { - _storage.Add(item.Key, item.Value); - } - } - public EcsPipelineConfig(params KeyValuePair[] range) - { - _storage = new Dictionary(); - foreach (var item in range) - { - _storage.Add(item.Key, item.Value); - } - } - - public int Count - { - get { return _storage.Count; } - } - public T Get(string valueName) - { - return (T)_storage[valueName]; - } - public bool Has(string valueName) - { - return _storage.ContainsKey(valueName); - } - public void Remove(string valueName) - { - _storage.Remove(valueName); - } - public void Set(string valueName, T value) - { - _storage[valueName] = value; - } - public void Add(string key, object value) - { - _storage.Add(key, value); - } - public void Add(KeyValuePair pair) - { - _storage.Add(pair.Key, pair.Value); - } - public bool TryGet(string valueName, out T value) - { - bool result = _storage.TryGetValue(valueName, out object rawValue); - value = rawValue == null ? default : (T)rawValue; - return result; - } - public IEnumerable> GetAllConfigs() - { - return _storage; - } - public IEnumerator> GetEnumerator() - { - return GetAllConfigs().GetEnumerator(); - } - IEnumerator IEnumerable.GetEnumerator() - { - return GetAllConfigs().GetEnumerator(); - } - - public IEcsPipelineConfig GetPipelineConfig() - { - return this; - } - - private class EmptyConfig : IEcsWorldConfig - { - public int Count { get { return 0; } } - public T Get(string valueName) { return default; } - public IEnumerable> GetAllConfigs() { return Array.Empty>(); } - public bool Has(string valueName) { return false; } - public bool TryGet(string valueName, out T value) { value = default; return false; } - } - } -} diff --git a/src/Configs/EcsPipelineConfigContainer.cs b/src/Configs/EcsPipelineConfigContainer.cs new file mode 100644 index 0000000..df08b24 --- /dev/null +++ b/src/Configs/EcsPipelineConfigContainer.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; + +namespace DCFApixels.DragonECS +{ + public interface IEcsPipelineConfigContainer : IConfigContainer { } + public interface IEcsPipelineConfigContainerWriter : IConfigContainerWriter + { + IEcsPipelineConfigContainer GetPipelineConfigs(); + } + [Serializable] + public class EcsPipelineConfigContainer : DefaultConfigContainerBase, IEcsPipelineConfigContainerWriter, IEcsPipelineConfigContainer, IEnumerable + { + public static readonly IEcsPipelineConfigContainer Defaut; + static EcsPipelineConfigContainer() + { + var container = new EcsPipelineConfigContainer(); + Defaut = container; + } + public EcsPipelineConfigContainer Set(T value) + { + SetInternal(value); + return this; + } + public IEcsPipelineConfigContainer GetPipelineConfigs() + { + return this; + } + } +} diff --git a/src/Configs/EcsPipelineConfig.cs.meta b/src/Configs/EcsPipelineConfigContainer.cs.meta similarity index 100% rename from src/Configs/EcsPipelineConfig.cs.meta rename to src/Configs/EcsPipelineConfigContainer.cs.meta diff --git a/src/Configs/EcsWorldConfig.cs b/src/Configs/EcsWorldConfig.cs deleted file mode 100644 index 02cdd63..0000000 --- a/src/Configs/EcsWorldConfig.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -namespace DCFApixels.DragonECS -{ - public interface IEcsWorldConfig : IConfig { } - public interface IEcsWorldConfigWriter : IConfigWriter - { - IEcsWorldConfig GetWorldConfig(); - } - [Serializable] - public class EcsWorldConfig : IEcsWorldConfigWriter, IEcsWorldConfig, IEnumerable> - { - public static readonly IEcsWorldConfig Empty = new EmptyConfig(); - - private Dictionary _storage = new Dictionary(); - - public EcsWorldConfig() { } - public EcsWorldConfig(IEnumerable> range) - { - _storage = new Dictionary(); - foreach (var item in range) - { - _storage.Add(item.Key, item.Value); - } - } - public EcsWorldConfig(params KeyValuePair[] range) - { - _storage = new Dictionary(); - foreach (var item in range) - { - _storage.Add(item.Key, item.Value); - } - } - - public int Count - { - get { return _storage.Count; } - } - public T Get(string valueName) - { - return (T)_storage[valueName]; - } - public bool Has(string valueName) - { - return _storage.ContainsKey(valueName); - } - public void Remove(string valueName) - { - _storage.Remove(valueName); - } - public void Set(string valueName, T value) - { - _storage[valueName] = value; - } - public void Add(string key, object value) - { - _storage.Add(key, value); - } - public void Add(KeyValuePair pair) - { - _storage.Add(pair.Key, pair.Value); - } - public bool TryGet(string valueName, out T value) - { - bool result = _storage.TryGetValue(valueName, out object rawValue); - value = rawValue == null ? default : (T)rawValue; - return result; - } - public IEnumerable> GetAllConfigs() - { - return _storage; - } - public IEnumerator> GetEnumerator() - { - return GetAllConfigs().GetEnumerator(); - } - IEnumerator IEnumerable.GetEnumerator() - { - return GetAllConfigs().GetEnumerator(); - } - - public IEcsWorldConfig GetWorldConfig() - { - return this; - } - - private class EmptyConfig : IEcsWorldConfig - { - public int Count { get { return 0; } } - public T Get(string valueName) { return default; } - public IEnumerable> GetAllConfigs() { return Array.Empty>(); } - public bool Has(string valueName) { return false; } - public bool TryGet(string valueName, out T value) { value = default; return false; } - } - } - public static class EcsWorldConfigExtensions - { - public static T GetOrDefault(this IEcsWorldConfig self, string valueName, T defaultValue) - { - if (self.TryGet(valueName, out T value)) - { - return value; - } - return defaultValue; - } - - private const string ENTITIES_CAPACITY = nameof(ENTITIES_CAPACITY); - private const int ENTITIES_CAPACITY_DEFAULT = 512; - public static TConfig Set_EntitiesCapacity(this TConfig self, int value) - where TConfig : IEcsWorldConfigWriter - { - self.Set(ENTITIES_CAPACITY, value); - return self; - } - public static int Get_EntitiesCapacity(this IEcsWorldConfig self) - { - return self.GetOrDefault(ENTITIES_CAPACITY, ENTITIES_CAPACITY_DEFAULT); - } - - //private const string RECYCLED_ENTITIES_CAPACITY = nameof(RECYCLED_ENTITIES_CAPACITY); - //public static void Set_RecycledEntitiesCapacity(this IEcsWorldConfig self, int value) - //{ - // self.Set(RECYCLED_ENTITIES_CAPACITY, value); - //} - //public static int Get_RecycledEntitiesCapacity(this IEcsWorldConfig self) - //{ - // return self.GetOrDefault(RECYCLED_ENTITIES_CAPACITY, self.Get_EntitiesCapacity() / 2); - //} - - private const string GROUP_CAPACITY = nameof(GROUP_CAPACITY); - private const int GROUP_CAPACITY_DEFAULT = 512; - public static TConfig Set_GroupCapacity(this TConfig self, int value) - where TConfig : IEcsWorldConfigWriter - { - self.Set(GROUP_CAPACITY, value); - return self; - } - public static int Get_GroupCapacity(this IEcsWorldConfig self) - { - return self.GetOrDefault(GROUP_CAPACITY, GROUP_CAPACITY_DEFAULT); - } - - - private const string POOLS_CAPACITY = nameof(POOLS_CAPACITY); - private const int POOLS_CAPACITY_DEFAULT = 512; - public static TConfig Set_PoolsCapacity(this TConfig self, int value) - where TConfig : IEcsWorldConfigWriter - { - self.Set(POOLS_CAPACITY, value); - return self; - } - public static int Get_PoolsCapacity(this IEcsWorldConfig self) - { - return self.GetOrDefault(POOLS_CAPACITY, POOLS_CAPACITY_DEFAULT); - } - - private const string COMPONENT_POOL_CAPACITY = nameof(COMPONENT_POOL_CAPACITY); - private const int COMPONENT_POOL_CAPACITY_DEFAULT = 512; - public static TConfig Set_PoolComponentsCapacity(this TConfig self, int value) - where TConfig : IEcsWorldConfigWriter - { - self.Set(COMPONENT_POOL_CAPACITY, value); - return self; - } - public static int Get_PoolComponentsCapacity(this IEcsWorldConfig self) - { - return self.GetOrDefault(COMPONENT_POOL_CAPACITY, COMPONENT_POOL_CAPACITY_DEFAULT); - } - - private const string POOL_RECYCLED_COMPONENTS_CAPACITY = nameof(POOL_RECYCLED_COMPONENTS_CAPACITY); - public static TConfig Set_PoolRecycledComponentsCapacity(this TConfig self, int value) - where TConfig : IEcsWorldConfigWriter - { - self.Set(POOL_RECYCLED_COMPONENTS_CAPACITY, value); - return self; - } - public static int Get_PoolRecycledComponentsCapacity(this IEcsWorldConfig self) - { - return self.GetOrDefault(POOL_RECYCLED_COMPONENTS_CAPACITY, self.Get_PoolComponentsCapacity() / 2); - } - } -} diff --git a/src/Configs/EcsWorldConfigContainer.cs b/src/Configs/EcsWorldConfigContainer.cs new file mode 100644 index 0000000..7a5b449 --- /dev/null +++ b/src/Configs/EcsWorldConfigContainer.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; + +namespace DCFApixels.DragonECS +{ + public class EcsWorldConfig + { + public readonly int EntitiesCapacity; + public readonly int GroupCapacity; + public readonly int PoolsCapacity; + public readonly int PoolComponentsCapacity; + public readonly int PoolRecycledComponentsCapacity; + public EcsWorldConfig(int entitiesCapacity = 512, int groupCapacity = 512, int poolsCapacity = 512, int poolComponentsCapacity = 512, int poolRecycledComponentsCapacity = 512 / 2) + { + EntitiesCapacity = entitiesCapacity; + GroupCapacity = groupCapacity; + PoolsCapacity = poolsCapacity; + PoolComponentsCapacity = poolComponentsCapacity; + PoolRecycledComponentsCapacity = poolRecycledComponentsCapacity; + } + } + public interface IEcsWorldConfigContainer : IConfigContainer { } + public interface IEcsWorldConfigContainerWriter : IConfigContainerWriter + { + IEcsWorldConfigContainer GetWorldConfigs(); + } + [Serializable] + public class EcsWorldConfigContainer : DefaultConfigContainerBase, IEcsWorldConfigContainerWriter, IEcsWorldConfigContainer, IEnumerable + { + public static readonly IEcsWorldConfigContainer Defaut; + static EcsWorldConfigContainer() + { + var container = new EcsWorldConfigContainer(); + container.Set(new EcsWorldConfig()); + Defaut = container; + } + public EcsWorldConfigContainer Set(T value) + { + SetInternal(value); + return this; + } + public IEcsWorldConfigContainer GetWorldConfigs() + { + return this; + } + } + public static class EcsWorldConfigExtensions + { + public static T GetOrDefault(this IEcsWorldConfigContainer self, T defaultValue) + { + if (self.TryGet(out T value)) + { + return value; + } + return defaultValue; + } + } +} diff --git a/src/Configs/EcsWorldConfig.cs.meta b/src/Configs/EcsWorldConfigContainer.cs.meta similarity index 100% rename from src/Configs/EcsWorldConfig.cs.meta rename to src/Configs/EcsWorldConfigContainer.cs.meta diff --git a/src/Configs/IConfig.cs b/src/Configs/IConfig.cs deleted file mode 100644 index 4ed43b9..0000000 --- a/src/Configs/IConfig.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections.Generic; - -namespace DCFApixels.DragonECS -{ - public interface IConfig - { - int Count { get; } - bool Has(string valueName); - T Get(string valueName); - bool TryGet(string valueName, out T value); - IEnumerable> GetAllConfigs(); - } - public interface IConfigWriter - { - int Count { get; } - void Set(string valueName, T value); - bool Has(string valueName); - T Get(string valueName); - bool TryGet(string valueName, out T value); - void Remove(string valueName); - IEnumerable> GetAllConfigs(); - } - public static class ConfigExtensions - { - public static T GetOrDefault(this IConfig self, string valueName, T defaultValue) - { - if (self.TryGet(valueName, out T value)) - { - return value; - } - return defaultValue; - } - } -} diff --git a/src/Configs/IConfigContainer.cs b/src/Configs/IConfigContainer.cs new file mode 100644 index 0000000..4fce30e --- /dev/null +++ b/src/Configs/IConfigContainer.cs @@ -0,0 +1,110 @@ +using System.Collections; +using System; +using System.Collections.Generic; + +namespace DCFApixels.DragonECS +{ + public interface IConfigContainer + { + int Count { get; } + bool Has(); + T Get(); + bool TryGet(out T value); + IEnumerable GetAllConfigs(); + } + public interface IConfigContainerWriter + { + int Count { get; } + void Set(T value); + bool Has(); + T Get(); + bool TryGet(out T value); + void Remove(); + IEnumerable GetAllConfigs(); + } + public static class ConfigContainerExtensions + { + public static T GetOrDefault(this IConfigContainer self, T defaultValue) + { + if (self.TryGet(out T value)) + { + return value; + } + return defaultValue; + } + } + + public class DefaultConfigContainerBase : IConfigContainer, IConfigContainerWriter, IEnumerable + { + private Dictionary _storage = new Dictionary(); + + public DefaultConfigContainerBase() { } + public DefaultConfigContainerBase(IEnumerable range) + { + foreach (var item in range) + { + _storage.Add(item.GetType(), item); + } + } + public DefaultConfigContainerBase(params object[] range) + { + foreach (var item in range) + { + _storage.Add(item.GetType(), item); + } + } + + public int Count + { + get { return _storage.Count; } + } + public T Get() + { + return (T)_storage[typeof(T)]; + } + public bool Has() + { + return _storage.ContainsKey(typeof(T)); + } + public void Remove() + { + _storage.Remove(typeof(T)); + } + protected void SetInternal(T value) + { + _storage[typeof(T)] = value; + } + void IConfigContainerWriter.Set(T value) + { + SetInternal(value); + } + public bool TryGet(out T value) + { + bool result = _storage.TryGetValue(typeof(T), out object rawValue); + value = rawValue == null ? default : (T)rawValue; + return result; + } + public IEnumerable GetAllConfigs() + { + return _storage.Values; + } + public IEnumerator GetEnumerator() + { + return _storage.Values.GetEnumerator(); + } + IEnumerator IEnumerable.GetEnumerator() + { + return GetAllConfigs().GetEnumerator(); + } + } + + public static class DefaultConfigContainerBaseExtensions + { + public static TContainer Set(this TContainer self, T value) + where TContainer : IConfigContainerWriter + { + self.Set(value); + return self; + } + } +} diff --git a/src/Configs/IConfig.cs.meta b/src/Configs/IConfigContainer.cs.meta similarity index 100% rename from src/Configs/IConfig.cs.meta rename to src/Configs/IConfigContainer.cs.meta diff --git a/src/EcsPipeline.cs b/src/EcsPipeline.cs index 82e2e9f..7ffcf8d 100644 --- a/src/EcsPipeline.cs +++ b/src/EcsPipeline.cs @@ -14,7 +14,7 @@ namespace DCFApixels.DragonECS } public sealed class EcsPipeline { - private readonly IEcsPipelineConfig _config; + private readonly IEcsPipelineConfigContainer _config; private Injector.Builder _injectorBuilder; private Injector _injector; @@ -31,7 +31,7 @@ namespace DCFApixels.DragonECS #endif #region Properties - public IEcsPipelineConfig Config + public IEcsPipelineConfigContainer Config { get { return _config; } } @@ -58,7 +58,7 @@ namespace DCFApixels.DragonECS #endregion #region Constructors - private EcsPipeline(IEcsPipelineConfig config, Injector.Builder injectorBuilder, IEcsProcess[] systems) + private EcsPipeline(IEcsPipelineConfigContainer config, Injector.Builder injectorBuilder, IEcsProcess[] systems) { _config = config; _allSystems = systems; @@ -186,7 +186,7 @@ namespace DCFApixels.DragonECS #endregion #region Builder - public static Builder New(IEcsPipelineConfigWriter config = null) + public static Builder New(IEcsPipelineConfigContainerWriter config = null) { return new Builder(config); } @@ -197,14 +197,14 @@ namespace DCFApixels.DragonECS private readonly Dictionary> _systems; private readonly string _basicLayer; public readonly LayerList Layers; - private readonly IEcsPipelineConfigWriter _config; + private readonly IEcsPipelineConfigContainerWriter _config; private readonly Injector.Builder _injector; #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS private EcsProfilerMarker _buildBarker = new EcsProfilerMarker("EcsPipeline.Build"); #endif private List _initDeclaredRunners = new List(4); - public IEcsPipelineConfigWriter Config + public IEcsPipelineConfigContainerWriter Config { get { return _config; } } @@ -212,12 +212,12 @@ namespace DCFApixels.DragonECS { get { return _injector; } } - public Builder(IEcsPipelineConfigWriter config = null) + public Builder(IEcsPipelineConfigContainerWriter config = null) { #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS _buildBarker.Begin(); #endif - if (config == null) { config = new EcsPipelineConfig(); } + if (config == null) { config = new EcsPipelineConfigContainer(); } _config = config; _injector = new Injector.Builder(this); @@ -293,7 +293,7 @@ namespace DCFApixels.DragonECS if (_systems.TryGetValue(item, out var list)) result.AddRange(list); } - EcsPipeline pipeline = new EcsPipeline(_config.GetPipelineConfig(), _injector, result.ToArray()); + EcsPipeline pipeline = new EcsPipeline(_config.GetPipelineConfigs(), _injector, result.ToArray()); foreach (var item in _initDeclaredRunners) { item.Declare(pipeline); diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index 5df4655..e7a1c99 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -9,7 +9,7 @@ namespace DCFApixels.DragonECS public partial class EcsWorld : IEntityStorage { public readonly short id; - private IEcsWorldConfig _config; + private IEcsWorldConfigContainer _configs; private bool _isDestroyed = false; @@ -38,10 +38,10 @@ namespace DCFApixels.DragonECS private List _entityListeners = new List(); #region Properties - public IEcsWorldConfig Config + public IEcsWorldConfigContainer Configs { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get { return _config; } + get { return _configs; } } public long Version { @@ -95,18 +95,19 @@ namespace DCFApixels.DragonECS #endregion #region Constructors/Destroy - public EcsWorld(IEcsWorldConfig config = null, short worldID = -1) + public EcsWorld(IEcsWorldConfigContainer configs = null, short worldID = -1) { - if (config == null) + if (configs == null) { - config = EcsWorldConfig.Empty; + configs = EcsWorldConfigContainer.Defaut; } bool nullWorld = this is NullWorld; if(nullWorld == false && worldID == NULL_WORLD_ID) { EcsDebug.PrintWarning($"The world identifier cannot be {NULL_WORLD_ID}"); } - _config = config; + _configs = configs; + EcsWorldConfig config = configs.Get(); if (worldID < 0 || (worldID == NULL_WORLD_ID && nullWorld == false)) { @@ -129,12 +130,12 @@ namespace DCFApixels.DragonECS _poolsMediator = new PoolsMediator(this); - int poolsCapacity = ArrayUtility.NormalizeSizeToPowerOfTwo(config.Get_PoolsCapacity()); + int poolsCapacity = ArrayUtility.NormalizeSizeToPowerOfTwo(config.PoolsCapacity); _pools = new IEcsPoolImplementation[poolsCapacity]; _poolComponentCounts = new int[poolsCapacity]; ArrayUtility.Fill(_pools, _nullPool); - int entitiesCapacity = ArrayUtility.NormalizeSizeToPowerOfTwo(config.Get_EntitiesCapacity()); + int entitiesCapacity = ArrayUtility.NormalizeSizeToPowerOfTwo(config.EntitiesCapacity); _entityDispenser = new IdDispenser(entitiesCapacity, 0, OnEntityDispenserResized); } public void Destroy() @@ -553,7 +554,7 @@ namespace DCFApixels.DragonECS } internal EcsGroup GetFreeGroup() { - EcsGroup result = _groupsPool.Count <= 0 ? new EcsGroup(this, _config.Get_GroupCapacity()) : _groupsPool.Pop(); + EcsGroup result = _groupsPool.Count <= 0 ? new EcsGroup(this, _configs.Get().GroupCapacity) : _groupsPool.Pop(); result._isReleased = false; return result; } diff --git a/src/EcsWorld.static.cs b/src/EcsWorld.static.cs index c1145cf..fa19f70 100644 --- a/src/EcsWorld.static.cs +++ b/src/EcsWorld.static.cs @@ -131,7 +131,7 @@ namespace DCFApixels.DragonECS } private sealed class NullWorld : EcsWorld { - internal NullWorld() : base(EcsWorldConfig.Empty, 0) { } + internal NullWorld() : base(EcsWorldConfigContainer.Defaut, 0) { } } } } diff --git a/src/Pools/EcsPool.cs b/src/Pools/EcsPool.cs index 5fc251e..a8fc7f1 100644 --- a/src/Pools/EcsPool.cs +++ b/src/Pools/EcsPool.cs @@ -16,9 +16,9 @@ namespace DCFApixels.DragonECS private int[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID private T[] _items; //dense - private int _itemsCount; + private int _itemsCount = 0; private int[] _recycledItems; - private int _recycledItemsCount; + private int _recycledItemsCount = 0; private IEcsComponentReset _componentResetHandler = EcsComponentResetHandler.instance; private bool _isHasComponentResetHandler = EcsComponentResetHandler.isHasHandler; @@ -177,10 +177,8 @@ namespace DCFApixels.DragonECS _maskBit = EcsMaskChunck.FromID(componentTypeID); _mapping = new int[world.Capacity]; - _recycledItems = new int[world.Config.Get_PoolRecycledComponentsCapacity()]; - _recycledItemsCount = 0; - _items = new T[ArrayUtility.NormalizeSizeToPowerOfTwo(world.Config.Get_PoolComponentsCapacity())]; - _itemsCount = 0; + _items = new T[ArrayUtility.NormalizeSizeToPowerOfTwo(world.Configs.Get().PoolComponentsCapacity)]; + _recycledItems = new int[world.Configs.Get().PoolRecycledComponentsCapacity]; } void IEcsPoolImplementation.OnWorldResize(int newSize) { diff --git a/src/Pools/EcsTagPool.cs b/src/Pools/EcsTagPool.cs index eb5b56d..049d17b 100644 --- a/src/Pools/EcsTagPool.cs +++ b/src/Pools/EcsTagPool.cs @@ -14,7 +14,7 @@ namespace DCFApixels.DragonECS private EcsMaskChunck _maskBit; private bool[] _mapping;// index = entityID / value = itemIndex;/ value = 0 = no entityID - private int _count; + private int _count = 0; private List _listeners = new List(); @@ -156,7 +156,6 @@ namespace DCFApixels.DragonECS _maskBit = EcsMaskChunck.FromID(componentTypeID); _mapping = new bool[world.Capacity]; - _count = 0; } void IEcsPoolImplementation.OnWorldResize(int newSize) {