From 26f141fca9f286eb3e8349a1e3fffe855f538368 Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Wed, 19 Mar 2025 09:38:53 +0800 Subject: [PATCH 1/2] Update TypeMeta.cs --- src/DebugUtils/TypeMeta.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/DebugUtils/TypeMeta.cs b/src/DebugUtils/TypeMeta.cs index ed6869a..5d658f5 100644 --- a/src/DebugUtils/TypeMeta.cs +++ b/src/DebugUtils/TypeMeta.cs @@ -3,6 +3,7 @@ #endif using DCFApixels.DragonECS.Core; using DCFApixels.DragonECS.Internal; +using DCFApixels.DragonECS.PoolsCore; using System; using System.Collections.Generic; using System.Diagnostics; @@ -67,6 +68,7 @@ namespace DCFApixels.DragonECS private bool _isProcess; private bool _isComponent; + private bool _isPool; private InitFlag _initFlags = InitFlag.None; @@ -315,6 +317,18 @@ namespace DCFApixels.DragonECS return _isProcess; } } + public bool IsPool + { + get + { + if (_initFlags.HasFlag(InitFlag.ReflectionInfo) == false) + { + MetaGenerator.GetReflectionInfo(this); + _initFlags |= InitFlag.ReflectionInfo; + } + return _isPool; + } + } #endregion #region InitializeAll @@ -574,9 +588,9 @@ namespace DCFApixels.DragonECS #region GetReflectionInfo public static void GetReflectionInfo(TypeMeta meta) { - var interfaces = meta.Type.GetInterfaces(); - meta._isComponent = Array.IndexOf(interfaces, typeof(IEcsComponentMember)) >= 0; - meta._isProcess = Array.IndexOf(interfaces, typeof(IEcsProcess)) >= 0; + meta._isComponent = typeof(IEcsComponentMember).IsAssignableFrom(meta.Type); + meta._isProcess = typeof(IEcsProcess).IsAssignableFrom(meta.Type); + meta._isPool = typeof(IEcsPoolImplementation).IsAssignableFrom(meta.Type); } #endregion } From 760e3d7e0f0bc93843b5e9f2635e52dd65b26eab Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Wed, 19 Mar 2025 09:39:14 +0800 Subject: [PATCH 2/2] add static pool.apply --- src/Pools/EcsPool.cs | 11 +++++++++++ src/Pools/EcsTagPool.cs | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/Pools/EcsPool.cs b/src/Pools/EcsPool.cs index cb4bb09..7bad6f4 100644 --- a/src/Pools/EcsPool.cs +++ b/src/Pools/EcsPool.cs @@ -370,6 +370,17 @@ namespace DCFApixels.DragonECS public static implicit operator EcsPool(OptionalMarker a) { return a.GetInstance>(); } public static implicit operator EcsPool(EcsWorld.GetPoolInstanceMarker a) { return a.GetInstance>(); } #endregion + + #region Apply + public static void Apply(ref T component, int entityID, short worldID) + { + EcsWorld.GetPoolInstance>(worldID).TryAddOrGet(entityID) = component; + } + public static void Apply(ref T component, int entityID, EcsPool pool) + { + pool.TryAddOrGet(entityID) = component; + } + #endregion } public static class EcsPoolExtensions diff --git a/src/Pools/EcsTagPool.cs b/src/Pools/EcsTagPool.cs index b7626d3..74d5f28 100644 --- a/src/Pools/EcsTagPool.cs +++ b/src/Pools/EcsTagPool.cs @@ -317,6 +317,17 @@ namespace DCFApixels.DragonECS public static implicit operator EcsTagPool(OptionalMarker a) { return a.GetInstance>(); } public static implicit operator EcsTagPool(EcsWorld.GetPoolInstanceMarker a) { return a.GetInstance>(); } #endregion + + #region Apply + public static void Apply(ref T component, int entityID, short worldID) + { + EcsWorld.GetPoolInstance>(worldID).TryAdd(entityID); + } + public static void Apply(ref T component, int entityID, EcsTagPool pool) + { + pool.TryAdd(entityID); + } + #endregion } public static class EcsTagPoolExtensions