osu/osu.Game/Beatmaps/WorkingBeatmap_VirtualBeatm...

40 lines
1.3 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.Audio.Track;
2018-07-21 02:38:28 +00:00
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Beatmaps
{
public partial class WorkingBeatmap
{
/// <summary>
/// A type of <see cref="TrackVirtual"/> which provides a valid length based on the <see cref="HitObject"/>s of an <see cref="IBeatmap"/>.
/// </summary>
2018-06-28 02:45:48 +00:00
protected class VirtualBeatmapTrack : TrackVirtual
{
2018-06-28 02:46:56 +00:00
private const double excess_length = 1000;
public VirtualBeatmapTrack(IBeatmap beatmap)
{
var lastObject = beatmap.HitObjects.LastOrDefault();
switch (lastObject)
{
case null:
2018-06-28 02:46:56 +00:00
Length = excess_length;
break;
case IHasEndTime endTime:
2018-06-28 02:46:56 +00:00
Length = endTime.EndTime + excess_length;
break;
default:
2018-06-28 02:46:56 +00:00
Length = lastObject.StartTime + excess_length;
break;
}
}
}
}
}