diff --git a/src/Builtin/Worlds.cs b/src/Builtin/Worlds.cs index fe3b8dc..9b059d1 100644 --- a/src/Builtin/Worlds.cs +++ b/src/Builtin/Worlds.cs @@ -3,15 +3,23 @@ namespace DCFApixels.DragonECS { [DebuggerTypeProxy(typeof(DebuggerProxy))] - public sealed class EcsDefaultWorld : EcsWorld + public sealed class EcsDefaultWorld : EcsWorld, IInjectionUnit { public EcsDefaultWorld(EcsWorldConfig config, short worldID = -1) : base(config, worldID) { } public EcsDefaultWorld(IConfigContainer configs = null, short worldID = -1) : base(configs, worldID) { } + void IInjectionUnit.OnInitInjectionBranch(InjectionBranchIniter initer) + { + initer.AddNode(); + } } [DebuggerTypeProxy(typeof(DebuggerProxy))] - public sealed class EcsEventWorld : EcsWorld + public sealed class EcsEventWorld : EcsWorld, IInjectionUnit { public EcsEventWorld(EcsWorldConfig config, short worldID = -1) : base(config, worldID) { } public EcsEventWorld(IConfigContainer configs = null, short worldID = -1) : base(configs, worldID) { } + void IInjectionUnit.OnInitInjectionBranch(InjectionBranchIniter initer) + { + initer.AddNode(); + } } } diff --git a/src/EcsMask.cs b/src/EcsMask.cs index 5339dac..f1de43d 100644 --- a/src/EcsMask.cs +++ b/src/EcsMask.cs @@ -313,8 +313,8 @@ namespace DCFApixels.DragonECS } public bool Equals(OpMaskKey other) { - return leftMaskID == other.leftMaskID && - rightMaskID == other.rightMaskID && + return leftMaskID == other.leftMaskID && + rightMaskID == other.rightMaskID && operation == other.operation; } public override int GetHashCode() @@ -585,7 +585,7 @@ namespace DCFApixels.DragonECS { foreach (var item in _excepteds) { - if(combinedInc.Overlaps(item.mask._exc) || combinedExc.Overlaps(item.mask._inc)) + if (combinedInc.Overlaps(item.mask._exc) || combinedExc.Overlaps(item.mask._inc)) { _combineds.Clear(); _excepteds.Clear(); diff --git a/src/EcsPreFilter.cs b/src/EcsPreFilter.cs new file mode 100644 index 0000000..2f762a1 --- /dev/null +++ b/src/EcsPreFilter.cs @@ -0,0 +1,36 @@ +namespace DCFApixels.DragonECS +{ + public class EcsPreFilter + { + + } + + public class EcsPreFilterManager + { + private EcsWorld _world; + private EcsGroup _dirtyEntities; + + public EcsPreFilterManager(EcsWorld world) + { + _world = world; + _dirtyEntities = EcsGroup.New(_world); + } + + internal void AddDirty(int entityID) + { + _dirtyEntities.Add(entityID); + } + } + public class PoolListener : IEcsPoolEventListener + { + public void OnAdd(int entityID) + { + } + public void OnDel(int entityID) + { + } + public void OnGet(int entityID) + { + } + } +} diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index 7ea189a..319fc4f 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -256,7 +256,7 @@ namespace DCFApixels.DragonECS _entitiesCount++; ref var slot = ref _entities[entityID]; slot.isUsed = true; - if(slot.gen >= 0) + if (slot.gen >= 0) { //если gen был пробужен у не мертвой сущности, то для отличия от мертвой, нужно инкрементировать и усыпить slot.gen++; slot.gen &= SLEEP_GEN_MASK; diff --git a/src/Injections/EcsPipelineExtensions.cs b/src/Injections/EcsPipelineExtensions.cs index ac02ad7..d698db6 100644 --- a/src/Injections/EcsPipelineExtensions.cs +++ b/src/Injections/EcsPipelineExtensions.cs @@ -6,10 +6,7 @@ namespace DCFApixels.DragonECS { public static EcsPipeline.Builder Inject(this EcsPipeline.Builder self, T data) { - if (data == null) - { - Throw.ArgumentNull(); - } + if (data == null) { Throw.ArgumentNull(); } self.Injector.Inject(data); if (data is IEcsModule module) { diff --git a/src/Internal/EcsTypeCode.cs b/src/Internal/EcsTypeCode.cs index eab9457..dfc2e20 100644 --- a/src/Internal/EcsTypeCode.cs +++ b/src/Internal/EcsTypeCode.cs @@ -5,6 +5,8 @@ using System.Runtime.CompilerServices; namespace DCFApixels.DragonECS.Internal { + //TODO разработать возможность ручного устанавливания ID типам. + //это нужно для упрощения разработки сетевух internal static class EcsTypeCode { private static readonly Dictionary _codes = new Dictionary(); diff --git a/src/Pools/EcsPool.cs b/src/Pools/EcsPool.cs index 921fe8a..611f48c 100644 --- a/src/Pools/EcsPool.cs +++ b/src/Pools/EcsPool.cs @@ -229,13 +229,13 @@ namespace DCFApixels.DragonECS #region Listeners public void AddListener(IEcsPoolEventListener listener) { - if (listener == null) { throw new ArgumentNullException("listener is null"); } + if (listener == null) { EcsPoolThrowHalper.ThrowNullListener(); } _listeners.Add(listener); _listenersCachedCount++; } public void RemoveListener(IEcsPoolEventListener listener) { - if (listener == null) { throw new ArgumentNullException("listener is null"); } + if (listener == null) { EcsPoolThrowHalper.ThrowNullListener(); } if (_listeners.Remove(listener)) { _listenersCachedCount--; diff --git a/src/Pools/EcsPoolBase.cs b/src/Pools/EcsPoolBase.cs index 2f03486..c1bf8f1 100644 --- a/src/Pools/EcsPoolBase.cs +++ b/src/Pools/EcsPoolBase.cs @@ -85,6 +85,10 @@ namespace DCFApixels.DragonECS { throw new EcsFrameworkException($"Entity({entityID}) has no component {EcsDebugUtility.GetGenericTypeName(type)}."); } + public static void ThrowNullListener() + { + throw new ArgumentNullException("listener is null"); + } } public static class IEcsPoolImplementationExtensions { diff --git a/src/Pools/EcsTagPool.cs b/src/Pools/EcsTagPool.cs index c39c5c8..ed7372b 100644 --- a/src/Pools/EcsTagPool.cs +++ b/src/Pools/EcsTagPool.cs @@ -97,6 +97,7 @@ namespace DCFApixels.DragonECS _mediator.UnregisterComponent(entityID, _componentTypeID, _maskBit); _listeners.InvokeOnDel(entityID, _listenersCachedCount); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void TryDel(int entityID) { if (Has(entityID)) @@ -120,16 +121,13 @@ namespace DCFApixels.DragonECS } public void Set(int entityID, bool isHas) { - if (isHas) + if (isHas != Has(entityID)) { - if (!Has(entityID)) + if (isHas) { Add(entityID); } - } - else - { - if (Has(entityID)) + else { Del(entityID); } @@ -228,13 +226,13 @@ namespace DCFApixels.DragonECS #region Listeners public void AddListener(IEcsPoolEventListener listener) { - if (listener == null) { throw new ArgumentNullException("listener is null"); } + if (listener == null) { EcsPoolThrowHalper.ThrowNullListener(); } _listeners.Add(listener); _listenersCachedCount++; } public void RemoveListener(IEcsPoolEventListener listener) { - if (listener == null) { throw new ArgumentNullException("listener is null"); } + if (listener == null) { EcsPoolThrowHalper.ThrowNullListener(); } if (_listeners.Remove(listener)) { _listenersCachedCount--;