From 1cc630edba38c65d0a1b8c0e50d6c68a2a68834c Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Sat, 15 Mar 2025 22:27:57 +0800 Subject: [PATCH] add IEcsStructPool.NewEntity() --- src/Pools/EcsPoolBase.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Pools/EcsPoolBase.cs b/src/Pools/EcsPoolBase.cs index a34e156..172f933 100644 --- a/src/Pools/EcsPoolBase.cs +++ b/src/Pools/EcsPoolBase.cs @@ -249,6 +249,18 @@ namespace DCFApixels.DragonECS { return self == null || self == EcsNullPool.instance; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ref T NewEntity(this IEcsStructPool self) where T : struct + { + var e = self.World.NewEntity(); + return ref self.Add(e); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ref T NewEntity(this IEcsStructPool self, out int entityID) where T : struct + { + entityID = self.World.NewEntity(); + return ref self.Add(entityID); + } } #endregion