From df52ec1f8702fd0f877136b2676eb6e75b16761d Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 22 Apr 2024 17:20:31 +0800 Subject: [PATCH] fix field naming --- src/EcsAspect.cs | 20 +++++------ src/EcsMask.cs | 86 ++++++++++++++++++++++++------------------------ src/EcsWorld.cs | 10 +++--- 3 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/EcsAspect.cs b/src/EcsAspect.cs index 67eba0b..105556a 100644 --- a/src/EcsAspect.cs +++ b/src/EcsAspect.cs @@ -141,27 +141,27 @@ namespace DCFApixels.DragonECS builder.Build(out newAspect._mask); newAspect._isBuilt = true; - newAspect._sortIncBuffer = new UnsafeArray(newAspect._mask.inc.Length, true); - newAspect._sortExcBuffer = new UnsafeArray(newAspect._mask.exc.Length, true); - newAspect._sortIncChunckBuffer = new UnsafeArray(newAspect._mask.incChunckMasks.Length, true); - newAspect._sortExcChunckBuffer = new UnsafeArray(newAspect._mask.excChunckMasks.Length, true); + newAspect._sortIncBuffer = new UnsafeArray(newAspect._mask._inc.Length, true); + newAspect._sortExcBuffer = new UnsafeArray(newAspect._mask._exc.Length, true); + newAspect._sortIncChunckBuffer = new UnsafeArray(newAspect._mask._incChunckMasks.Length, true); + newAspect._sortExcChunckBuffer = new UnsafeArray(newAspect._mask._excChunckMasks.Length, true); 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++) { - 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++) { - 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++) { - newAspect._sortExcChunckBuffer.ptr[i] = newAspect._mask.excChunckMasks[i]; + newAspect._sortExcChunckBuffer.ptr[i] = newAspect._mask._excChunckMasks[i]; } return (TAspect)newAspect; @@ -494,7 +494,7 @@ namespace DCFApixels.DragonECS public virtual void Apply(short worldID, int entityID) { EcsWorld world = EcsWorld.GetWorld(worldID); - foreach (var incTypeID in _mask.inc) + foreach (var incTypeID in _mask._inc) { var pool = world.GetPoolInstance(incTypeID); if (pool != null) @@ -511,7 +511,7 @@ namespace DCFApixels.DragonECS } } #endif - foreach (var excTypeID in _mask.exc) + foreach (var excTypeID in _mask._exc) { var pool = world.GetPoolInstance(excTypeID); if (pool != null && pool.Has(entityID)) diff --git a/src/EcsMask.cs b/src/EcsMask.cs index 1d41a72..5339dac 100644 --- a/src/EcsMask.cs +++ b/src/EcsMask.cs @@ -10,43 +10,43 @@ namespace DCFApixels.DragonECS [DebuggerTypeProxy(typeof(DebuggerProxy))] public sealed class EcsMask : IEquatable { - internal readonly int id; - internal readonly short worldID; - internal readonly EcsMaskChunck[] incChunckMasks; - internal readonly EcsMaskChunck[] excChunckMasks; - internal readonly int[] inc; //Sorted - internal readonly int[] exc; //Sorted + internal readonly int _id; + internal readonly short _worldID; + internal readonly EcsMaskChunck[] _incChunckMasks; + internal readonly EcsMaskChunck[] _excChunckMasks; + internal readonly int[] _inc; //Sorted + internal readonly int[] _exc; //Sorted #region Properties public int ID { - get { return id; } + get { return _id; } } public short WorldID { - get { return worldID; } + get { return _worldID; } } public EcsWorld World { - get { return EcsWorld.GetWorld(worldID); } + get { return EcsWorld.GetWorld(_worldID); } } /// Including constraints public ReadOnlySpan Inc { - get { return inc; } + get { return _inc; } } /// Excluding constraints public ReadOnlySpan Exc { - get { return exc; } + get { return _exc; } } public bool IsEmpty { - get { return inc.Length == 0 && exc.Length == 0; } + get { return _inc.Length == 0 && _exc.Length == 0; } } 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 @@ -73,13 +73,13 @@ namespace DCFApixels.DragonECS } private EcsMask(int id, short worldID, int[] inc, int[] exc) { - this.id = id; - this.inc = inc; - this.exc = exc; - this.worldID = worldID; + this._id = id; + this._inc = inc; + this._exc = exc; + this._worldID = worldID; - incChunckMasks = MakeMaskChuncsArray(inc); - excChunckMasks = MakeMaskChuncsArray(exc); + _incChunckMasks = MakeMaskChuncsArray(inc); + _excChunckMasks = MakeMaskChuncsArray(exc); } private unsafe EcsMaskChunck[] MakeMaskChuncsArray(int[] sortedArray) @@ -124,7 +124,7 @@ namespace DCFApixels.DragonECS } 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) @@ -150,7 +150,7 @@ namespace DCFApixels.DragonECS } 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) { @@ -196,19 +196,19 @@ namespace DCFApixels.DragonECS #region Object public override string ToString() { - return CreateLogString(worldID, inc, exc); + return CreateLogString(_worldID, _inc, _exc); } 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) { - return obj is EcsMask mask && id == mask.id && Equals(mask); + return obj is EcsMask mask && _id == mask._id && Equals(mask); } public override int GetHashCode() { - return unchecked(id ^ (worldID * EcsConsts.MAGIC_PRIME)); + return unchecked(_id ^ (_worldID * EcsConsts.MAGIC_PRIME)); } #endregion @@ -271,13 +271,13 @@ namespace DCFApixels.DragonECS { _source = mask; - ID = mask.id; - world = EcsWorld.GetWorld(mask.worldID); - _worldID = mask.worldID; - includedChunkMasks = mask.incChunckMasks; - excludedChunkMasks = mask.excChunckMasks; - included = mask.inc; - excluded = mask.exc; + ID = mask._id; + world = EcsWorld.GetWorld(mask._worldID); + _worldID = mask._worldID; + includedChunkMasks = mask._incChunckMasks; + excludedChunkMasks = mask._excChunckMasks; + included = mask._inc; + excluded = mask._exc; Type converter(int o) { return world.GetComponentType(o); } includedTypes = included.Select(converter).ToArray(); excludedTypes = excluded.Select(converter).ToArray(); @@ -349,8 +349,8 @@ namespace DCFApixels.DragonECS var masks = new Dictionary(256); EcsMask emptyMask = NewEmpty(0, world.id); EcsMask brokenMask = NewBroken(1, world.id); - masks.Add(new Key(emptyMask.inc, emptyMask.exc), emptyMask); - masks.Add(new Key(brokenMask.inc, brokenMask.exc), brokenMask); + masks.Add(new Key(emptyMask._inc, emptyMask._exc), emptyMask); + masks.Add(new Key(brokenMask._inc, brokenMask._exc), brokenMask); component = new WorldMaskComponent(world, masks, new Dictionary(256), emptyMask, brokenMask); } public void OnDestroy(ref WorldMaskComponent component, EcsWorld world) @@ -365,14 +365,14 @@ namespace DCFApixels.DragonECS internal EcsMask ExceptMask(EcsMask a, EcsMask b) { 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)) { return a.World.Get().BrokenMask; } 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; } @@ -566,10 +566,10 @@ namespace DCFApixels.DragonECS foreach (var item in _combineds) { EcsMask submask = item.mask; - combinedInc.ExceptWith(submask.exc);//удаляю конфликтующие ограничения - combinedExc.ExceptWith(submask.inc);//удаляю конфликтующие ограничения - combinedInc.UnionWith(submask.inc); - combinedExc.UnionWith(submask.exc); + combinedInc.ExceptWith(submask._exc);//удаляю конфликтующие ограничения + combinedExc.ExceptWith(submask._inc);//удаляю конфликтующие ограничения + combinedInc.UnionWith(submask._inc); + combinedExc.UnionWith(submask._exc); } combinedInc.ExceptWith(_exc);//удаляю конфликтующие ограничения combinedExc.ExceptWith(_inc);//удаляю конфликтующие ограничения @@ -585,14 +585,14 @@ 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(); return _world.Get().BrokenMask; } - combinedInc.ExceptWith(item.mask.inc); - combinedExc.ExceptWith(item.mask.exc); + combinedInc.ExceptWith(item.mask._inc); + combinedExc.ExceptWith(item.mask._exc); } } diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index 68b33d4..7c176a9 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -357,18 +357,18 @@ namespace DCFApixels.DragonECS public bool IsMatchesMask(EcsMask mask, int entityID) { #if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS - if (mask.worldID != id) { Throw.World_MaskDoesntBelongWorld(); } + if (mask._worldID != id) { Throw.World_MaskDoesntBelongWorld(); } #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; } } - 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; }