diff --git a/osu.Game/Storyboards/CommandLoop.cs b/osu.Game/Storyboards/CommandLoop.cs index 480d69c12f..a912daea44 100644 --- a/osu.Game/Storyboards/CommandLoop.cs +++ b/osu.Game/Storyboards/CommandLoop.cs @@ -38,11 +38,21 @@ namespace osu.Game.Storyboards public override IEnumerable.TypedCommand> GetCommands(CommandTimelineSelector 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.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 + }; } } diff --git a/osu.Game/Storyboards/CommandTimeline.cs b/osu.Game/Storyboards/CommandTimeline.cs index 2bb606d2bb..ce25bfe25b 100644 --- a/osu.Game/Storyboards/CommandTimeline.cs +++ b/osu.Game/Storyboards/CommandTimeline.cs @@ -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; diff --git a/osu.Game/Storyboards/StoryboardSprite.cs b/osu.Game/Storyboards/StoryboardSprite.cs index 4d3f1c158f..2c04e4c983 100644 --- a/osu.Game/Storyboards/StoryboardSprite.cs +++ b/osu.Game/Storyboards/StoryboardSprite.cs @@ -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;