From 5ced4c0388662cf615171c05b397d64d4d1a1dcd Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Sun, 25 Feb 2024 23:02:01 +0800 Subject: [PATCH] fix EcsGroup.ToSpan --- src/Collections/EcsGroup.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Collections/EcsGroup.cs b/src/Collections/EcsGroup.cs index 558af8a..eb2950f 100644 --- a/src/Collections/EcsGroup.cs +++ b/src/Collections/EcsGroup.cs @@ -132,13 +132,8 @@ namespace DCFApixels.DragonECS [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => throw new NotSupportedException(); #pragma warning restore CS0809 // Устаревший член переопределяет неустаревший член - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator EcsSpan(EcsReadonlyGroup a) => a.ToSpan(); - //internal class DebuggerProxy : EcsGroup.DebuggerProxy - //{ - // public DebuggerProxy(EcsReadonlyGroup group) : base(group._source) { } - //} #endregion } @@ -327,16 +322,22 @@ namespace DCFApixels.DragonECS { entities.Clear(); foreach (var e in this) + { entities.Add(e); + } } public EcsSpan ToSpan() { - return new EcsSpan(WorldID, _dense); + return new EcsSpan(WorldID, _dense, 1, _count); } public EcsSpan ToSpan(int start, int length) { + start -= 1; #if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS - if (start + length > _count) Throw.ArgumentOutOfRange(); + if (start < 0 || start + length > _count) + { + Throw.ArgumentOutOfRange(); + } #endif return new EcsSpan(WorldID, _dense, start, length); }