add new getter methods to EcsWorld

This commit is contained in:
Mikhail 2023-07-03 02:44:35 +08:00
parent 143faf24e0
commit a11c7de42c
2 changed files with 17 additions and 0 deletions

View File

@ -108,6 +108,17 @@ namespace DCFApixels.DragonECS
{ {
return UncheckedGet<PoolCache<TPool>>().instance; return UncheckedGet<PoolCache<TPool>>().instance;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPool GetPool<TPool>(int worldID) where TPool : IEcsPoolImplementation, new()
{
return Get<PoolCache<TPool>>(worldID).instance;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TPool UncheckedGetPool<TPool>(int worldID) where TPool : IEcsPoolImplementation, new()
{
return UncheckedGet<PoolCache<TPool>>(worldID).instance;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public TAspect GetAspect<TAspect>() where TAspect : EcsAspect public TAspect GetAspect<TAspect>() where TAspect : EcsAspect
{ {
@ -123,6 +134,10 @@ namespace DCFApixels.DragonECS
public ref T Get<T>() where T : struct => ref WorldComponentPool<T>.GetForWorld(id); public ref T Get<T>() where T : struct => ref WorldComponentPool<T>.GetForWorld(id);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public ref T UncheckedGet<T>() where T : struct => ref WorldComponentPool<T>.UncheckedGetForWorld(id); public ref T UncheckedGet<T>() where T : struct => ref WorldComponentPool<T>.UncheckedGetForWorld(id);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T Get<T>(int worldID) where T : struct => ref WorldComponentPool<T>.GetForWorld(worldID);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T UncheckedGet<T>(int worldID) where T : struct => ref WorldComponentPool<T>.UncheckedGetForWorld(worldID);
#endregion #endregion
#region Where Query #region Where Query

View File

@ -39,6 +39,8 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T GetData<T>(int worldID) => ref WorldComponentPool<T>.GetForWorld(worldID); public static ref T GetData<T>(int worldID) => ref WorldComponentPool<T>.GetForWorld(worldID);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T UncheckedGetData<T>(int worldID) => ref WorldComponentPool<T>.UncheckedGetForWorld(worldID);
private abstract class DataReleaser private abstract class DataReleaser
{ {