1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 20:42:55 +08:00

Use fresh mods for each difficulty calculation iteration

This commit is contained in:
smoogipoo 2019-03-14 23:39:45 +09:00
parent bbf42fdd00
commit 6df275c83a
2 changed files with 9 additions and 2 deletions

View File

@ -37,6 +37,8 @@ namespace osu.Game.Rulesets.Difficulty
/// <returns>A structure describing the difficulty of the beatmap.</returns> /// <returns>A structure describing the difficulty of the beatmap.</returns>
public DifficultyAttributes Calculate(params Mod[] mods) public DifficultyAttributes Calculate(params Mod[] mods)
{ {
mods = mods.Select(m => m.CreateCopy()).ToArray();
beatmap.Mods.Value = mods; beatmap.Mods.Value = mods;
IBeatmap playableBeatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo); IBeatmap playableBeatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo);
@ -55,9 +57,9 @@ namespace osu.Game.Rulesets.Difficulty
foreach (var combination in CreateDifficultyAdjustmentModCombinations()) foreach (var combination in CreateDifficultyAdjustmentModCombinations())
{ {
if (combination is MultiMod multi) if (combination is MultiMod multi)
yield return Calculate(multi.Mods); yield return Calculate(multi.Mods.Select(m => m.CreateCopy()).ToArray());
else else
yield return Calculate(combination); yield return Calculate(combination.CreateCopy());
} }
} }

View File

@ -65,5 +65,10 @@ namespace osu.Game.Rulesets.Mods
/// </summary> /// </summary>
[JsonIgnore] [JsonIgnore]
public virtual Type[] IncompatibleMods => new Type[] { }; public virtual Type[] IncompatibleMods => new Type[] { };
/// <summary>
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.
/// </summary>
public virtual Mod CreateCopy() => (Mod)Activator.CreateInstance(GetType());
} }
} }