mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +01:00
cleaned up the sprite animation changes
This commit is contained in:
parent
c76357a9e3
commit
14526d24d3
2 changed files with 11 additions and 6 deletions
|
@ -103,8 +103,8 @@ namespace MLEM.Animations {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="timePerFrame">The amount of time that each frame should last for</param>
|
/// <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>
|
/// <param name="regions">The texture regions that should make up this animation</param>
|
||||||
public SpriteAnimation(double timePerFrame, params TextureRegion[] regions)
|
public SpriteAnimation(double timePerFrame, params TextureRegion[] regions) :
|
||||||
: this(Array.ConvertAll(regions, r => new AnimationFrame(timePerFrame, r))) {
|
this(Array.ConvertAll(regions, r => new AnimationFrame(timePerFrame, r))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -187,7 +187,8 @@ namespace MLEM.Animations {
|
||||||
/// The texture region that this frame should render.
|
/// The texture region that this frame should render.
|
||||||
/// If there are multiple regions, <see cref="Regions"/> should be used instead.
|
/// If there are multiple regions, <see cref="Regions"/> should be used instead.
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Creates a new animation frame based on a set of texture regions and a time.
|
/// Creates a new animation frame based on a set of texture regions and a time.
|
||||||
|
|
|
@ -25,18 +25,22 @@ namespace MLEM.Animations {
|
||||||
set => this.currAnimation = value;
|
set => this.currAnimation = value;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The animation that is currently playing
|
/// Returns the animation that is currently playing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SpriteAnimation CurrentAnimation => this.CurrAnimation?.Animation;
|
public SpriteAnimation CurrentAnimation => this.CurrAnimation?.Animation;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The frame that <see cref="CurrentAnimation"/> is displaying
|
/// Returns the frame that <see cref="CurrentAnimation"/> is displaying.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AnimationFrame CurrentFrame => this.CurrentAnimation?.CurrentFrame;
|
public AnimationFrame CurrentFrame => this.CurrentAnimation?.CurrentFrame;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The region that <see cref="CurrentFrame"/> has
|
/// Returns the <see cref="CurrentAnimation"/>'s <see cref="SpriteAnimation.CurrentRegion"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TextureRegion CurrentRegion => this.CurrentAnimation?.CurrentRegion;
|
public TextureRegion CurrentRegion => this.CurrentAnimation?.CurrentRegion;
|
||||||
/// <summary>
|
/// <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.
|
/// A callback for when the currently displaying animation has changed due to a condition with a higher priority being met.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event AnimationChanged OnAnimationChanged;
|
public event AnimationChanged OnAnimationChanged;
|
||||||
|
|
Loading…
Reference in a new issue