1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 20:22:55 +08:00

Improve ModRamp's handling of external rate changes

This commit is contained in:
Dean Herbert 2019-03-12 18:15:18 +09:00
parent 6832e384a9
commit a10cd2288d
3 changed files with 33 additions and 9 deletions

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Mods
{
public abstract class ModTimeRamp : Mod
{
public override Type[] IncompatibleMods => new[] { typeof(ModDoubleTime), typeof(ModHalfTime) };
public override Type[] IncompatibleMods => new[] { typeof(ModTimeAdjust) };
protected abstract double FinalRateAdjustment { get; }
}
@ -29,20 +29,26 @@ namespace osu.Game.Rulesets.Mods
private IAdjustableClock clock;
private IHasPitchAdjust pitchAdjust;
/// <summary>
/// The point in the beatmap at which the final ramping rate should be reached.
/// </summary>
private const double final_rate_progress = 0.75f;
/// <summary>
/// The adjustment applied on entering this mod's application method.
/// </summary>
private double baseAdjust;
public virtual void ApplyToClock(IAdjustableClock clock)
{
this.clock = clock;
pitchAdjust = (IHasPitchAdjust)clock;
// for preview purposes
pitchAdjust.PitchAdjust = 1.0 + FinalRateAdjustment;
// 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;
// for preview purposes. during gameplay, Update will overwrite this setting.
applyAdjustment(1);
}
public virtual void ApplyToBeatmap(Beatmap<T> beatmap)
@ -56,9 +62,17 @@ namespace osu.Game.Rulesets.Mods
public virtual void Update(Playfield playfield)
{
var absRate = Math.Abs(FinalRateAdjustment);
var adjustment = MathHelper.Clamp(absRate * ((clock.CurrentTime - beginRampTime) / finalRateTime), 0, absRate);
applyAdjustment(MathHelper.Clamp(absRate * ((clock.CurrentTime - beginRampTime) / finalRateTime), 0, absRate));
}
pitchAdjust.PitchAdjust = 1 + Math.Sign(FinalRateAdjustment) * adjustment;
private void applyAdjustment(double adjustment)
{
var localAdjust = 1 + Math.Sign(FinalRateAdjustment) * adjustment;
if (clock is IHasPitchAdjust tempo)
tempo.PitchAdjust = baseAdjust * localAdjust;
else
clock.Rate *= baseAdjust * localAdjust;
}
}
}

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects;
@ -14,6 +16,9 @@ namespace osu.Game.Rulesets.Mods
public override string Description => "Sloooow doooown...";
public override FontAwesome Icon => FontAwesome.fa_chevron_circle_down;
public override double ScoreMultiplier => 1.0;
protected override double FinalRateAdjustment => -0.25;
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModWindUp<T>)).ToArray();
}
}

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects;
@ -14,6 +16,9 @@ namespace osu.Game.Rulesets.Mods
public override string Description => "Can you keep up?";
public override FontAwesome Icon => FontAwesome.fa_chevron_circle_up;
public override double ScoreMultiplier => 1.0;
protected override double FinalRateAdjustment => 0.5;
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModWindDown<T>)).ToArray();
}
}
}