mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
feat(Easing): add IsRunning, IsDone
This commit is contained in:
parent
0a35700ee3
commit
cb85f8d49a
1 changed files with 12 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ namespace Dalamud.Interface.Animation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class Easing
|
public abstract class Easing
|
||||||
{
|
{
|
||||||
|
// TODO: Use game delta time here instead
|
||||||
private readonly Stopwatch animationTimer = new();
|
private readonly Stopwatch animationTimer = new();
|
||||||
|
|
||||||
private double valueInternal;
|
private double valueInternal;
|
||||||
|
|
@ -45,7 +46,7 @@ namespace Dalamud.Interface.Animation
|
||||||
get => this.valueInternal;
|
get => this.valueInternal;
|
||||||
protected set
|
protected set
|
||||||
{
|
{
|
||||||
this.valueInternal = Math.Min(value, 1);
|
this.valueInternal = value;
|
||||||
|
|
||||||
if (this.Point1.HasValue && this.Point2.HasValue)
|
if (this.Point1.HasValue && this.Point2.HasValue)
|
||||||
this.EasedPoint = AnimUtil.Lerp(this.Point1.Value, this.Point2.Value, (float)this.valueInternal);
|
this.EasedPoint = AnimUtil.Lerp(this.Point1.Value, this.Point2.Value, (float)this.valueInternal);
|
||||||
|
|
@ -57,6 +58,16 @@ namespace Dalamud.Interface.Animation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TimeSpan Duration { get; set; }
|
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>
|
/// <summary>
|
||||||
/// Gets the progress of the animation, from 0 to 1.
|
/// Gets the progress of the animation, from 0 to 1.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue