mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 09:54:35 +08:00
fix field naming
This commit is contained in:
parent
4ace55d4d7
commit
df52ec1f87
@ -141,27 +141,27 @@ namespace DCFApixels.DragonECS
|
|||||||
builder.Build(out newAspect._mask);
|
builder.Build(out newAspect._mask);
|
||||||
newAspect._isBuilt = true;
|
newAspect._isBuilt = true;
|
||||||
|
|
||||||
newAspect._sortIncBuffer = new UnsafeArray<int>(newAspect._mask.inc.Length, true);
|
newAspect._sortIncBuffer = new UnsafeArray<int>(newAspect._mask._inc.Length, true);
|
||||||
newAspect._sortExcBuffer = new UnsafeArray<int>(newAspect._mask.exc.Length, true);
|
newAspect._sortExcBuffer = new UnsafeArray<int>(newAspect._mask._exc.Length, true);
|
||||||
newAspect._sortIncChunckBuffer = new UnsafeArray<EcsMaskChunck>(newAspect._mask.incChunckMasks.Length, true);
|
newAspect._sortIncChunckBuffer = new UnsafeArray<EcsMaskChunck>(newAspect._mask._incChunckMasks.Length, true);
|
||||||
newAspect._sortExcChunckBuffer = new UnsafeArray<EcsMaskChunck>(newAspect._mask.excChunckMasks.Length, true);
|
newAspect._sortExcChunckBuffer = new UnsafeArray<EcsMaskChunck>(newAspect._mask._excChunckMasks.Length, true);
|
||||||
|
|
||||||
for (int i = 0; i < newAspect._sortIncBuffer.Length; i++)
|
for (int i = 0; i < newAspect._sortIncBuffer.Length; i++)
|
||||||
{
|
{
|
||||||
newAspect._sortIncBuffer.ptr[i] = newAspect._mask.inc[i];
|
newAspect._sortIncBuffer.ptr[i] = newAspect._mask._inc[i];
|
||||||
}
|
}
|
||||||
for (int i = 0; i < newAspect._sortExcBuffer.Length; i++)
|
for (int i = 0; i < newAspect._sortExcBuffer.Length; i++)
|
||||||
{
|
{
|
||||||
newAspect._sortExcBuffer.ptr[i] = newAspect._mask.exc[i];
|
newAspect._sortExcBuffer.ptr[i] = newAspect._mask._exc[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < newAspect._sortIncChunckBuffer.Length; i++)
|
for (int i = 0; i < newAspect._sortIncChunckBuffer.Length; i++)
|
||||||
{
|
{
|
||||||
newAspect._sortIncChunckBuffer.ptr[i] = newAspect._mask.incChunckMasks[i];
|
newAspect._sortIncChunckBuffer.ptr[i] = newAspect._mask._incChunckMasks[i];
|
||||||
}
|
}
|
||||||
for (int i = 0; i < newAspect._sortExcChunckBuffer.Length; i++)
|
for (int i = 0; i < newAspect._sortExcChunckBuffer.Length; i++)
|
||||||
{
|
{
|
||||||
newAspect._sortExcChunckBuffer.ptr[i] = newAspect._mask.excChunckMasks[i];
|
newAspect._sortExcChunckBuffer.ptr[i] = newAspect._mask._excChunckMasks[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TAspect)newAspect;
|
return (TAspect)newAspect;
|
||||||
@ -494,7 +494,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public virtual void Apply(short worldID, int entityID)
|
public virtual void Apply(short worldID, int entityID)
|
||||||
{
|
{
|
||||||
EcsWorld world = EcsWorld.GetWorld(worldID);
|
EcsWorld world = EcsWorld.GetWorld(worldID);
|
||||||
foreach (var incTypeID in _mask.inc)
|
foreach (var incTypeID in _mask._inc)
|
||||||
{
|
{
|
||||||
var pool = world.GetPoolInstance(incTypeID);
|
var pool = world.GetPoolInstance(incTypeID);
|
||||||
if (pool != null)
|
if (pool != null)
|
||||||
@ -511,7 +511,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
foreach (var excTypeID in _mask.exc)
|
foreach (var excTypeID in _mask._exc)
|
||||||
{
|
{
|
||||||
var pool = world.GetPoolInstance(excTypeID);
|
var pool = world.GetPoolInstance(excTypeID);
|
||||||
if (pool != null && pool.Has(entityID))
|
if (pool != null && pool.Has(entityID))
|
||||||
|
@ -10,43 +10,43 @@ namespace DCFApixels.DragonECS
|
|||||||
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
||||||
public sealed class EcsMask : IEquatable<EcsMask>
|
public sealed class EcsMask : IEquatable<EcsMask>
|
||||||
{
|
{
|
||||||
internal readonly int id;
|
internal readonly int _id;
|
||||||
internal readonly short worldID;
|
internal readonly short _worldID;
|
||||||
internal readonly EcsMaskChunck[] incChunckMasks;
|
internal readonly EcsMaskChunck[] _incChunckMasks;
|
||||||
internal readonly EcsMaskChunck[] excChunckMasks;
|
internal readonly EcsMaskChunck[] _excChunckMasks;
|
||||||
internal readonly int[] inc; //Sorted
|
internal readonly int[] _inc; //Sorted
|
||||||
internal readonly int[] exc; //Sorted
|
internal readonly int[] _exc; //Sorted
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
public int ID
|
public int ID
|
||||||
{
|
{
|
||||||
get { return id; }
|
get { return _id; }
|
||||||
}
|
}
|
||||||
public short WorldID
|
public short WorldID
|
||||||
{
|
{
|
||||||
get { return worldID; }
|
get { return _worldID; }
|
||||||
}
|
}
|
||||||
public EcsWorld World
|
public EcsWorld World
|
||||||
{
|
{
|
||||||
get { return EcsWorld.GetWorld(worldID); }
|
get { return EcsWorld.GetWorld(_worldID); }
|
||||||
}
|
}
|
||||||
/// <summary>Including constraints</summary>
|
/// <summary>Including constraints</summary>
|
||||||
public ReadOnlySpan<int> Inc
|
public ReadOnlySpan<int> Inc
|
||||||
{
|
{
|
||||||
get { return inc; }
|
get { return _inc; }
|
||||||
}
|
}
|
||||||
/// <summary>Excluding constraints</summary>
|
/// <summary>Excluding constraints</summary>
|
||||||
public ReadOnlySpan<int> Exc
|
public ReadOnlySpan<int> Exc
|
||||||
{
|
{
|
||||||
get { return exc; }
|
get { return _exc; }
|
||||||
}
|
}
|
||||||
public bool IsEmpty
|
public bool IsEmpty
|
||||||
{
|
{
|
||||||
get { return inc.Length == 0 && exc.Length == 0; }
|
get { return _inc.Length == 0 && _exc.Length == 0; }
|
||||||
}
|
}
|
||||||
public bool IsBroken
|
public bool IsBroken
|
||||||
{
|
{
|
||||||
get { return (inc.Length & exc.Length) == 1 && inc[0] == exc[0]; }
|
get { return (_inc.Length & _exc.Length) == 1 && _inc[0] == _exc[0]; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -73,13 +73,13 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
private EcsMask(int id, short worldID, int[] inc, int[] exc)
|
private EcsMask(int id, short worldID, int[] inc, int[] exc)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this._id = id;
|
||||||
this.inc = inc;
|
this._inc = inc;
|
||||||
this.exc = exc;
|
this._exc = exc;
|
||||||
this.worldID = worldID;
|
this._worldID = worldID;
|
||||||
|
|
||||||
incChunckMasks = MakeMaskChuncsArray(inc);
|
_incChunckMasks = MakeMaskChuncsArray(inc);
|
||||||
excChunckMasks = MakeMaskChuncsArray(exc);
|
_excChunckMasks = MakeMaskChuncsArray(exc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe EcsMaskChunck[] MakeMaskChuncsArray(int[] sortedArray)
|
private unsafe EcsMaskChunck[] MakeMaskChuncsArray(int[] sortedArray)
|
||||||
@ -124,7 +124,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
public bool IsConflictWith(EcsMask otherMask)
|
public bool IsConflictWith(EcsMask otherMask)
|
||||||
{
|
{
|
||||||
return OverlapsArray(inc, otherMask.exc) || OverlapsArray(exc, otherMask.inc);
|
return OverlapsArray(_inc, otherMask._exc) || OverlapsArray(_exc, otherMask._inc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool OverlapsArray(int[] l, int[] r)
|
private static bool OverlapsArray(int[] l, int[] r)
|
||||||
@ -150,7 +150,7 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
private static bool IsSubmask(EcsMask super, EcsMask sub)
|
private static bool IsSubmask(EcsMask super, EcsMask sub)
|
||||||
{
|
{
|
||||||
return IsSubarray(sub.inc, super.inc) && IsSuperarray(sub.exc, super.exc);
|
return IsSubarray(sub._inc, super._inc) && IsSuperarray(sub._exc, super._exc);
|
||||||
}
|
}
|
||||||
private static bool IsSubarray(int[] super, int[] sub)
|
private static bool IsSubarray(int[] super, int[] sub)
|
||||||
{
|
{
|
||||||
@ -196,19 +196,19 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Object
|
#region Object
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return CreateLogString(worldID, inc, exc);
|
return CreateLogString(_worldID, _inc, _exc);
|
||||||
}
|
}
|
||||||
public bool Equals(EcsMask mask)
|
public bool Equals(EcsMask mask)
|
||||||
{
|
{
|
||||||
return id == mask.id && worldID == mask.worldID;
|
return _id == mask._id && _worldID == mask._worldID;
|
||||||
}
|
}
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
return obj is EcsMask mask && id == mask.id && Equals(mask);
|
return obj is EcsMask mask && _id == mask._id && Equals(mask);
|
||||||
}
|
}
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return unchecked(id ^ (worldID * EcsConsts.MAGIC_PRIME));
|
return unchecked(_id ^ (_worldID * EcsConsts.MAGIC_PRIME));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -271,13 +271,13 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
_source = mask;
|
_source = mask;
|
||||||
|
|
||||||
ID = mask.id;
|
ID = mask._id;
|
||||||
world = EcsWorld.GetWorld(mask.worldID);
|
world = EcsWorld.GetWorld(mask._worldID);
|
||||||
_worldID = mask.worldID;
|
_worldID = mask._worldID;
|
||||||
includedChunkMasks = mask.incChunckMasks;
|
includedChunkMasks = mask._incChunckMasks;
|
||||||
excludedChunkMasks = mask.excChunckMasks;
|
excludedChunkMasks = mask._excChunckMasks;
|
||||||
included = mask.inc;
|
included = mask._inc;
|
||||||
excluded = mask.exc;
|
excluded = mask._exc;
|
||||||
Type converter(int o) { return world.GetComponentType(o); }
|
Type converter(int o) { return world.GetComponentType(o); }
|
||||||
includedTypes = included.Select(converter).ToArray();
|
includedTypes = included.Select(converter).ToArray();
|
||||||
excludedTypes = excluded.Select(converter).ToArray();
|
excludedTypes = excluded.Select(converter).ToArray();
|
||||||
@ -349,8 +349,8 @@ namespace DCFApixels.DragonECS
|
|||||||
var masks = new Dictionary<Key, EcsMask>(256);
|
var masks = new Dictionary<Key, EcsMask>(256);
|
||||||
EcsMask emptyMask = NewEmpty(0, world.id);
|
EcsMask emptyMask = NewEmpty(0, world.id);
|
||||||
EcsMask brokenMask = NewBroken(1, world.id);
|
EcsMask brokenMask = NewBroken(1, world.id);
|
||||||
masks.Add(new Key(emptyMask.inc, emptyMask.exc), emptyMask);
|
masks.Add(new Key(emptyMask._inc, emptyMask._exc), emptyMask);
|
||||||
masks.Add(new Key(brokenMask.inc, brokenMask.exc), brokenMask);
|
masks.Add(new Key(brokenMask._inc, brokenMask._exc), brokenMask);
|
||||||
component = new WorldMaskComponent(world, masks, new Dictionary<OpMaskKey, EcsMask>(256), emptyMask, brokenMask);
|
component = new WorldMaskComponent(world, masks, new Dictionary<OpMaskKey, EcsMask>(256), emptyMask, brokenMask);
|
||||||
}
|
}
|
||||||
public void OnDestroy(ref WorldMaskComponent component, EcsWorld world)
|
public void OnDestroy(ref WorldMaskComponent component, EcsWorld world)
|
||||||
@ -365,14 +365,14 @@ namespace DCFApixels.DragonECS
|
|||||||
internal EcsMask ExceptMask(EcsMask a, EcsMask b)
|
internal EcsMask ExceptMask(EcsMask a, EcsMask b)
|
||||||
{
|
{
|
||||||
int operation = OpMaskKey.EXCEPT_OP;
|
int operation = OpMaskKey.EXCEPT_OP;
|
||||||
if (_opMasks.TryGetValue(new OpMaskKey(a.id, b.id, operation), out EcsMask result) == false)
|
if (_opMasks.TryGetValue(new OpMaskKey(a._id, b._id, operation), out EcsMask result) == false)
|
||||||
{
|
{
|
||||||
if (a.IsConflictWith(b))
|
if (a.IsConflictWith(b))
|
||||||
{
|
{
|
||||||
return a.World.Get<WorldMaskComponent>().BrokenMask;
|
return a.World.Get<WorldMaskComponent>().BrokenMask;
|
||||||
}
|
}
|
||||||
result = New(a.World).Combine(a).Except(b).Build();
|
result = New(a.World).Combine(a).Except(b).Build();
|
||||||
_opMasks.Add(new OpMaskKey(a.id, b.id, operation), result);
|
_opMasks.Add(new OpMaskKey(a._id, b._id, operation), result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -566,10 +566,10 @@ namespace DCFApixels.DragonECS
|
|||||||
foreach (var item in _combineds)
|
foreach (var item in _combineds)
|
||||||
{
|
{
|
||||||
EcsMask submask = item.mask;
|
EcsMask submask = item.mask;
|
||||||
combinedInc.ExceptWith(submask.exc);//удаляю конфликтующие ограничения
|
combinedInc.ExceptWith(submask._exc);//удаляю конфликтующие ограничения
|
||||||
combinedExc.ExceptWith(submask.inc);//удаляю конфликтующие ограничения
|
combinedExc.ExceptWith(submask._inc);//удаляю конфликтующие ограничения
|
||||||
combinedInc.UnionWith(submask.inc);
|
combinedInc.UnionWith(submask._inc);
|
||||||
combinedExc.UnionWith(submask.exc);
|
combinedExc.UnionWith(submask._exc);
|
||||||
}
|
}
|
||||||
combinedInc.ExceptWith(_exc);//удаляю конфликтующие ограничения
|
combinedInc.ExceptWith(_exc);//удаляю конфликтующие ограничения
|
||||||
combinedExc.ExceptWith(_inc);//удаляю конфликтующие ограничения
|
combinedExc.ExceptWith(_inc);//удаляю конфликтующие ограничения
|
||||||
@ -585,14 +585,14 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
foreach (var item in _excepteds)
|
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();
|
_combineds.Clear();
|
||||||
_excepteds.Clear();
|
_excepteds.Clear();
|
||||||
return _world.Get<WorldMaskComponent>().BrokenMask;
|
return _world.Get<WorldMaskComponent>().BrokenMask;
|
||||||
}
|
}
|
||||||
combinedInc.ExceptWith(item.mask.inc);
|
combinedInc.ExceptWith(item.mask._inc);
|
||||||
combinedExc.ExceptWith(item.mask.exc);
|
combinedExc.ExceptWith(item.mask._exc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,18 +357,18 @@ namespace DCFApixels.DragonECS
|
|||||||
public bool IsMatchesMask(EcsMask mask, int entityID)
|
public bool IsMatchesMask(EcsMask mask, int entityID)
|
||||||
{
|
{
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
if (mask.worldID != id) { Throw.World_MaskDoesntBelongWorld(); }
|
if (mask._worldID != id) { Throw.World_MaskDoesntBelongWorld(); }
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0, iMax = mask.incChunckMasks.Length; i < iMax; i++)
|
for (int i = 0, iMax = mask._incChunckMasks.Length; i < iMax; i++)
|
||||||
{
|
{
|
||||||
if (!_pools[mask.inc[i]].Has(entityID))
|
if (!_pools[mask._inc[i]].Has(entityID))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0, iMax = mask.excChunckMasks.Length; i < iMax; i++)
|
for (int i = 0, iMax = mask._excChunckMasks.Length; i < iMax; i++)
|
||||||
{
|
{
|
||||||
if (_pools[mask.exc[i]].Has(entityID))
|
if (_pools[mask._exc[i]].Has(entityID))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user