// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; using osu.Game.Rulesets.Difficulty.Preprocessing; using osu.Game.Rulesets.Taiko.Difficulty.Utils; namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Rhythm.Data { /// /// Represents a group of s with no rhythm variation. /// public class SameRhythmHitObjectGrouping : IHasInterval { public readonly List HitObjects; public TaikoDifficultyHitObject FirstHitObject => HitObjects[0]; public readonly SameRhythmHitObjectGrouping? Previous; /// /// of the first hit object. /// public double StartTime => HitObjects[0].StartTime; /// /// The interval between the first and final hit object within this group. /// public double Duration => HitObjects[^1].StartTime - HitObjects[0].StartTime; /// /// The interval in ms of each hit object in this . This is only defined if there is /// more than two hit objects in this . /// public readonly double? HitObjectInterval; /// /// The ratio of between this and the previous . In the /// case where one or both of the is undefined, this will have a value of 1. /// public readonly double HitObjectIntervalRatio; /// public double Interval { get; } public SameRhythmHitObjectGrouping(SameRhythmHitObjectGrouping? previous, List hitObjects) { Previous = previous; HitObjects = hitObjects; // Calculate the average interval between hitobjects, or null if there are fewer than two HitObjectInterval = HitObjects.Count < 2 ? null : Duration / (HitObjects.Count - 1); // Calculate the ratio between this group's interval and the previous group's interval HitObjectIntervalRatio = Previous?.HitObjectInterval != null && HitObjectInterval != null ? HitObjectInterval.Value / Previous.HitObjectInterval.Value : 1; // Calculate the interval from the previous group's start time Interval = Previous != null ? StartTime - Previous.StartTime : double.PositiveInfinity; } } }