Merge pull request #13929 from peppy/i-deep-cloneable

Create a deep clone of score for score submission purposes
This commit is contained in:
Dan Balasescu
2021-07-19 21:58:27 +09:00
committed by GitHub
21 changed files with 118 additions and 32 deletions

View File

@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Difficulty
/// <returns>A structure describing the difficulty of the beatmap.</returns>
public DifficultyAttributes Calculate(params Mod[] mods)
{
mods = mods.Select(m => m.CreateCopy()).ToArray();
mods = mods.Select(m => m.DeepClone()).ToArray();
IBeatmap playableBeatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mods
/// The base class for gameplay modifiers.
/// </summary>
[ExcludeFromDynamicCompile]
public abstract class Mod : IMod, IEquatable<Mod>, IJsonSerializable
public abstract class Mod : IMod, IEquatable<Mod>, IJsonSerializable, IDeepCloneable<Mod>
{
/// <summary>
/// The name of this mod.
@ -132,7 +132,7 @@ namespace osu.Game.Rulesets.Mods
/// <summary>
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.
/// </summary>
public virtual Mod CreateCopy()
public virtual Mod DeepClone()
{
var result = (Mod)Activator.CreateInstance(GetType());
result.CopyFrom(this);

View File

@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Mods
Mods = mods;
}
public override Mod CreateCopy() => new MultiMod(Mods.Select(m => m.CreateCopy()).ToArray());
public override Mod DeepClone() => new MultiMod(Mods.Select(m => m.DeepClone()).ToArray());
public override Type[] IncompatibleMods => Mods.SelectMany(m => m.IncompatibleMods).ToArray();
}