From b6a65d403be676de3f81305a05ac34547b4e62ad Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Sat, 17 Feb 2024 00:10:27 +0800 Subject: [PATCH] update EcsPipeline.GetSystems --- src/EcsPipeline.cs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/EcsPipeline.cs b/src/EcsPipeline.cs index 98ea570..bc628a4 100644 --- a/src/EcsPipeline.cs +++ b/src/EcsPipeline.cs @@ -37,11 +37,30 @@ namespace DCFApixels.DragonECS } #endregion - #region Runners - public T[] GetSystems() where T : IEcsProcess + #region GetSystems + public T[] GetSystems() { - return _allSystems.Where(o => o is T).Select(o => (T)o).ToArray(); + return _allSystems.OfType().ToArray(); } + public int GetSystemsNoAllock(ref T[] array) + { + int count = 0; + for (int i = 0; i < _allSystems.Length; i++) + { + if (_allSystems is T targetSystem) + { + if (array.Length <= count) + { + Array.Resize(ref array, array.Length << 1); + } + array[count++] = targetSystem; + } + } + return count; + } + #endregion + + #region Runners public T GetRunner() where T : IEcsProcess { Type type = typeof(T);