From 67fb791544e141c421ae3e8b23671177b0dcc36d Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:55:34 +0800 Subject: [PATCH] simple refactoring --- src/EcsAspect.cs | 70 +++++++++++++++++++++---------------------- src/EcsRunner.cs | 2 +- src/EcsWorld.pools.cs | 4 +-- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/EcsAspect.cs b/src/EcsAspect.cs index 145cfc8..7d1a87c 100644 --- a/src/EcsAspect.cs +++ b/src/EcsAspect.cs @@ -31,39 +31,39 @@ namespace DCFApixels.DragonECS } #region IEcsAspectExtensions tmp -// public static class IEcsAspectExtensions -// { -// public static void Apply(this IEcsAspect aspect, short worldID, int entityID) -// { -// EcsWorld world = EcsWorld.GetWorld(worldID); -// EcsMask mask = aspect.Mask; -// foreach (var incTypeID in mask._incs) -// { -// var pool = world.FindPoolInstance(incTypeID); -// if (pool != null) -// { -// if (pool.Has(entityID) == false) -// { -// pool.AddEmpty(entityID); -// } -// } -//#if DEBUG -// else -// { -// EcsDebug.PrintWarning("Component has not been added because the pool has not been initialized yet."); -// } -//#endif -// } -// foreach (var excTypeID in mask._excs) -// { -// var pool = world.FindPoolInstance(excTypeID); -// if (pool != null && pool.Has(entityID)) -// { -// pool.Del(entityID); -// } -// } -// } -// } + // public static class IEcsAspectExtensions + // { + // public static void Apply(this IEcsAspect aspect, short worldID, int entityID) + // { + // EcsWorld world = EcsWorld.GetWorld(worldID); + // EcsMask mask = aspect.Mask; + // foreach (var incTypeID in mask._incs) + // { + // var pool = world.FindPoolInstance(incTypeID); + // if (pool != null) + // { + // if (pool.Has(entityID) == false) + // { + // pool.AddEmpty(entityID); + // } + // } + //#if DEBUG + // else + // { + // EcsDebug.PrintWarning("Component has not been added because the pool has not been initialized yet."); + // } + //#endif + // } + // foreach (var excTypeID in mask._excs) + // { + // var pool = world.FindPoolInstance(excTypeID); + // if (pool != null && pool.Has(entityID)) + // { + // pool.Del(entityID); + // } + // } + // } + // } #endregion public static partial class API @@ -227,7 +227,7 @@ namespace DCFApixels.DragonECS //Building TAspect newAspect = new TAspect(); EcsAspect builtinAspect = newAspect as EcsAspect; - if(builtinAspect != null) + if (builtinAspect != null) { builtinAspect._source = world; builtinAspect.Init(builder); @@ -244,7 +244,7 @@ namespace DCFApixels.DragonECS } } EcsMask mask = staticMask.ToMask(world); - if(builtinAspect != null) + if (builtinAspect != null) { builtinAspect._mask = mask; //var pools = new IEcsPool[builder._poolsBufferCount]; diff --git a/src/EcsRunner.cs b/src/EcsRunner.cs index 7a30daa..67ad62a 100644 --- a/src/EcsRunner.cs +++ b/src/EcsRunner.cs @@ -377,7 +377,7 @@ namespace DCFApixels.DragonECS } finally { - if(pair.runFinally != null) + if (pair.runFinally != null) { translationFinnalyCallback(pair.runFinally); } diff --git a/src/EcsWorld.pools.cs b/src/EcsWorld.pools.cs index 8c9e2f0..be0ba8e 100644 --- a/src/EcsWorld.pools.cs +++ b/src/EcsWorld.pools.cs @@ -8,8 +8,8 @@ namespace DCFApixels.DragonECS { public partial class EcsWorld { - private SparseArray _poolTypeCode_2_CmpTypeIDs = new SparseArray(); - private SparseArray _cmpTypeCode_2_CmpTypeIDs = new SparseArray(); + private readonly SparseArray _poolTypeCode_2_CmpTypeIDs = new SparseArray(); + private readonly SparseArray _cmpTypeCode_2_CmpTypeIDs = new SparseArray(); internal IEcsPoolImplementation[] _pools; internal PoolSlot[] _poolSlots;