1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 22:35:23 +08:00

Use new flow to calcaulate TrueGameplayRate

This commit is contained in:
Dean Herbert 2022-09-05 23:37:41 +09:00
parent 7084aeee05
commit 266eb758aa
2 changed files with 23 additions and 31 deletions

View File

@ -10,7 +10,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Logging;
using osu.Framework.Timing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
namespace osu.Game.Screens.Play
@ -225,22 +224,6 @@ namespace osu.Game.Screens.Play
public FrameTimeInfo TimeInfo => GameplayClock.TimeInfo;
public double TrueGameplayRate
{
get
{
double baseRate = Rate;
foreach (double adjustment in NonGameplayAdjustments)
{
if (Precision.AlmostEquals(adjustment, 0))
return 0;
baseRate /= adjustment;
}
return baseRate;
}
}
public virtual double TrueGameplayRate => Rate;
}
}

View File

@ -45,8 +45,6 @@ namespace osu.Game.Screens.Play
private readonly double skipTargetTime;
private readonly List<Bindable<double>> nonGameplayAdjustments = new List<Bindable<double>>();
/// <summary>
/// Stores the time at which the last <see cref="StopGameplayClock"/> call was triggered.
/// This is used to ensure we resume from that precise point in time, ignoring the proceeding frequency ramp.
@ -58,8 +56,6 @@ namespace osu.Game.Screens.Play
/// </summary>
private double? actualStopTime;
public override IEnumerable<double> NonGameplayAdjustments => nonGameplayAdjustments.Select(b => b.Value);
/// <summary>
/// Create a new master gameplay clock container.
/// </summary>
@ -201,9 +197,6 @@ namespace osu.Game.Screens.Play
track.AddAdjustment(AdjustableProperty.Frequency, GameplayClock.ExternalPauseFrequencyAdjust);
track.AddAdjustment(AdjustableProperty.Tempo, UserPlaybackRate);
nonGameplayAdjustments.Add(GameplayClock.ExternalPauseFrequencyAdjust);
nonGameplayAdjustments.Add(UserPlaybackRate);
speedAdjustmentsApplied = true;
}
@ -215,9 +208,6 @@ namespace osu.Game.Screens.Play
track.RemoveAdjustment(AdjustableProperty.Frequency, GameplayClock.ExternalPauseFrequencyAdjust);
track.RemoveAdjustment(AdjustableProperty.Tempo, UserPlaybackRate);
nonGameplayAdjustments.Remove(GameplayClock.ExternalPauseFrequencyAdjust);
nonGameplayAdjustments.Remove(UserPlaybackRate);
speedAdjustmentsApplied = false;
}
@ -232,11 +222,30 @@ namespace osu.Game.Screens.Play
ChannelAmplitudes IHasAmplitudes.CurrentAmplitudes => beatmap.TrackLoaded ? beatmap.Track.CurrentAmplitudes : ChannelAmplitudes.Empty;
void IAdjustableAudioComponent.AddAdjustment(AdjustableProperty type, IBindable<double> adjustBindable) =>
track.AddAdjustment(type, adjustBindable);
private readonly List<IBindable<double>> speedAdjustments = new List<IBindable<double>>();
void IAdjustableAudioComponent.RemoveAdjustment(AdjustableProperty type, IBindable<double> adjustBindable) =>
public override double TrueGameplayRate
{
get
{
double rate = Rate;
foreach (var a in speedAdjustments)
rate *= a.Value;
return rate;
}
}
void IAdjustableAudioComponent.AddAdjustment(AdjustableProperty type, IBindable<double> adjustBindable)
{
speedAdjustments.Add(adjustBindable);
track.AddAdjustment(type, adjustBindable);
}
void IAdjustableAudioComponent.RemoveAdjustment(AdjustableProperty type, IBindable<double> adjustBindable)
{
speedAdjustments.Remove(adjustBindable);
track.RemoveAdjustment(type, adjustBindable);
}
public override void ResetSpeedAdjustments()
{