diff --git a/osu.Game/Rulesets/Mods/ModTimeRamp.cs b/osu.Game/Rulesets/Mods/ModTimeRamp.cs
index 082f0091c6..8cd4b28ce3 100644
--- a/osu.Game/Rulesets/Mods/ModTimeRamp.cs
+++ b/osu.Game/Rulesets/Mods/ModTimeRamp.cs
@@ -34,18 +34,11 @@ namespace osu.Game.Rulesets.Mods
///
private const double final_rate_progress = 0.75f;
- ///
- /// The adjustment applied on entering this mod's application method.
- ///
- private double baseAdjust;
-
public virtual void ApplyToClock(IAdjustableClock clock)
{
this.clock = clock;
- // we capture the adjustment applied before entering our application method.
- // this will cover external changes, which should re-fire this method.
- baseAdjust = (clock as IHasPitchAdjust)?.PitchAdjust ?? clock.Rate;
+ lastAdjust = 1;
// for preview purposes. during gameplay, Update will overwrite this setting.
applyAdjustment(1);
@@ -61,20 +54,38 @@ namespace osu.Game.Rulesets.Mods
public virtual void Update(Playfield playfield)
{
- var absRate = Math.Abs(FinalRateAdjustment);
applyAdjustment((clock.CurrentTime - beginRampTime) / finalRateTime);
}
- private void applyAdjustment(double adjustAmount)
+ private double lastAdjust = 1;
+
+ private bool reported;
+
+ ///
+ /// Adjust the rate along the specified ramp
+ ///
+ /// The amount of adjustment to apply (from 0..1).
+ private void applyAdjustment(double amount)
{
- adjustAmount = MathHelper.Clamp(adjustAmount, 0, 1);
+ double adjust = 1 + (Math.Sign(FinalRateAdjustment) * MathHelper.Clamp(amount, 0, 1) * Math.Abs(FinalRateAdjustment));
- var localAdjust = 1 + Math.Sign(FinalRateAdjustment) * adjustAmount * Math.Abs(FinalRateAdjustment);
+ switch (clock)
+ {
+ case IHasPitchAdjust pitch:
+ pitch.PitchAdjust /= lastAdjust;
+ pitch.PitchAdjust *= adjust;
+ break;
+ case IHasTempoAdjust tempo:
+ tempo.TempoAdjust /= lastAdjust;
+ tempo.TempoAdjust *= adjust;
+ break;
+ default:
+ clock.Rate /= lastAdjust;
+ clock.Rate *= adjust;
+ break;
+ }
- if (clock is IHasPitchAdjust tempo)
- tempo.PitchAdjust = baseAdjust * localAdjust;
- else
- clock.Rate = baseAdjust * localAdjust;
+ lastAdjust = adjust;
}
}
}