2019-02-12 07:01:25 +00:00
|
|
|
// 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 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2022-05-22 15:26:22 +00:00
|
|
|
using System.Collections.Generic;
|
2022-05-24 15:40:24 +00:00
|
|
|
using System.Linq;
|
2019-02-12 07:01:25 +00:00
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Difficulty.Preprocessing
|
|
|
|
{
|
2019-02-19 05:30:59 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Wraps a <see cref="HitObject"/> and provides additional information to be used for difficulty calculation.
|
|
|
|
/// </summary>
|
2019-02-12 07:01:25 +00:00
|
|
|
public class DifficultyHitObject
|
|
|
|
{
|
2022-05-23 12:10:42 +00:00
|
|
|
private readonly IReadOnlyList<DifficultyHitObject> difficultyHitObjects;
|
2022-05-22 15:26:22 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2022-06-09 09:49:11 +00:00
|
|
|
/// The index of this <see cref="DifficultyHitObject"/> in the list of all <see cref="DifficultyHitObject"/>s.
|
2022-05-22 15:26:22 +00:00
|
|
|
/// </summary>
|
2022-06-09 09:49:11 +00:00
|
|
|
public int Index;
|
2022-05-22 15:26:22 +00:00
|
|
|
|
2019-02-12 07:01:25 +00:00
|
|
|
/// <summary>
|
2019-02-19 05:30:59 +00:00
|
|
|
/// The <see cref="HitObject"/> this <see cref="DifficultyHitObject"/> wraps.
|
2019-02-12 07:01:25 +00:00
|
|
|
/// </summary>
|
2019-02-19 05:30:59 +00:00
|
|
|
public readonly HitObject BaseObject;
|
2019-02-12 07:01:25 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2019-02-19 05:30:59 +00:00
|
|
|
/// The last <see cref="HitObject"/> which occurs before <see cref="BaseObject"/>.
|
2019-02-12 07:01:25 +00:00
|
|
|
/// </summary>
|
2019-02-19 05:30:59 +00:00
|
|
|
public readonly HitObject LastObject;
|
2019-02-12 07:01:25 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2021-04-03 09:47:39 +00:00
|
|
|
/// Amount of time elapsed between <see cref="BaseObject"/> and <see cref="LastObject"/>, adjusted by clockrate.
|
2019-02-12 07:01:25 +00:00
|
|
|
/// </summary>
|
2019-02-19 05:30:59 +00:00
|
|
|
public readonly double DeltaTime;
|
2019-02-12 07:01:25 +00:00
|
|
|
|
2021-02-19 07:04:25 +00:00
|
|
|
/// <summary>
|
2021-03-27 07:38:23 +00:00
|
|
|
/// Clockrate adjusted start time of <see cref="BaseObject"/>.
|
2021-02-19 07:04:25 +00:00
|
|
|
/// </summary>
|
|
|
|
public readonly double StartTime;
|
|
|
|
|
2021-03-27 07:38:43 +00:00
|
|
|
/// <summary>
|
2021-03-29 06:33:54 +00:00
|
|
|
/// Clockrate adjusted end time of <see cref="BaseObject"/>.
|
2021-03-27 07:38:43 +00:00
|
|
|
/// </summary>
|
|
|
|
public readonly double EndTime;
|
|
|
|
|
2019-02-19 05:30:59 +00: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>
|
2022-05-22 15:26:22 +00:00
|
|
|
/// <param name="objects">The list of <see cref="DifficultyHitObject"/>s in the current beatmap.</param>
|
2022-06-09 09:49:11 +00: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)
|
2019-02-12 07:01:25 +00:00
|
|
|
{
|
2022-05-22 15:26:22 +00:00
|
|
|
difficultyHitObjects = objects;
|
2022-06-09 09:49:11 +00:00
|
|
|
Index = index;
|
2019-02-12 07:01:25 +00:00
|
|
|
BaseObject = hitObject;
|
|
|
|
LastObject = lastObject;
|
2019-02-19 05:29:23 +00:00
|
|
|
DeltaTime = (hitObject.StartTime - lastObject.StartTime) / clockRate;
|
2021-02-19 07:04:25 +00:00
|
|
|
StartTime = hitObject.StartTime / clockRate;
|
2021-03-27 07:38:43 +00:00
|
|
|
EndTime = hitObject.GetEndTime() / clockRate;
|
2019-02-12 07:01:25 +00:00
|
|
|
}
|
2022-05-22 15:26:22 +00:00
|
|
|
|
2022-06-09 09:49:11 +00:00
|
|
|
public DifficultyHitObject Previous(int backwardsIndex) => difficultyHitObjects.ElementAtOrDefault(Index - (backwardsIndex + 1));
|
2022-05-22 15:26:22 +00:00
|
|
|
|
2022-06-09 09:49:11 +00:00
|
|
|
public DifficultyHitObject Next(int forwardsIndex) => difficultyHitObjects.ElementAtOrDefault(Index + (forwardsIndex + 1));
|
2019-02-12 07:01:25 +00:00
|
|
|
}
|
|
|
|
}
|