mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 18:14:37 +08:00
rename write methods to get
This commit is contained in:
parent
b73101d18c
commit
8dc8236f7e
@ -74,18 +74,18 @@ namespace DCFApixels.DragonECS
|
|||||||
Array.Resize(ref _items, _items.Length << 1);
|
Array.Resize(ref _items, _items.Length << 1);
|
||||||
}
|
}
|
||||||
this.IncrementEntityComponentCount(entityID);
|
this.IncrementEntityComponentCount(entityID);
|
||||||
_listeners.InvokeOnAddAndWrite(entityID);
|
_listeners.InvokeOnAddAndGet(entityID);
|
||||||
return ref _items[itemIndex];
|
return ref _items[itemIndex];
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public ref T Write(int entityID)
|
public ref T Get(int entityID)
|
||||||
{
|
{
|
||||||
// using (_writeMark.Auto())
|
// using (_writeMark.Auto())
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
if (!Has(entityID)) ThrowNotHaveComponent<T>(entityID);
|
if (!Has(entityID)) ThrowNotHaveComponent<T>(entityID);
|
||||||
#endif
|
#endif
|
||||||
_listeners.InvokeOnWrite(entityID);
|
_listeners.InvokeOnGet(entityID);
|
||||||
return ref _items[_mapping[entityID]];
|
return ref _items[_mapping[entityID]];
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -97,7 +97,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endif
|
#endif
|
||||||
return ref _items[_mapping[entityID]];
|
return ref _items[_mapping[entityID]];
|
||||||
}
|
}
|
||||||
public ref T TryAddOrWrite(int entityID)
|
public ref T TryAddOrGet(int entityID)
|
||||||
{
|
{
|
||||||
ref int itemIndex = ref _mapping[entityID];
|
ref int itemIndex = ref _mapping[entityID];
|
||||||
if (itemIndex <= 0)
|
if (itemIndex <= 0)
|
||||||
@ -116,7 +116,7 @@ namespace DCFApixels.DragonECS
|
|||||||
this.IncrementEntityComponentCount(entityID);
|
this.IncrementEntityComponentCount(entityID);
|
||||||
_listeners.InvokeOnAdd(entityID);
|
_listeners.InvokeOnAdd(entityID);
|
||||||
}
|
}
|
||||||
_listeners.InvokeOnWrite(entityID);
|
_listeners.InvokeOnGet(entityID);
|
||||||
return ref _items[itemIndex];
|
return ref _items[itemIndex];
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -148,14 +148,14 @@ namespace DCFApixels.DragonECS
|
|||||||
#if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
if (!Has(fromEntityID)) ThrowNotHaveComponent<T>(fromEntityID);
|
if (!Has(fromEntityID)) ThrowNotHaveComponent<T>(fromEntityID);
|
||||||
#endif
|
#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)
|
public void Copy(int fromEntityID, EcsWorld toWorld, int toEntityID)
|
||||||
{
|
{
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
if (!Has(fromEntityID)) ThrowNotHaveComponent<T>(fromEntityID);
|
if (!Has(fromEntityID)) ThrowNotHaveComponent<T>(fromEntityID);
|
||||||
#endif
|
#endif
|
||||||
_componentCopyHandler.Copy(ref Write(fromEntityID), ref toWorld.GetPool<T>().TryAddOrWrite(toEntityID));
|
_componentCopyHandler.Copy(ref Get(fromEntityID), ref toWorld.GetPool<T>().TryAddOrGet(toEntityID));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -175,9 +175,9 @@ namespace DCFApixels.DragonECS
|
|||||||
#region Other
|
#region Other
|
||||||
void IEcsPool.AddRaw(int entityID, object dataRaw) => Add(entityID) = (T)dataRaw;
|
void IEcsPool.AddRaw(int entityID, object dataRaw) => Add(entityID) = (T)dataRaw;
|
||||||
object IEcsPool.GetRaw(int entityID) => Read(entityID);
|
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<T>.Read(int entityID) => ref Read(entityID);
|
ref readonly T IEcsPool<T>.Read(int entityID) => ref Read(entityID);
|
||||||
ref T IEcsPool<T>.Write(int entityID) => ref Write(entityID);
|
ref T IEcsPool<T>.Get(int entityID) => ref Get(entityID);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Listeners
|
#region Listeners
|
||||||
|
@ -35,7 +35,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
ref T Add(int entityID);
|
ref T Add(int entityID);
|
||||||
ref readonly T Read(int entityID);
|
ref readonly T Read(int entityID);
|
||||||
ref T Write(int entityID);
|
ref T Get(int entityID);
|
||||||
}
|
}
|
||||||
/// <summary>Only used to implement a custom pool. In other contexts use IEcsPool or IEcsPool<T>.</summary>
|
/// <summary>Only used to implement a custom pool. In other contexts use IEcsPool or IEcsPool<T>.</summary>
|
||||||
public interface IEcsPoolImplementation : IEcsPool
|
public interface IEcsPoolImplementation : IEcsPool
|
||||||
@ -106,7 +106,7 @@ namespace DCFApixels.DragonECS
|
|||||||
void IEcsPool.Copy(int fromEntityID, EcsWorld toWorld, int toEntityID) => throw new NotImplementedException();
|
void IEcsPool.Copy(int fromEntityID, EcsWorld toWorld, int toEntityID) => throw new NotImplementedException();
|
||||||
ref NullComponent IEcsPool<NullComponent>.Add(int entityID) => throw new NotImplementedException();
|
ref NullComponent IEcsPool<NullComponent>.Add(int entityID) => throw new NotImplementedException();
|
||||||
ref readonly NullComponent IEcsPool<NullComponent>.Read(int entityID) => throw new NotImplementedException();
|
ref readonly NullComponent IEcsPool<NullComponent>.Read(int entityID) => throw new NotImplementedException();
|
||||||
ref NullComponent IEcsPool<NullComponent>.Write(int entityID) => throw new NotImplementedException();
|
ref NullComponent IEcsPool<NullComponent>.Get(int entityID) => throw new NotImplementedException();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Callbacks
|
#region Callbacks
|
||||||
@ -203,8 +203,8 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
/// <summary>Called after adding an entity to the pool, but before changing values.</summary>
|
/// <summary>Called after adding an entity to the pool, but before changing values.</summary>
|
||||||
void OnAdd(int entityID);
|
void OnAdd(int entityID);
|
||||||
/// <summary>Is called when EcsPool.Write or EcsPool.Add is called, but before changing values.</summary>
|
/// <summary>Is called when EcsPool.Get or EcsPool.Add is called, but before changing values.</summary>
|
||||||
void OnWrite(int entityID);
|
void OnGet(int entityID);
|
||||||
/// <summary>Called after deleting an entity from the pool</summary>
|
/// <summary>Called after deleting an entity from the pool</summary>
|
||||||
void OnDel(int entityID);
|
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);
|
for (int i = 0, iMax = self.Count; i < iMax; i++) self[i].OnAdd(entityID);
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void InvokeOnAddAndWrite(this List<IEcsPoolEventListener> self, int entityID)
|
public static void InvokeOnAddAndGet(this List<IEcsPoolEventListener> self, int entityID)
|
||||||
{
|
{
|
||||||
for (int i = 0, iMax = self.Count; i < iMax; i++)
|
for (int i = 0, iMax = self.Count; i < iMax; i++)
|
||||||
{
|
{
|
||||||
self[i].OnAdd(entityID);
|
self[i].OnAdd(entityID);
|
||||||
self[i].OnWrite(entityID);
|
self[i].OnGet(entityID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void InvokeOnWrite(this List<IEcsPoolEventListener> self, int entityID)
|
public static void InvokeOnGet(this List<IEcsPoolEventListener> 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)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static void InvokeOnDel(this List<IEcsPoolEventListener> self, int entityID)
|
public static void InvokeOnDel(this List<IEcsPoolEventListener> self, int entityID)
|
||||||
|
@ -143,7 +143,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endif
|
#endif
|
||||||
return ref _fakeComponent;
|
return ref _fakeComponent;
|
||||||
}
|
}
|
||||||
ref T IEcsPool<T>.Write(int entityID)
|
ref T IEcsPool<T>.Get(int entityID)
|
||||||
{
|
{
|
||||||
#if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || !DISABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
if (!Has(entityID)) ThrowNotHaveComponent<T>(entityID);
|
if (!Has(entityID)) ThrowNotHaveComponent<T>(entityID);
|
||||||
|
Loading…
Reference in New Issue
Block a user