From ba939c0b657aa8bd683635b100bac9d2335c2e7f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 8 Jul 2021 17:40:09 +0900 Subject: [PATCH] Simplify serialisation edge case by moving to `Value` override --- osu.Game/Rulesets/Mods/DifficultyBindable.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game/Rulesets/Mods/DifficultyBindable.cs b/osu.Game/Rulesets/Mods/DifficultyBindable.cs index 7b01b1e0c7..22d8472922 100644 --- a/osu.Game/Rulesets/Mods/DifficultyBindable.cs +++ b/osu.Game/Rulesets/Mods/DifficultyBindable.cs @@ -73,13 +73,19 @@ public float? ExtendedMaxValue public DifficultyBindable() { ExtendedLimits.BindValueChanged(_ => updateMaxValue()); + } - BindValueChanged(val => + public override float? Value + { + get => base.Value; + set { // Ensure that in the case serialisation runs in the wrong order (and limit extensions aren't applied yet) the deserialised value is still propagated. - if (val.NewValue != null) - CurrentNumber.MaxValue = MathF.Max(CurrentNumber.MaxValue, val.NewValue.Value); - }); + if (value != null) + CurrentNumber.MaxValue = MathF.Max(CurrentNumber.MaxValue, value.Value); + + base.Value = value; + } } private void updateMaxValue()