From a11c7de42cb9e8a2a88fdc5d9233be80f01dc834 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 3 Jul 2023 02:44:35 +0800 Subject: [PATCH] add new getter methods to EcsWorld --- src/EcsWorld.cs | 15 +++++++++++++++ src/EcsWorld.static.cs | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index 415e8b0..f36f4b1 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -108,6 +108,17 @@ namespace DCFApixels.DragonECS { return UncheckedGet>().instance; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPool GetPool(int worldID) where TPool : IEcsPoolImplementation, new() + { + return Get>(worldID).instance; + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TPool UncheckedGetPool(int worldID) where TPool : IEcsPoolImplementation, new() + { + return UncheckedGet>(worldID).instance; + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public TAspect GetAspect() where TAspect : EcsAspect { @@ -123,6 +134,10 @@ namespace DCFApixels.DragonECS public ref T Get() where T : struct => ref WorldComponentPool.GetForWorld(id); [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T UncheckedGet() where T : struct => ref WorldComponentPool.UncheckedGetForWorld(id); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ref T Get(int worldID) where T : struct => ref WorldComponentPool.GetForWorld(worldID); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ref T UncheckedGet(int worldID) where T : struct => ref WorldComponentPool.UncheckedGetForWorld(worldID); #endregion #region Where Query diff --git a/src/EcsWorld.static.cs b/src/EcsWorld.static.cs index 91b36be..8237000 100644 --- a/src/EcsWorld.static.cs +++ b/src/EcsWorld.static.cs @@ -39,6 +39,8 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T GetData(int worldID) => ref WorldComponentPool.GetForWorld(worldID); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ref T UncheckedGetData(int worldID) => ref WorldComponentPool.UncheckedGetForWorld(worldID); private abstract class DataReleaser {