From 14526d24d3f767d73ee49e43fea06be130130396 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 21 Dec 2021 20:17:02 +0100 Subject: [PATCH] cleaned up the sprite animation changes --- MLEM/Animations/SpriteAnimation.cs | 7 ++++--- MLEM/Animations/SpriteAnimationGroup.cs | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/MLEM/Animations/SpriteAnimation.cs b/MLEM/Animations/SpriteAnimation.cs index f72e09b..121b4c5 100644 --- a/MLEM/Animations/SpriteAnimation.cs +++ b/MLEM/Animations/SpriteAnimation.cs @@ -103,8 +103,8 @@ namespace MLEM.Animations { /// /// The amount of time that each frame should last for /// The texture regions that should make up this animation - public SpriteAnimation(double timePerFrame, params TextureRegion[] regions) - : this(Array.ConvertAll(regions, r => new AnimationFrame(timePerFrame, r))) { + public SpriteAnimation(double timePerFrame, params TextureRegion[] regions) : + this(Array.ConvertAll(regions, r => new AnimationFrame(timePerFrame, r))) { } /// @@ -187,7 +187,8 @@ namespace MLEM.Animations { /// The texture region that this frame should render. /// If there are multiple regions, should be used instead. /// - public TextureRegion Region => this.Regions[0]; + /// Thrown if this animation frame has more than one region, in which case should be used instead. + public TextureRegion Region => this.Regions.Count == 1 ? this.Regions[0] : throw new InvalidOperationException("Cannot return single region for an animation frame with multiple regions"); /// /// Creates a new animation frame based on a set of texture regions and a time. diff --git a/MLEM/Animations/SpriteAnimationGroup.cs b/MLEM/Animations/SpriteAnimationGroup.cs index e7f8146..ac62c1a 100644 --- a/MLEM/Animations/SpriteAnimationGroup.cs +++ b/MLEM/Animations/SpriteAnimationGroup.cs @@ -25,18 +25,22 @@ namespace MLEM.Animations { set => this.currAnimation = value; } /// - /// The animation that is currently playing + /// Returns the animation that is currently playing. /// public SpriteAnimation CurrentAnimation => this.CurrAnimation?.Animation; /// - /// The frame that is displaying + /// Returns the frame that is displaying. /// public AnimationFrame CurrentFrame => this.CurrentAnimation?.CurrentFrame; /// - /// The region that has + /// Returns the 's . /// public TextureRegion CurrentRegion => this.CurrentAnimation?.CurrentRegion; /// + /// Returns the 's . + /// + public IList CurrentRegions => this.CurrentAnimation?.CurrentRegions; + /// /// A callback for when the currently displaying animation has changed due to a condition with a higher priority being met. /// public event AnimationChanged OnAnimationChanged;