2019-01-24 08:43:03 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-08-07 13:59:35 +00:00
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
namespace osu.Game.Beatmaps.Timing
|
|
|
|
|
{
|
|
|
|
|
public class BreakPeriod
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The minimum duration required for a break to have any effect.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const double MIN_BREAK_DURATION = 650;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The break start time.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double StartTime;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The break end time.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double EndTime;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The break duration.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double Duration => EndTime - StartTime;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-10-12 06:28:16 +00:00
|
|
|
|
/// Whether the break has any effect.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
public bool HasEffect => Duration >= MIN_BREAK_DURATION;
|
2019-05-12 07:25:25 +00:00
|
|
|
|
|
2020-04-05 18:29:03 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a new break period.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="startTime">The start time of the break period.</param>
|
|
|
|
|
/// <param name="endTime">The end time of the break period.</param>
|
|
|
|
|
public BreakPeriod(double startTime, double endTime)
|
|
|
|
|
{
|
|
|
|
|
StartTime = startTime;
|
|
|
|
|
EndTime = endTime;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-12 07:25:25 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether this break contains a specified time.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="time">The time to check in milliseconds.</param>
|
|
|
|
|
/// <returns>Whether the time falls within this <see cref="BreakPeriod"/>.</returns>
|
2019-08-07 13:59:35 +00:00
|
|
|
|
public bool Contains(double time) => time >= StartTime && time <= EndTime - BreakOverlay.BREAK_FADE_DURATION;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|