mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
polishing
This commit is contained in:
parent
32444868e1
commit
bc4375808d
@ -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<EcsDefaultWorld>();
|
||||
}
|
||||
}
|
||||
[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<EcsDefaultWorld>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
36
src/EcsPreFilter.cs
Normal file
36
src/EcsPreFilter.cs
Normal file
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -6,10 +6,7 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
public static EcsPipeline.Builder Inject<T>(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)
|
||||
{
|
||||
|
@ -5,6 +5,8 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DCFApixels.DragonECS.Internal
|
||||
{
|
||||
//TODO разработать возможность ручного устанавливания ID типам.
|
||||
//это нужно для упрощения разработки сетевух
|
||||
internal static class EcsTypeCode
|
||||
{
|
||||
private static readonly Dictionary<Type, int> _codes = new Dictionary<Type, int>();
|
||||
|
@ -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--;
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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--;
|
||||
|
Loading…
Reference in New Issue
Block a user