// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using osu.Game.Screens.Play; namespace osu.Game.Beatmaps.Timing { public class BreakPeriod : IEquatable { /// /// The minimum gap between the start of the break and the previous object. /// public const double GAP_BEFORE_BREAK = 200; /// /// The minimum gap between the end of the break and the next object. /// Based on osu! preempt time at AR=10. /// See also: https://github.com/ppy/osu/issues/14330#issuecomment-1002158551 /// public const double GAP_AFTER_BREAK = 450; /// /// The minimum duration required for a break to have any effect. /// public const double MIN_BREAK_DURATION = 650; /// /// The minimum required duration of a gap between two objects such that a break can be placed between them. /// public const double MIN_GAP_DURATION = GAP_BEFORE_BREAK + MIN_BREAK_DURATION + GAP_AFTER_BREAK; /// /// The break start time. /// public double StartTime { get; } /// /// The break end time. /// public double EndTime { get; } /// /// The break duration. /// public double Duration => EndTime - StartTime; /// /// Whether the break has any effect. /// public bool HasEffect => Duration >= MIN_BREAK_DURATION; /// /// Constructs a new break period. /// /// The start time of the break period. /// The end time of the break period. public BreakPeriod(double startTime, double endTime) { StartTime = startTime; EndTime = endTime; } /// /// Whether this break contains a specified time. /// /// The time to check in milliseconds. /// Whether the time falls within this . public bool Contains(double time) => time >= StartTime && time <= EndTime - BreakOverlay.BREAK_FADE_DURATION; public bool Intersects(BreakPeriod other) => StartTime <= other.EndTime && EndTime >= other.StartTime; public virtual bool Equals(BreakPeriod? other) => other != null && StartTime == other.StartTime && EndTime == other.EndTime; public override int GetHashCode() => HashCode.Combine(StartTime, EndTime); } }