2019-02-18 05:54:21 +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
|
|
|
|
|
2020-06-08 07:30:26 +00:00
|
|
|
using System;
|
2022-05-22 15:26:22 +00:00
|
|
|
using System.Collections.Generic;
|
2020-06-08 07:30:26 +00:00
|
|
|
using System.Linq;
|
2019-02-18 05:54:21 +00:00
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
|
|
|
{
|
2020-08-22 17:34:16 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Represents a single hit object in taiko difficulty calculation.
|
|
|
|
/// </summary>
|
2019-02-18 05:54:21 +00:00
|
|
|
public class TaikoDifficultyHitObject : DifficultyHitObject
|
|
|
|
{
|
2020-08-22 17:34:16 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The rhythm required to hit this hit object.
|
|
|
|
/// </summary>
|
2020-05-11 05:50:02 +00:00
|
|
|
public readonly TaikoDifficultyHitObjectRhythm Rhythm;
|
2020-08-22 17:34:16 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The hit type of this hit object.
|
|
|
|
/// </summary>
|
2020-08-12 16:35:56 +00:00
|
|
|
public readonly HitType? HitType;
|
2020-08-22 17:34:16 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Whether the object should carry a penalty due to being hittable using special techniques
|
|
|
|
/// making it easier to do so.
|
|
|
|
/// </summary>
|
2020-08-18 17:31:10 +00:00
|
|
|
public bool StaminaCheese;
|
2020-05-11 05:50:02 +00:00
|
|
|
|
2020-08-22 17:34:16 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new difficulty hit object.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="hitObject">The gameplay <see cref="HitObject"/> associated with this difficulty object.</param>
|
|
|
|
/// <param name="lastObject">The gameplay <see cref="HitObject"/> preceding <paramref name="hitObject"/>.</param>
|
|
|
|
/// <param name="lastLastObject">The gameplay <see cref="HitObject"/> preceding <paramref name="lastObject"/>.</param>
|
|
|
|
/// <param name="clockRate">The rate of the gameplay clock. Modified by speed-changing mods.</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 position of this <see cref="DifficultyHitObject"/> in the <paramref name="objects"/> list.</param>
|
|
|
|
public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, HitObject lastLastObject, double clockRate, List<DifficultyHitObject> objects, int index)
|
|
|
|
: base(hitObject, lastObject, clockRate, objects, index)
|
2019-02-18 05:54:21 +00:00
|
|
|
{
|
2020-05-11 05:53:42 +00:00
|
|
|
var currentHit = hitObject as Hit;
|
|
|
|
|
2020-08-22 17:34:16 +00:00
|
|
|
Rhythm = getClosestRhythm(lastObject, lastLastObject, clockRate);
|
2020-08-12 16:35:56 +00:00
|
|
|
HitType = currentHit?.Type;
|
2019-02-18 05:54:21 +00:00
|
|
|
}
|
2020-05-11 05:50:02 +00:00
|
|
|
|
2020-08-22 17:34:16 +00:00
|
|
|
/// <summary>
|
|
|
|
/// List of most common rhythm changes in taiko maps.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// The general guidelines for the values are:
|
|
|
|
/// <list type="bullet">
|
|
|
|
/// <item>rhythm changes with ratio closer to 1 (that are <i>not</i> 1) are harder to play,</item>
|
|
|
|
/// <item>speeding up is <i>generally</i> harder than slowing down (with exceptions of rhythm changes requiring a hand switch).</item>
|
|
|
|
/// </list>
|
|
|
|
/// </remarks>
|
2020-08-22 15:10:31 +00:00
|
|
|
private static readonly TaikoDifficultyHitObjectRhythm[] common_rhythms =
|
2020-06-08 07:30:26 +00:00
|
|
|
{
|
2020-08-22 15:10:31 +00:00
|
|
|
new TaikoDifficultyHitObjectRhythm(1, 1, 0.0),
|
|
|
|
new TaikoDifficultyHitObjectRhythm(2, 1, 0.3),
|
|
|
|
new TaikoDifficultyHitObjectRhythm(1, 2, 0.5),
|
|
|
|
new TaikoDifficultyHitObjectRhythm(3, 1, 0.3),
|
|
|
|
new TaikoDifficultyHitObjectRhythm(1, 3, 0.35),
|
2020-08-22 17:34:16 +00:00
|
|
|
new TaikoDifficultyHitObjectRhythm(3, 2, 0.6), // purposefully higher (requires hand switch in full alternating gameplay style)
|
2020-08-22 15:10:31 +00:00
|
|
|
new TaikoDifficultyHitObjectRhythm(2, 3, 0.4),
|
|
|
|
new TaikoDifficultyHitObjectRhythm(5, 4, 0.5),
|
|
|
|
new TaikoDifficultyHitObjectRhythm(4, 5, 0.7)
|
|
|
|
};
|
|
|
|
|
2020-08-22 17:34:16 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Returns the closest rhythm change from <see cref="common_rhythms"/> required to hit this object.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="lastObject">The gameplay <see cref="HitObject"/> preceding this one.</param>
|
|
|
|
/// <param name="lastLastObject">The gameplay <see cref="HitObject"/> preceding <paramref name="lastObject"/>.</param>
|
|
|
|
/// <param name="clockRate">The rate of the gameplay clock.</param>
|
|
|
|
private TaikoDifficultyHitObjectRhythm getClosestRhythm(HitObject lastObject, HitObject lastLastObject, double clockRate)
|
|
|
|
{
|
|
|
|
double prevLength = (lastObject.StartTime - lastLastObject.StartTime) / clockRate;
|
|
|
|
double ratio = DeltaTime / prevLength;
|
|
|
|
|
|
|
|
return common_rhythms.OrderBy(x => Math.Abs(x.Ratio - ratio)).First();
|
|
|
|
}
|
2019-02-18 05:54:21 +00:00
|
|
|
}
|
|
|
|
}
|