feat(Easing): add IsRunning, IsDone

This commit is contained in:
goat 2021-07-18 22:56:40 +02:00
parent 0a35700ee3
commit cb85f8d49a
No known key found for this signature in database
GPG key ID: F18F057873895461

View file

@ -9,6 +9,7 @@ namespace Dalamud.Interface.Animation
/// </summary>
public abstract class Easing
{
// TODO: Use game delta time here instead
private readonly Stopwatch animationTimer = new();
private double valueInternal;
@ -45,7 +46,7 @@ namespace Dalamud.Interface.Animation
get => this.valueInternal;
protected set
{
this.valueInternal = Math.Min(value, 1);
this.valueInternal = value;
if (this.Point1.HasValue && this.Point2.HasValue)
this.EasedPoint = AnimUtil.Lerp(this.Point1.Value, this.Point2.Value, (float)this.valueInternal);
@ -57,6 +58,16 @@ namespace Dalamud.Interface.Animation
/// </summary>
public TimeSpan Duration { get; set; }
/// <summary>
/// Gets a value indicating whether or not the animation is running.
/// </summary>
public bool IsRunning => this.animationTimer.IsRunning;
/// <summary>
/// Gets a value indicating whether or not the animation is done.
/// </summary>
public bool IsDone => this.animationTimer.ElapsedMilliseconds > this.Duration.TotalMilliseconds;
/// <summary>
/// Gets the progress of the animation, from 0 to 1.
/// </summary>