diff --git a/src/Collections/EcsGroup.cs b/src/Collections/EcsGroup.cs index 46138bf..d95d92d 100644 --- a/src/Collections/EcsGroup.cs +++ b/src/Collections/EcsGroup.cs @@ -1,4 +1,5 @@ using DCFApixels.DragonECS.Internal; +using DCFApixels.DragonECS.Utils; using System; using System.Collections; using System.Collections.Generic; @@ -13,7 +14,7 @@ namespace DCFApixels.DragonECS //_dense заполняется с индекса 1 //в операциях изменяющих состояние группы нельзя итерироваться по this, либо осторожно учитывать этот момент [StructLayout(LayoutKind.Sequential, Pack = 0, Size = 8)] - [DebuggerTypeProxy(typeof(DebuggerProxy))] + [DebuggerTypeProxy(typeof(EcsGroup.DebuggerProxy))] public readonly ref struct EcsReadonlyGroup { private readonly EcsGroup _source; @@ -134,10 +135,10 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator EcsSpan(EcsReadonlyGroup a) => a.ToSpan(); - internal class DebuggerProxy : EcsGroup.DebuggerProxy - { - public DebuggerProxy(EcsReadonlyGroup group) : base(group._source) { } - } + //internal class DebuggerProxy : EcsGroup.DebuggerProxy + //{ + // public DebuggerProxy(EcsReadonlyGroup group) : base(group._source) { } + //} #endregion } @@ -720,7 +721,8 @@ namespace DCFApixels.DragonECS #region Other public override string ToString() { - return $"group({_count}) {{{string.Join(", ", _dense.Skip(1).Take(_count).OrderBy(o => o))}}}"; + return EntitiesCollectionUtility.AutoToString(_dense.Skip(1).Take(_count), "group"); + //return $"group({_count}) {{{string.Join(", ", _dense.Skip(1).Take(_count).OrderBy(o => o))}}}"; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int First() @@ -762,6 +764,7 @@ namespace DCFApixels.DragonECS public int CapacitySparce => _group.CapacitySparce; public override string ToString() => _group.ToString(); public DebuggerProxy(EcsGroup group) => _group = group; + public DebuggerProxy(EcsReadonlyGroup group) : this(group.GetGroupInternal()) { } } #endregion } diff --git a/src/Collections/EcsSpan.cs b/src/Collections/EcsSpan.cs index 38e22a3..6a943df 100644 --- a/src/Collections/EcsSpan.cs +++ b/src/Collections/EcsSpan.cs @@ -1,8 +1,8 @@ -using System; +using DCFApixels.DragonECS.Utils; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; -using System.Linq; using System.Runtime.CompilerServices; namespace DCFApixels.DragonECS @@ -122,7 +122,8 @@ namespace DCFApixels.DragonECS #pragma warning restore CS0809 // Устаревший член переопределяет неустаревший член public override string ToString() { - return $"span({_values.Length}) {{{string.Join(", ", _values.ToArray().OrderBy(o => o))}}}"; + return EntitiesCollectionUtility.AutoToString(_values.ToArray(), "span"); + //return $"span({_values.Length}) {{{string.Join(", ", _values.ToArray().OrderBy(o => o))}}}"; } internal class DebuggerProxy @@ -142,7 +143,6 @@ namespace DCFApixels.DragonECS } } public int Count => _values.Length; - //public override string ToString() => $"span({_values.Length}) {{{string.Join(", ", _values.OrderBy(o => o))}}}"; public DebuggerProxy(EcsSpan span) { _values = new int[span.Length]; diff --git a/src/Utils/ArrayUtility.cs b/src/Utils/ArrayUtility.cs index 7ad4540..5ff3c32 100644 --- a/src/Utils/ArrayUtility.cs +++ b/src/Utils/ArrayUtility.cs @@ -1,6 +1,8 @@ -using System.Runtime.CompilerServices; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System; namespace DCFApixels.DragonECS.Utils { @@ -51,4 +53,12 @@ namespace DCFApixels.DragonECS.Utils new IntPtr(Marshal.SizeOf(typeof(T)) * newCount))).ToPointer(); } } + + public static class EntitiesCollectionUtility + { + public static string AutoToString(IEnumerable range, string name) + { + return $"{name}({range.Count()}) {{{string.Join(", ", range.OrderBy(o => o))}}})"; + } + } }