1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 12:58:33 +01:00

cleaned up the sprite animation changes

This commit is contained in:
Ell 2021-12-21 20:17:02 +01:00
parent c76357a9e3
commit 14526d24d3
2 changed files with 11 additions and 6 deletions

View file

@ -103,8 +103,8 @@ namespace MLEM.Animations {
/// </summary>
/// <param name="timePerFrame">The amount of time that each frame should last for</param>
/// <param name="regions">The texture regions that should make up this animation</param>
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))) {
}
/// <summary>
@ -187,7 +187,8 @@ namespace MLEM.Animations {
/// The texture region that this frame should render.
/// If there are multiple regions, <see cref="Regions"/> should be used instead.
/// </summary>
public TextureRegion Region => this.Regions[0];
/// <exception cref="InvalidOperationException">Thrown if this animation frame has more than one region, in which case <see cref="Regions"/> should be used instead.</exception>
public TextureRegion Region => this.Regions.Count == 1 ? this.Regions[0] : throw new InvalidOperationException("Cannot return single region for an animation frame with multiple regions");
/// <summary>
/// Creates a new animation frame based on a set of texture regions and a time.

View file

@ -25,18 +25,22 @@ namespace MLEM.Animations {
set => this.currAnimation = value;
}
/// <summary>
/// The animation that is currently playing
/// Returns the animation that is currently playing.
/// </summary>
public SpriteAnimation CurrentAnimation => this.CurrAnimation?.Animation;
/// <summary>
/// The frame that <see cref="CurrentAnimation"/> is displaying
/// Returns the frame that <see cref="CurrentAnimation"/> is displaying.
/// </summary>
public AnimationFrame CurrentFrame => this.CurrentAnimation?.CurrentFrame;
/// <summary>
/// The region that <see cref="CurrentFrame"/> has
/// Returns the <see cref="CurrentAnimation"/>'s <see cref="SpriteAnimation.CurrentRegion"/>.
/// </summary>
public TextureRegion CurrentRegion => this.CurrentAnimation?.CurrentRegion;
/// <summary>
/// Returns the <see cref="CurrentAnimation"/>'s <see cref="SpriteAnimation.CurrentRegions"/>.
/// </summary>
public IList<TextureRegion> CurrentRegions => this.CurrentAnimation?.CurrentRegions;
/// <summary>
/// A callback for when the currently displaying animation has changed due to a condition with a higher priority being met.
/// </summary>
public event AnimationChanged OnAnimationChanged;