From 1632df1f4db4a9aea047548f3ad6205ebdfd4eda Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 22 Nov 2022 14:51:17 +0900 Subject: [PATCH] Update `DifficultyBindable` to match new bindable spec --- osu.Game/Rulesets/Mods/DifficultyBindable.cs | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/osu.Game/Rulesets/Mods/DifficultyBindable.cs b/osu.Game/Rulesets/Mods/DifficultyBindable.cs index 34e9fe40a3..2b3ba1dd13 100644 --- a/osu.Game/Rulesets/Mods/DifficultyBindable.cs +++ b/osu.Game/Rulesets/Mods/DifficultyBindable.cs @@ -99,22 +99,31 @@ namespace osu.Game.Rulesets.Mods CurrentNumber.MaxValue = ExtendedLimits.Value && extendedMaxValue != null ? extendedMaxValue.Value : maxValue; } + public override void CopyTo(Bindable them) + { + if (!(them is DifficultyBindable otherDifficultyBindable)) + throw new InvalidOperationException($"Cannot copy to a non-{nameof(DifficultyBindable)}."); + + base.CopyTo(them); + + otherDifficultyBindable.ReadCurrentFromDifficulty = ReadCurrentFromDifficulty; + + // the following max value copies are only safe as long as these values are effectively constants. + otherDifficultyBindable.MaxValue = maxValue; + otherDifficultyBindable.ExtendedMaxValue = extendedMaxValue; + } + public override void BindTo(Bindable them) { if (!(them is DifficultyBindable otherDifficultyBindable)) throw new InvalidOperationException($"Cannot bind to a non-{nameof(DifficultyBindable)}."); - ReadCurrentFromDifficulty = otherDifficultyBindable.ReadCurrentFromDifficulty; - - // the following max value copies are only safe as long as these values are effectively constants. - MaxValue = otherDifficultyBindable.maxValue; - ExtendedMaxValue = otherDifficultyBindable.extendedMaxValue; + base.BindTo(them); ExtendedLimits.BindTarget = otherDifficultyBindable.ExtendedLimits; // the actual values need to be copied after the max value constraints. CurrentNumber.BindTarget = otherDifficultyBindable.CurrentNumber; - base.BindTo(them); } public override void UnbindFrom(IUnbindable them)