1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 23:43:03 +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 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; } protected abstract double FinalRateAdjustment { get; }
} }
@ -29,20 +29,26 @@ namespace osu.Game.Rulesets.Mods
private IAdjustableClock clock; private IAdjustableClock clock;
private IHasPitchAdjust pitchAdjust;
/// <summary> /// <summary>
/// The point in the beatmap at which the final ramping rate should be reached. /// The point in the beatmap at which the final ramping rate should be reached.
/// </summary> /// </summary>
private const double final_rate_progress = 0.75f; 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) public virtual void ApplyToClock(IAdjustableClock clock)
{ {
this.clock = clock; this.clock = clock;
pitchAdjust = (IHasPitchAdjust)clock;
// for preview purposes // we capture the adjustment applied before entering our application method.
pitchAdjust.PitchAdjust = 1.0 + FinalRateAdjustment; // 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) public virtual void ApplyToBeatmap(Beatmap<T> beatmap)
@ -56,9 +62,17 @@ namespace osu.Game.Rulesets.Mods
public virtual void Update(Playfield playfield) public virtual void Update(Playfield playfield)
{ {
var absRate = Math.Abs(FinalRateAdjustment); 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. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
@ -14,6 +16,9 @@ namespace osu.Game.Rulesets.Mods
public override string Description => "Sloooow doooown..."; public override string Description => "Sloooow doooown...";
public override FontAwesome Icon => FontAwesome.fa_chevron_circle_down; public override FontAwesome Icon => FontAwesome.fa_chevron_circle_down;
public override double ScoreMultiplier => 1.0; public override double ScoreMultiplier => 1.0;
protected override double FinalRateAdjustment => -0.25; 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. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
@ -14,6 +16,9 @@ namespace osu.Game.Rulesets.Mods
public override string Description => "Can you keep up?"; public override string Description => "Can you keep up?";
public override FontAwesome Icon => FontAwesome.fa_chevron_circle_up; public override FontAwesome Icon => FontAwesome.fa_chevron_circle_up;
public override double ScoreMultiplier => 1.0; public override double ScoreMultiplier => 1.0;
protected override double FinalRateAdjustment => 0.5; protected override double FinalRateAdjustment => 0.5;
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModWindDown<T>)).ToArray();
} }
} }