1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-15 17:47:18 +08:00

Update DifficultyBindable to match new bindable spec

This commit is contained in:
Dean Herbert 2022-11-22 14:51:17 +09:00
parent 06ce8130c2
commit 1632df1f4d

View File

@ -99,22 +99,31 @@ namespace osu.Game.Rulesets.Mods
CurrentNumber.MaxValue = ExtendedLimits.Value && extendedMaxValue != null ? extendedMaxValue.Value : maxValue;
}
public override void CopyTo(Bindable<float?> 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<float?> 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)