diff --git a/src/Collections/EcsSpan.cs b/src/Collections/EcsSpan.cs index 5306b9e..a463302 100644 --- a/src/Collections/EcsSpan.cs +++ b/src/Collections/EcsSpan.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; @@ -62,6 +63,34 @@ namespace DCFApixels.DragonECS } #endregion + #region Methdos + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public int[] Bake() + { + int[] result = new int[_values.Length]; + _values.CopyTo(result); + return result; + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public int Bake(ref int[] entities) + { + if (entities.Length < _values.Length) + Array.Resize(ref entities, _values.Length); + int[] result = new int[_values.Length]; + _values.CopyTo(result); + return _values.Length; + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Bake(List entities) + { + entities.Clear(); + foreach (var e in _values) + { + entities.Add(e); + } + } + #endregion + #region Object #pragma warning disable CS0809 // Устаревший член переопределяет неустаревший член [Obsolete($"Equals() on {nameof(EcsSpan)} will always throw an exception. Use the equality operator instead.")]