// 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 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) { int index = Index - (backwardsIndex + 1); return index >= 0 && index < difficultyHitObjects.Count ? difficultyHitObjects[index] : default; } public DifficultyHitObject Next(int forwardsIndex) { int index = Index + (forwardsIndex + 1); return index >= 0 && index < difficultyHitObjects.Count ? difficultyHitObjects[index] : default; } } }