2021-10-01 05:34:11 +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.
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A representation of all top-level difficulty settings for a beatmap.
|
|
|
|
/// </summary>
|
|
|
|
public interface IBeatmapDifficultyInfo
|
|
|
|
{
|
|
|
|
/// <summary>
|
2023-05-09 07:58:19 +00:00
|
|
|
/// The default value used for all difficulty settings except <see cref="SliderMultiplier"/> and <see cref="SliderTickRate"/>.
|
2021-10-01 05:34:11 +00:00
|
|
|
/// </summary>
|
|
|
|
const float DEFAULT_DIFFICULTY = 5;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The drain rate of the associated beatmap.
|
|
|
|
/// </summary>
|
|
|
|
float DrainRate { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The circle size of the associated beatmap.
|
|
|
|
/// </summary>
|
|
|
|
float CircleSize { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The overall difficulty of the associated beatmap.
|
|
|
|
/// </summary>
|
|
|
|
float OverallDifficulty { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The approach rate of the associated beatmap.
|
|
|
|
/// </summary>
|
|
|
|
float ApproachRate { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
2023-05-07 03:32:38 +00:00
|
|
|
/// The base slider velocity of the associated beatmap.
|
|
|
|
/// This was known as "SliderMultiplier" in the .osu format and stable editor.
|
2021-10-01 05:34:11 +00:00
|
|
|
/// </summary>
|
2023-05-09 07:58:19 +00:00
|
|
|
double SliderMultiplier { get; }
|
2021-10-01 05:34:11 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The slider tick rate of the associated beatmap.
|
|
|
|
/// </summary>
|
|
|
|
double SliderTickRate { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Maps a difficulty value [0, 10] to a two-piece linear range of values.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="difficulty">The difficulty value to be mapped.</param>
|
|
|
|
/// <param name="min">Minimum of the resulting range which will be achieved by a difficulty value of 0.</param>
|
|
|
|
/// <param name="mid">Midpoint of the resulting range which will be achieved by a difficulty value of 5.</param>
|
|
|
|
/// <param name="max">Maximum of the resulting range which will be achieved by a difficulty value of 10.</param>
|
|
|
|
/// <returns>Value to which the difficulty value maps in the specified range.</returns>
|
|
|
|
static double DifficultyRange(double difficulty, double min, double mid, double max)
|
|
|
|
{
|
|
|
|
if (difficulty > 5)
|
2023-10-18 10:50:42 +00:00
|
|
|
return mid + (max - mid) * DifficultyRange(difficulty);
|
2021-10-01 05:34:11 +00:00
|
|
|
if (difficulty < 5)
|
2023-10-18 14:54:18 +00:00
|
|
|
return mid + (mid - min) * DifficultyRange(difficulty);
|
2021-10-01 05:34:11 +00:00
|
|
|
|
|
|
|
return mid;
|
|
|
|
}
|
|
|
|
|
2023-10-18 10:50:42 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Maps a difficulty value [0, 10] to a linear range of [-1, 1].
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="difficulty">The difficulty value to be mapped.</param>
|
|
|
|
/// <returns>Value to which the difficulty value maps in the specified range.</returns>
|
|
|
|
static double DifficultyRange(double difficulty) => (difficulty - 5) / 5;
|
|
|
|
|
2021-10-01 05:34:11 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Maps a difficulty value [0, 10] to a two-piece linear range of values.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="difficulty">The difficulty value to be mapped.</param>
|
|
|
|
/// <param name="range">The values that define the two linear ranges.
|
|
|
|
/// <list type="table">
|
|
|
|
/// <item>
|
|
|
|
/// <term>od0</term>
|
|
|
|
/// <description>Minimum of the resulting range which will be achieved by a difficulty value of 0.</description>
|
|
|
|
/// </item>
|
|
|
|
/// <item>
|
|
|
|
/// <term>od5</term>
|
|
|
|
/// <description>Midpoint of the resulting range which will be achieved by a difficulty value of 5.</description>
|
|
|
|
/// </item>
|
|
|
|
/// <item>
|
|
|
|
/// <term>od10</term>
|
|
|
|
/// <description>Maximum of the resulting range which will be achieved by a difficulty value of 10.</description>
|
|
|
|
/// </item>
|
|
|
|
/// </list>
|
|
|
|
/// </param>
|
|
|
|
/// <returns>Value to which the difficulty value maps in the specified range.</returns>
|
2021-10-01 05:38:30 +00:00
|
|
|
static double DifficultyRange(double difficulty, (double od0, double od5, double od10) range)
|
2021-10-01 05:34:11 +00:00
|
|
|
=> DifficultyRange(difficulty, range.od0, range.od5, range.od10);
|
|
|
|
}
|
|
|
|
}
|