From 7fca466dbb68a3eb9581f090a0c102da2595c819 Mon Sep 17 00:00:00 2001 From: "Dylan R. E. Moonfire" Date: Tue, 28 Jun 2022 02:23:20 -0500 Subject: [PATCH] fix: corrected the sequence properties to handle empty lists --- src/Nitride/Entities/EntitySequence.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Nitride/Entities/EntitySequence.cs b/src/Nitride/Entities/EntitySequence.cs index e90ac75..bfb2b09 100644 --- a/src/Nitride/Entities/EntitySequence.cs +++ b/src/Nitride/Entities/EntitySequence.cs @@ -15,15 +15,15 @@ public class EntitySequence this.Index = index; } - public bool HasNext => !this.IsLast; + public bool HasNext => this.Sequence.Count > 0 && !this.IsLast; - public bool HasPrevious => !this.IsFirst; + public bool HasPrevious => this.Sequence.Count > 0 && !this.IsFirst; public int Index { get; } - public bool IsFirst => this.Index == 0; + public bool IsFirst => this.Sequence.Count > 0 && this.Index == 0; - public bool IsLast => this.Index == this.Sequence.Count - 1; + public bool IsLast => this.Sequence.Count > 0 && this.Index == this.Sequence.Count - 1; public Entity? Next => this.HasNext ? this.Sequence[this.Index + 1] : null;