2024-03-07 00:39:28 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2024-03-08 07:02:22 +08:00
|
|
|
using System;
|
2024-03-07 00:39:28 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Transforms;
|
2024-03-08 08:06:49 +08:00
|
|
|
using osu.Game.Storyboards.Drawables;
|
2024-03-07 00:39:28 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Storyboards.Commands
|
|
|
|
{
|
2024-03-08 07:02:22 +08:00
|
|
|
public abstract class StoryboardCommand<T> : IStoryboardCommand, IComparable<StoryboardCommand<T>>
|
2024-03-07 00:39:28 +08:00
|
|
|
{
|
|
|
|
public double StartTime { get; }
|
|
|
|
public double EndTime { get; }
|
2024-03-08 08:06:49 +08:00
|
|
|
|
|
|
|
public T StartValue { get; }
|
|
|
|
public T EndValue { get; }
|
|
|
|
public Easing Easing { get; }
|
|
|
|
|
2024-03-07 00:39:28 +08:00
|
|
|
public double Duration => EndTime - StartTime;
|
|
|
|
|
|
|
|
protected StoryboardCommand(double startTime, double endTime, T startValue, T endValue, Easing easing)
|
|
|
|
{
|
|
|
|
if (endTime < startTime)
|
|
|
|
endTime = startTime;
|
|
|
|
|
|
|
|
StartTime = startTime;
|
|
|
|
StartValue = startValue;
|
|
|
|
EndTime = endTime;
|
|
|
|
EndValue = endValue;
|
|
|
|
Easing = easing;
|
|
|
|
}
|
|
|
|
|
2024-03-08 07:02:45 +08:00
|
|
|
public abstract string PropertyName { get; }
|
|
|
|
|
2024-03-08 08:06:49 +08:00
|
|
|
public abstract void ApplyInitialValue<TDrawable>(TDrawable d)
|
|
|
|
where TDrawable : Drawable, IFlippable, IVectorScalable;
|
2024-03-08 07:02:45 +08:00
|
|
|
|
2024-03-08 08:06:49 +08:00
|
|
|
public abstract TransformSequence<TDrawable> ApplyTransforms<TDrawable>(TDrawable d)
|
|
|
|
where TDrawable : Drawable, IFlippable, IVectorScalable;
|
2024-03-07 00:39:28 +08:00
|
|
|
|
2024-03-08 07:02:22 +08:00
|
|
|
public int CompareTo(StoryboardCommand<T>? other)
|
2024-03-07 00:39:28 +08:00
|
|
|
{
|
2024-03-08 07:02:22 +08:00
|
|
|
if (other == null)
|
|
|
|
return 1;
|
|
|
|
|
2024-03-07 00:39:28 +08:00
|
|
|
int result = StartTime.CompareTo(other.StartTime);
|
2024-03-08 07:02:22 +08:00
|
|
|
if (result != 0)
|
|
|
|
return result;
|
2024-03-07 00:39:28 +08:00
|
|
|
|
|
|
|
return EndTime.CompareTo(other.EndTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string ToString() => $"{StartTime} -> {EndTime}, {StartValue} -> {EndValue} {Easing}";
|
|
|
|
}
|
|
|
|
}
|