Handle mods with overloaded method signature instead

This commit is contained in:
Dean Herbert 2021-11-08 14:43:46 +09:00
parent 97345ac9e6
commit c58f21a115
2 changed files with 22 additions and 5 deletions

View File

@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using JetBrains.Annotations;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Beatmaps;
@ -36,13 +37,21 @@ protected DifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
this.beatmap = beatmap;
}
/// <summary>
/// Calculates the difficulty of the beatmap with no mods applied.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A structure describing the difficulty of the beatmap.</returns>
public DifficultyAttributes Calculate(CancellationToken cancellationToken = default)
=> Calculate(Array.Empty<Mod>(), cancellationToken);
/// <summary>
/// Calculates the difficulty of the beatmap using a specific mod combination.
/// </summary>
/// <param name="mods">The mods that should be applied to the beatmap.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A structure describing the difficulty of the beatmap.</returns>
public DifficultyAttributes Calculate(IEnumerable<Mod> mods = null, CancellationToken cancellationToken = default)
public DifficultyAttributes Calculate([NotNull] IEnumerable<Mod> mods, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
preProcess(mods, cancellationToken);
@ -65,12 +74,20 @@ public DifficultyAttributes Calculate(IEnumerable<Mod> mods = null, Cancellation
}
/// <summary>
/// Calculates the difficulty of the beatmap and returns a set of <see cref="TimedDifficultyAttributes"/> representing the difficulty at every relevant time value in the beatmap.
/// Calculates the difficulty of the beatmap with no mods applied and returns a set of <see cref="TimedDifficultyAttributes"/> representing the difficulty at every relevant time value in the beatmap.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The set of <see cref="TimedDifficultyAttributes"/>.</returns>
public List<TimedDifficultyAttributes> CalculateTimed(CancellationToken cancellationToken = default)
=> CalculateTimed(Array.Empty<Mod>(), cancellationToken);
/// <summary>
/// Calculates the difficulty of the beatmap using a specific mod combination and returns a set of <see cref="TimedDifficultyAttributes"/> representing the difficulty at every relevant time value in the beatmap.
/// </summary>
/// <param name="mods">The mods that should be applied to the beatmap.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The set of <see cref="TimedDifficultyAttributes"/>.</returns>
public List<TimedDifficultyAttributes> CalculateTimed(IEnumerable<Mod> mods, CancellationToken cancellationToken = default)
public List<TimedDifficultyAttributes> CalculateTimed([NotNull] IEnumerable<Mod> mods, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
preProcess(mods, cancellationToken);
@ -124,7 +141,7 @@ public IEnumerable<DifficultyAttributes> CalculateAll()
/// </summary>
/// <param name="mods">The original list of <see cref="Mod"/>s.</param>
/// <param name="cancellationToken">The cancellation token.</param>
private void preProcess(IEnumerable<Mod> mods, CancellationToken cancellationToken = default)
private void preProcess([NotNull] IEnumerable<Mod> mods, CancellationToken cancellationToken = default)
{
playableMods = mods.Select(m => m.DeepClone()).ToArray();

View File

@ -7,7 +7,7 @@ namespace osu.Game.Rulesets.Difficulty
{
/// <summary>
/// Wraps a <see cref="DifficultyAttributes"/> object and adds a time value for which the attribute is valid.
/// Output by <see cref="DifficultyCalculator.CalculateTimed"/>.
/// Output by DifficultyCalculator.CalculateTimed methods.
/// </summary>
public class TimedDifficultyAttributes : IComparable<TimedDifficultyAttributes>
{