1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 08:53:17 +08:00

Make use of framework's transform loops

This commit is contained in:
Andrei Zavatski 2024-03-03 21:30:46 +03:00
parent c05007804f
commit 7193ec66a4
3 changed files with 76 additions and 19 deletions

View File

@ -38,11 +38,21 @@ namespace osu.Game.Storyboards
public override IEnumerable<CommandTimeline<T>.TypedCommand> GetCommands<T>(CommandTimelineSelector<T> timelineSelector, double offset = 0)
{
for (int loop = 0; loop < TotalIterations; loop++)
double fullLoopDuration = CommandsEndTime - CommandsStartTime;
foreach (var command in timelineSelector(this).Commands)
{
double loopOffset = LoopStartTime + loop * CommandsDuration;
foreach (var command in base.GetCommands(timelineSelector, offset + loopOffset))
yield return command;
yield return new CommandTimeline<T>.TypedCommand
{
Easing = command.Easing,
StartTime = offset + LoopStartTime + command.StartTime,
EndTime = offset + LoopStartTime + command.EndTime,
StartValue = command.StartValue,
EndValue = command.EndValue,
PropertyName = command.PropertyName,
LoopCount = TotalIterations,
Delay = fullLoopDuration - command.EndTime + command.StartTime
};
}
}

View File

@ -63,6 +63,8 @@ namespace osu.Game.Storyboards
public double EndTime { get; set; }
public double Duration => EndTime - StartTime;
public string PropertyName { get; set; }
public int LoopCount { get; set; }
public double Delay { get; set; }
public T StartValue;
public T EndValue;

View File

@ -218,41 +218,86 @@ namespace osu.Game.Storyboards
switch (command.PropertyName)
{
case "VectorScale":
using (drawable.BeginAbsoluteSequence(command.StartTime))
if (command.LoopCount == 0)
{
((IVectorScalable)drawable).TransformTo(command.PropertyName, command.StartValue).Then().TransformTo(command.PropertyName, command.EndValue, command.Duration, command.Easing);
using (drawable.BeginAbsoluteSequence(command.StartTime))
{
((IVectorScalable)drawable).TransformTo(command.PropertyName, command.StartValue).Then()
.TransformTo(command.PropertyName, command.EndValue, command.Duration, command.Easing);
}
}
else
{
using (drawable.BeginAbsoluteSequence(command.StartTime))
{
((IVectorScalable)drawable).TransformTo(command.PropertyName, command.StartValue).Then()
.TransformTo(command.PropertyName, command.EndValue, command.Duration, command.Easing)
.Loop(command.Delay, command.LoopCount);
}
}
break;
case "FlipH":
using (drawable.BeginAbsoluteSequence(command.StartTime))
{
((IFlippable)drawable).TransformTo(command.PropertyName, command.StartValue).Delay(command.Duration).TransformTo(command.PropertyName, command.EndValue);
}
break;
case "FlipV":
using (drawable.BeginAbsoluteSequence(command.StartTime))
if (command.LoopCount == 0)
{
((IFlippable)drawable).TransformTo(command.PropertyName, command.StartValue).Delay(command.Duration).TransformTo(command.PropertyName, command.EndValue);
using (drawable.BeginAbsoluteSequence(command.StartTime))
{
((IFlippable)drawable).TransformTo(command.PropertyName, command.StartValue).Delay(command.Duration)
.TransformTo(command.PropertyName, command.EndValue);
}
}
else
{
using (drawable.BeginAbsoluteSequence(command.StartTime))
{
((IFlippable)drawable).TransformTo(command.PropertyName, command.StartValue).Delay(command.Duration)
.TransformTo(command.PropertyName, command.EndValue)
.Loop(command.Delay, command.LoopCount);
}
}
break;
case "Blending":
using (drawable.BeginAbsoluteSequence(command.StartTime))
if (command.LoopCount == 0)
{
drawable.TransformTo(command.PropertyName, command.StartValue).Delay(command.Duration).TransformTo(command.PropertyName, command.EndValue);
using (drawable.BeginAbsoluteSequence(command.StartTime))
{
drawable.TransformTo(command.PropertyName, command.StartValue).Delay(command.Duration)
.TransformTo(command.PropertyName, command.EndValue);
}
}
else
{
using (drawable.BeginAbsoluteSequence(command.StartTime))
{
drawable.TransformTo(command.PropertyName, command.StartValue).Delay(command.Duration)
.TransformTo(command.PropertyName, command.EndValue)
.Loop(command.Delay, command.LoopCount);
}
}
break;
default:
using (drawable.BeginAbsoluteSequence(command.StartTime))
if (command.LoopCount == 0)
{
drawable.TransformTo(command.PropertyName, command.StartValue).Then().TransformTo(command.PropertyName, command.EndValue, command.Duration, command.Easing);
using (drawable.BeginAbsoluteSequence(command.StartTime))
{
drawable.TransformTo(command.PropertyName, command.StartValue).Then()
.TransformTo(command.PropertyName, command.EndValue, command.Duration, command.Easing);
}
}
else
{
using (drawable.BeginAbsoluteSequence(command.StartTime))
{
drawable.TransformTo(command.PropertyName, command.StartValue).Then()
.TransformTo(command.PropertyName, command.EndValue, command.Duration, command.Easing)
.Loop(command.Delay, command.LoopCount);
}
}
break;