// 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 readonly struct BreakPeriod : IEquatable { /// /// The minimum duration required for a break to have any effect. /// public const double MIN_BREAK_DURATION = 650; /// /// The break start time. /// public double StartTime { get; init; } /// /// The break end time. /// public double EndTime { get; init; } /// /// 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 Equals(BreakPeriod other) => StartTime.Equals(other.StartTime) && EndTime.Equals(other.EndTime); public override bool Equals(object? obj) => obj is BreakPeriod other && Equals(other); public override int GetHashCode() => HashCode.Combine(StartTime, EndTime); } }