From 9907adc337dd7d4d14c2b0b0b8144695fcc475a2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 18 Oct 2023 17:39:11 +0900 Subject: [PATCH] Take in `IBindable`s and tidy up multiplier handling --- osu.Game/Rulesets/Mods/RateAdjustModHelper.cs | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/osu.Game/Rulesets/Mods/RateAdjustModHelper.cs b/osu.Game/Rulesets/Mods/RateAdjustModHelper.cs index 701bad06bc..ffd4de0e90 100644 --- a/osu.Game/Rulesets/Mods/RateAdjustModHelper.cs +++ b/osu.Game/Rulesets/Mods/RateAdjustModHelper.cs @@ -12,19 +12,39 @@ namespace osu.Game.Rulesets.Mods /// public class RateAdjustModHelper : IApplicableToTrack { - private readonly BindableNumber speedChange; + public readonly IBindableNumber SpeedChange; private IAdjustableAudioComponent? track; private BindableBool? adjustPitch; + /// + /// The score multiplier for the current . + /// + public double ScoreMultiplier + { + get + { + // Round to the nearest multiple of 0.1. + double value = (int)(SpeedChange.Value * 10) / 10.0; + + // Offset back to 0. + value -= 1; + + if (SpeedChange.Value >= 1) + value /= 5; + + return 1 + value; + } + } + /// /// Construct a new . /// /// The main speed adjust parameter which is exposed to the user. - public RateAdjustModHelper(BindableNumber speedChange) + public RateAdjustModHelper(IBindableNumber speedChange) { - this.speedChange = speedChange; + SpeedChange = speedChange; } /// @@ -39,8 +59,8 @@ namespace osu.Game.Rulesets.Mods // When switching between pitch adjust, we need to update adjustments to time-shift or frequency-scale. adjustPitch.BindValueChanged(adjustPitchSetting => { - track?.RemoveAdjustment(adjustmentForPitchSetting(adjustPitchSetting.OldValue), speedChange); - track?.AddAdjustment(adjustmentForPitchSetting(adjustPitchSetting.NewValue), speedChange); + track?.RemoveAdjustment(adjustmentForPitchSetting(adjustPitchSetting.OldValue), SpeedChange); + track?.AddAdjustment(adjustmentForPitchSetting(adjustPitchSetting.NewValue), SpeedChange); AdjustableProperty adjustmentForPitchSetting(bool adjustPitchSettingValue) => adjustPitchSettingValue ? AdjustableProperty.Frequency : AdjustableProperty.Tempo; @@ -60,25 +80,5 @@ namespace osu.Game.Rulesets.Mods this.track = track; adjustPitch.TriggerChange(); } - - /// - /// The score multiplier for the current . - /// - public double ScoreMultiplier - { - get - { - // Round to the nearest multiple of 0.1. - double value = (int)(speedChange.Value * 10) / 10.0; - - // Offset back to 0. - value -= 1; - - if (speedChange.Value >= 1) - value /= 5; - - return 1 + value; - } - } } }