From 8dc8236f7e4ced97fe9f57ca043e4815ef4db178 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Tue, 30 May 2023 16:01:16 +0800 Subject: [PATCH] rename write methods to get --- src/Pools/EcsPool.cs | 18 +++++++++--------- src/Pools/EcsPoolBase.cs | 16 ++++++++-------- src/Pools/EcsTagPool.cs | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Pools/EcsPool.cs b/src/Pools/EcsPool.cs index 2fff699..0cc1082 100644 --- a/src/Pools/EcsPool.cs +++ b/src/Pools/EcsPool.cs @@ -74,18 +74,18 @@ namespace DCFApixels.DragonECS Array.Resize(ref _items, _items.Length << 1); } this.IncrementEntityComponentCount(entityID); - _listeners.InvokeOnAddAndWrite(entityID); + _listeners.InvokeOnAddAndGet(entityID); return ref _items[itemIndex]; // } } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public ref T Write(int entityID) + public ref T Get(int entityID) { // using (_writeMark.Auto()) #if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS if (!Has(entityID)) ThrowNotHaveComponent(entityID); #endif - _listeners.InvokeOnWrite(entityID); + _listeners.InvokeOnGet(entityID); return ref _items[_mapping[entityID]]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -97,7 +97,7 @@ namespace DCFApixels.DragonECS #endif return ref _items[_mapping[entityID]]; } - public ref T TryAddOrWrite(int entityID) + public ref T TryAddOrGet(int entityID) { ref int itemIndex = ref _mapping[entityID]; if (itemIndex <= 0) @@ -116,7 +116,7 @@ namespace DCFApixels.DragonECS this.IncrementEntityComponentCount(entityID); _listeners.InvokeOnAdd(entityID); } - _listeners.InvokeOnWrite(entityID); + _listeners.InvokeOnGet(entityID); return ref _items[itemIndex]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -148,14 +148,14 @@ namespace DCFApixels.DragonECS #if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS if (!Has(fromEntityID)) ThrowNotHaveComponent(fromEntityID); #endif - _componentCopyHandler.Copy(ref Write(fromEntityID), ref TryAddOrWrite(toEntityID)); + _componentCopyHandler.Copy(ref Get(fromEntityID), ref TryAddOrGet(toEntityID)); } public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID) { #if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS if (!Has(fromEntityID)) ThrowNotHaveComponent(fromEntityID); #endif - _componentCopyHandler.Copy(ref Write(fromEntityID), ref toWorld.GetPool().TryAddOrWrite(toEntityID)); + _componentCopyHandler.Copy(ref Get(fromEntityID), ref toWorld.GetPool().TryAddOrGet(toEntityID)); } #endregion @@ -175,9 +175,9 @@ namespace DCFApixels.DragonECS #region Other void IEcsPool.AddRaw(int entityID, object dataRaw) => Add(entityID) = (T)dataRaw; object IEcsPool.GetRaw(int entityID) => Read(entityID); - void IEcsPool.SetRaw(int entityID, object dataRaw) => Write(entityID) = (T)dataRaw; + void IEcsPool.SetRaw(int entityID, object dataRaw) => Get(entityID) = (T)dataRaw; ref readonly T IEcsPool.Read(int entityID) => ref Read(entityID); - ref T IEcsPool.Write(int entityID) => ref Write(entityID); + ref T IEcsPool.Get(int entityID) => ref Get(entityID); #endregion #region Listeners diff --git a/src/Pools/EcsPoolBase.cs b/src/Pools/EcsPoolBase.cs index 155a477..5dfe6c6 100644 --- a/src/Pools/EcsPoolBase.cs +++ b/src/Pools/EcsPoolBase.cs @@ -35,7 +35,7 @@ namespace DCFApixels.DragonECS { ref T Add(int entityID); ref readonly T Read(int entityID); - ref T Write(int entityID); + ref T Get(int entityID); } /// Only used to implement a custom pool. In other contexts use IEcsPool or IEcsPool. public interface IEcsPoolImplementation : IEcsPool @@ -106,7 +106,7 @@ namespace DCFApixels.DragonECS void IEcsPool.Copy(int fromEntityID, EcsWorld toWorld, int toEntityID) => throw new NotImplementedException(); ref NullComponent IEcsPool.Add(int entityID) => throw new NotImplementedException(); ref readonly NullComponent IEcsPool.Read(int entityID) => throw new NotImplementedException(); - ref NullComponent IEcsPool.Write(int entityID) => throw new NotImplementedException(); + ref NullComponent IEcsPool.Get(int entityID) => throw new NotImplementedException(); #endregion #region Callbacks @@ -203,8 +203,8 @@ namespace DCFApixels.DragonECS { /// Called after adding an entity to the pool, but before changing values. void OnAdd(int entityID); - /// Is called when EcsPool.Write or EcsPool.Add is called, but before changing values. - void OnWrite(int entityID); + /// Is called when EcsPool.Get or EcsPool.Add is called, but before changing values. + void OnGet(int entityID); /// Called after deleting an entity from the pool void OnDel(int entityID); } @@ -216,18 +216,18 @@ namespace DCFApixels.DragonECS for (int i = 0, iMax = self.Count; i < iMax; i++) self[i].OnAdd(entityID); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void InvokeOnAddAndWrite(this List self, int entityID) + public static void InvokeOnAddAndGet(this List self, int entityID) { for (int i = 0, iMax = self.Count; i < iMax; i++) { self[i].OnAdd(entityID); - self[i].OnWrite(entityID); + self[i].OnGet(entityID); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void InvokeOnWrite(this List self, int entityID) + public static void InvokeOnGet(this List self, int entityID) { - for (int i = 0, iMax = self.Count; i < iMax; i++) self[i].OnWrite(entityID); + for (int i = 0, iMax = self.Count; i < iMax; i++) self[i].OnGet(entityID); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void InvokeOnDel(this List self, int entityID) diff --git a/src/Pools/EcsTagPool.cs b/src/Pools/EcsTagPool.cs index 75a670b..7d5708e 100644 --- a/src/Pools/EcsTagPool.cs +++ b/src/Pools/EcsTagPool.cs @@ -143,7 +143,7 @@ namespace DCFApixels.DragonECS #endif return ref _fakeComponent; } - ref T IEcsPool.Write(int entityID) + ref T IEcsPool.Get(int entityID) { #if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS if (!Has(entityID)) ThrowNotHaveComponent(entityID);