2018-01-05 11:21:19 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-09-07 21:55:05 +00:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-09-08 16:00:17 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-09-07 21:55:05 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Storyboards
|
|
|
|
|
{
|
|
|
|
|
public class CommandLoop : CommandTimelineGroup
|
|
|
|
|
{
|
2017-09-08 10:11:57 +00:00
|
|
|
|
public double LoopStartTime;
|
|
|
|
|
public int LoopCount;
|
2017-09-07 21:55:05 +00:00
|
|
|
|
|
2017-09-16 11:15:16 +00:00
|
|
|
|
public override double StartTime => LoopStartTime + CommandsStartTime;
|
|
|
|
|
public override double EndTime => StartTime + CommandsDuration * LoopCount;
|
2017-09-08 16:03:04 +00:00
|
|
|
|
|
2017-09-07 21:55:05 +00:00
|
|
|
|
public CommandLoop(double startTime, int loopCount)
|
|
|
|
|
{
|
2017-09-08 10:11:57 +00:00
|
|
|
|
LoopStartTime = startTime;
|
|
|
|
|
LoopCount = loopCount;
|
2017-09-07 21:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 16:00:17 +00:00
|
|
|
|
public override IEnumerable<CommandTimeline<T>.TypedCommand> GetCommands<T>(CommandTimelineSelector<T> timelineSelector, double offset = 0)
|
|
|
|
|
{
|
|
|
|
|
for (var loop = 0; loop < LoopCount; loop++)
|
|
|
|
|
{
|
|
|
|
|
var loopOffset = LoopStartTime + loop * CommandsDuration;
|
|
|
|
|
foreach (var command in base.GetCommands(timelineSelector, offset + loopOffset))
|
|
|
|
|
yield return command;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-07 21:55:05 +00:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
2017-09-08 10:11:57 +00:00
|
|
|
|
=> $"{LoopStartTime} x{LoopCount}";
|
2017-09-07 21:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|