// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. #nullable disable using System.Collections.Generic; using System.Linq; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Difficulty.Preprocessing { /// /// Wraps a and provides additional information to be used for difficulty calculation. /// public class DifficultyHitObject { private readonly IReadOnlyList difficultyHitObjects; /// /// The index of this in the list of all s. /// public int Index; /// /// The this wraps. /// public readonly HitObject BaseObject; /// /// The last which occurs before . /// public readonly HitObject LastObject; /// /// Amount of time elapsed between and , adjusted by clockrate. /// public readonly double DeltaTime; /// /// Clockrate adjusted start time of . /// public readonly double StartTime; /// /// Clockrate adjusted end time of . /// public readonly double EndTime; /// /// Creates a new . /// /// The which this wraps. /// The last which occurs before in the beatmap. /// The rate at which the gameplay clock is run at. /// The list of s in the current beatmap. /// The index of this in list. public DifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate, List objects, int index) { difficultyHitObjects = objects; Index = index; BaseObject = hitObject; LastObject = lastObject; DeltaTime = (hitObject.StartTime - lastObject.StartTime) / clockRate; StartTime = hitObject.StartTime / clockRate; EndTime = hitObject.GetEndTime() / clockRate; } public DifficultyHitObject Previous(int backwardsIndex) => difficultyHitObjects.ElementAtOrDefault(Index - (backwardsIndex + 1)); public DifficultyHitObject Next(int forwardsIndex) => difficultyHitObjects.ElementAtOrDefault(Index + (forwardsIndex + 1)); } }