Simplify serialisation edge case by moving to `Value` override

This commit is contained in:
Dean Herbert 2021-07-08 17:40:09 +09:00
parent 52ea62e3b2
commit ba939c0b65
1 changed files with 10 additions and 4 deletions

View File

@ -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()