1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 02:27:25 +08:00
osu-lazer/osu.Game/Storyboards/CommandLoop.cs

36 lines
1.2 KiB
C#
Raw Normal View History

2017-09-08 05:55:05 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-09-09 00:00:17 +08:00
using System.Collections.Generic;
2017-09-08 05:55:05 +08:00
namespace osu.Game.Storyboards
{
public class CommandLoop : CommandTimelineGroup
{
public double LoopStartTime;
public int LoopCount;
2017-09-08 05:55:05 +08:00
public override double StartTime => LoopStartTime + CommandsStartTime;
public override double EndTime => StartTime + CommandsDuration * LoopCount;
2017-09-09 00:03:04 +08:00
2017-09-08 05:55:05 +08:00
public CommandLoop(double startTime, int loopCount)
{
LoopStartTime = startTime;
LoopCount = loopCount;
2017-09-08 05:55:05 +08:00
}
2017-09-09 00:00:17 +08: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-08 05:55:05 +08:00
public override string ToString()
=> $"{LoopStartTime} x{LoopCount}";
2017-09-08 05:55:05 +08:00
}
}