1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 23:07:26 +08:00

Merge pull request #10500 from smoogipoo/fix-multimod-copy

Fix MultiMod throwing exceptions when creating copies
This commit is contained in:
Dean Herbert 2020-10-14 23:38:45 +09:00 committed by GitHub
commit 46002279cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View File

@ -95,6 +95,24 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("copy has original value", () => Precision.AlmostEquals(1.5, copy.SpeedChange.Value));
}
[Test]
public void TestMultiModSettingsUnboundWhenCopied()
{
MultiMod original = null;
MultiMod copy = null;
AddStep("create mods", () =>
{
original = new MultiMod(new OsuModDoubleTime());
copy = (MultiMod)original.CreateCopy();
});
AddStep("change property", () => ((OsuModDoubleTime)original.Mods[0]).SpeedChange.Value = 2);
AddAssert("original has new value", () => Precision.AlmostEquals(2.0, ((OsuModDoubleTime)original.Mods[0]).SpeedChange.Value));
AddAssert("copy has original value", () => Precision.AlmostEquals(1.5, ((OsuModDoubleTime)copy.Mods[0]).SpeedChange.Value));
}
private void createModSelect()
{
AddStep("create mod select", () =>

View File

@ -6,7 +6,7 @@ using System.Linq;
namespace osu.Game.Rulesets.Mods
{
public class MultiMod : Mod
public sealed class MultiMod : Mod
{
public override string Name => string.Empty;
public override string Acronym => string.Empty;
@ -20,6 +20,8 @@ namespace osu.Game.Rulesets.Mods
Mods = mods;
}
public override Mod CreateCopy() => new MultiMod(Mods.Select(m => m.CreateCopy()).ToArray());
public override Type[] IncompatibleMods => Mods.SelectMany(m => m.IncompatibleMods).ToArray();
}
}