// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; namespace osu.Game.Beatmaps { /// /// A representation of all top-level difficulty settings for a beatmap. /// public interface IBeatmapDifficultyInfo { /// /// The default value used for all difficulty settings except and . /// const float DEFAULT_DIFFICULTY = 5; /// /// The drain rate of the associated beatmap. /// float DrainRate { get; } /// /// The circle size of the associated beatmap. /// float CircleSize { get; } /// /// The overall difficulty of the associated beatmap. /// float OverallDifficulty { get; } /// /// The approach rate of the associated beatmap. /// float ApproachRate { get; } /// /// The base slider velocity of the associated beatmap. /// This was known as "SliderMultiplier" in the .osu format and stable editor. /// double SliderMultiplier { get; } /// /// The slider tick rate of the associated beatmap. /// double SliderTickRate { get; } /// /// Maps a difficulty value [0, 10] to a two-piece linear range of values. /// /// The difficulty value to be mapped. /// Minimum of the resulting range which will be achieved by a difficulty value of 0. /// Midpoint of the resulting range which will be achieved by a difficulty value of 5. /// Maximum of the resulting range which will be achieved by a difficulty value of 10. /// Value to which the difficulty value maps in the specified range. static double DifficultyRange(double difficulty, double min, double mid, double max) { if (difficulty > 5) return mid + (max - mid) * DifficultyRange(difficulty); if (difficulty < 5) return mid + (mid - min) * DifficultyRange(difficulty); return mid; } /// /// Maps a difficulty value [0, 10] to a linear range of [-1, 1]. /// /// The difficulty value to be mapped. /// Value to which the difficulty value maps in the specified range. static double DifficultyRange(double difficulty) => (difficulty - 5) / 5; /// /// Maps a difficulty value [0, 10] to a two-piece linear range of values. /// /// The difficulty value to be mapped. /// The values that define the two linear ranges. /// /// /// od0 /// Minimum of the resulting range which will be achieved by a difficulty value of 0. /// /// /// od5 /// Midpoint of the resulting range which will be achieved by a difficulty value of 5. /// /// /// od10 /// Maximum of the resulting range which will be achieved by a difficulty value of 10. /// /// /// /// Value to which the difficulty value maps in the specified range. static double DifficultyRange(double difficulty, (double od0, double od5, double od10) range) => DifficultyRange(difficulty, range.od0, range.od5, range.od10); /// /// Inverse function to . /// Maps a value returned by the function above back to the difficulty that produced it. /// /// The difficulty-dependent value to be unmapped. /// Minimum of the resulting range which will be achieved by a difficulty value of 0. /// Midpoint of the resulting range which will be achieved by a difficulty value of 5. /// Maximum of the resulting range which will be achieved by a difficulty value of 10. /// Value to which the difficulty value maps in the specified range. static double InverseDifficultyRange(double difficultyValue, double diff0, double diff5, double diff10) { return Math.Sign(difficultyValue - diff5) == Math.Sign(diff10 - diff5) ? (difficultyValue - diff5) / (diff10 - diff5) * 5 + 5 : (difficultyValue - diff5) / (diff5 - diff0) * 5 + 5; } } }