1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-25 05:02:55 +08:00
osu-lazer/osu.Game/Rulesets/Difficulty/Preprocessing/DifficultyHitObject.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
3.3 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2022-06-17 15:37:17 +08:00
#nullable disable
using System.Collections.Generic;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Difficulty.Preprocessing
{
2019-02-19 13:30:59 +08:00
/// <summary>
/// Wraps a <see cref="HitObject"/> and provides additional information to be used for difficulty calculation.
/// </summary>
public class DifficultyHitObject
{
2022-05-23 20:10:42 +08:00
private readonly IReadOnlyList<DifficultyHitObject> difficultyHitObjects;
/// <summary>
2022-06-09 17:49:11 +08:00
/// The index of this <see cref="DifficultyHitObject"/> in the list of all <see cref="DifficultyHitObject"/>s.
/// </summary>
2022-06-09 17:49:11 +08:00
public int Index;
/// <summary>
2019-02-19 13:30:59 +08:00
/// The <see cref="HitObject"/> this <see cref="DifficultyHitObject"/> wraps.
/// </summary>
2019-02-19 13:30:59 +08:00
public readonly HitObject BaseObject;
/// <summary>
2019-02-19 13:30:59 +08:00
/// The last <see cref="HitObject"/> which occurs before <see cref="BaseObject"/>.
/// </summary>
2019-02-19 13:30:59 +08:00
public readonly HitObject LastObject;
/// <summary>
/// Amount of time elapsed between <see cref="BaseObject"/> and <see cref="LastObject"/>, adjusted by clockrate.
/// </summary>
2019-02-19 13:30:59 +08:00
public readonly double DeltaTime;
/// <summary>
2021-03-27 15:38:23 +08:00
/// Clockrate adjusted start time of <see cref="BaseObject"/>.
/// </summary>
public readonly double StartTime;
/// <summary>
2021-03-29 14:33:54 +08:00
/// Clockrate adjusted end time of <see cref="BaseObject"/>.
/// </summary>
public readonly double EndTime;
2019-02-19 13:30:59 +08:00
/// <summary>
/// Creates a new <see cref="DifficultyHitObject"/>.
/// </summary>
/// <param name="hitObject">The <see cref="HitObject"/> which this <see cref="DifficultyHitObject"/> wraps.</param>
/// <param name="lastObject">The last <see cref="HitObject"/> which occurs before <paramref name="hitObject"/> in the beatmap.</param>
/// <param name="clockRate">The rate at which the gameplay clock is run at.</param>
/// <param name="objects">The list of <see cref="DifficultyHitObject"/>s in the current beatmap.</param>
2022-06-09 17:49:11 +08:00
/// <param name="index">The index of this <see cref="DifficultyHitObject"/> in <paramref name="objects"/> list.</param>
public DifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate, List<DifficultyHitObject> objects, int index)
{
difficultyHitObjects = objects;
2022-06-09 17:49:11 +08:00
Index = index;
BaseObject = hitObject;
LastObject = lastObject;
2019-02-19 13:29:23 +08:00
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;
}
}
}