1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:42:57 +08:00

Also share ScoreMultiplier implementation

This commit is contained in:
Dean Herbert 2023-10-18 17:23:14 +09:00
parent 43238b0cee
commit e56ff33271
No known key found for this signature in database
5 changed files with 34 additions and 57 deletions

View File

@ -27,9 +27,12 @@ namespace osu.Game.Rulesets.Mods
private readonly BindableNumber<double> tempoAdjust = new BindableDouble(1);
private readonly BindableNumber<double> freqAdjust = new BindableDouble(1);
private readonly RateAdjustModHelper rateAdjustHelper;
protected ModDaycore()
{
rateAdjustHelper = new RateAdjustModHelper(SpeedChange);
SpeedChange.BindValueChanged(val =>
{
freqAdjust.Value = SpeedChange.Default;
@ -43,18 +46,6 @@ namespace osu.Game.Rulesets.Mods
track.AddAdjustment(AdjustableProperty.Tempo, tempoAdjust);
}
public override 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;
return 1 + value;
}
}
public override double ScoreMultiplier => rateAdjustHelper.ScoreMultiplier;
}
}

View File

@ -42,21 +42,6 @@ namespace osu.Game.Rulesets.Mods
rateAdjustHelper.ApplyToTrack(track);
}
public override 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;
// Each 0.1 multiple changes score multiplier by 0.02.
value /= 5;
return 1 + value;
}
}
public override double ScoreMultiplier => rateAdjustHelper.ScoreMultiplier;
}
}

View File

@ -42,18 +42,6 @@ namespace osu.Game.Rulesets.Mods
rateAdjustHelper.ApplyToTrack(track);
}
public override 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;
return 1 + value;
}
}
public override double ScoreMultiplier => rateAdjustHelper.ScoreMultiplier;
}
}

View File

@ -39,8 +39,12 @@ namespace osu.Game.Rulesets.Mods
private readonly BindableNumber<double> tempoAdjust = new BindableDouble(1);
private readonly BindableNumber<double> freqAdjust = new BindableDouble(1);
private readonly RateAdjustModHelper rateAdjustHelper;
protected ModNightcore()
{
rateAdjustHelper = new RateAdjustModHelper(SpeedChange);
SpeedChange.BindValueChanged(val =>
{
freqAdjust.Value = SpeedChange.Default;
@ -54,19 +58,7 @@ namespace osu.Game.Rulesets.Mods
track.AddAdjustment(AdjustableProperty.Tempo, tempoAdjust);
}
public override 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;
return 1 + value;
}
}
public override double ScoreMultiplier => rateAdjustHelper.ScoreMultiplier;
}
public abstract partial class ModNightcore<TObject> : ModNightcore, IApplicableToDrawableRuleset<TObject>

View File

@ -6,13 +6,18 @@ using osu.Framework.Bindables;
namespace osu.Game.Rulesets.Mods
{
/// <summary>
/// Provides common functionality shared across various rate adjust mods.
/// </summary>
public class RateAdjustModHelper : IApplicableToTrack
{
private readonly BindableBool? adjustPitch;
private readonly BindableNumber<double> speedChange;
private IAdjustableAudioComponent? track;
public RateAdjustModHelper(BindableNumber<double> speedChange, BindableBool? adjustPitch)
public RateAdjustModHelper(BindableNumber<double> speedChange, BindableBool? adjustPitch = null)
{
this.speedChange = speedChange;
this.adjustPitch = adjustPitch;
// When switching between pitch adjust, we need to update adjustments to time-shift or frequency-scale.
@ -29,8 +34,24 @@ namespace osu.Game.Rulesets.Mods
public void ApplyToTrack(IAdjustableAudioComponent track)
{
this.track = track;
adjustPitch?.TriggerChange();
}
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;
}
}
}
}