mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 10:33:07 +08:00
Change NonGameplayAdjustments
to GameplayAdjustments
and convert TrueGameplayRate
to extension method
This commit is contained in:
parent
44b456e216
commit
bc1212f4e6
@ -110,7 +110,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
||||
currentRotation += angle;
|
||||
// rate has to be applied each frame, because it's not guaranteed to be constant throughout playback
|
||||
// (see: ModTimeRamp)
|
||||
drawableSpinner.Result.RateAdjustedRotation += (float)(Math.Abs(angle) * (gameplayClock?.TrueGameplayRate ?? Clock.Rate));
|
||||
drawableSpinner.Result.RateAdjustedRotation += (float)(Math.Abs(angle) * (gameplayClock?.GetTrueGameplayRate() ?? Clock.Rate));
|
||||
}
|
||||
|
||||
private void resetState(DrawableHitObject obj)
|
||||
|
@ -13,17 +13,17 @@ namespace osu.Game.Tests.NonVisual
|
||||
{
|
||||
[TestCase(0)]
|
||||
[TestCase(1)]
|
||||
public void TestTrueGameplayRateWithZeroAdjustment(double underlyingClockRate)
|
||||
public void TestTrueGameplayRateWithGameplayAdjustment(double underlyingClockRate)
|
||||
{
|
||||
var framedClock = new FramedClock(new ManualClock { Rate = underlyingClockRate });
|
||||
var gameplayClock = new TestGameplayClockContainer(framedClock);
|
||||
|
||||
Assert.That(gameplayClock.TrueGameplayRate, Is.EqualTo(0));
|
||||
Assert.That(gameplayClock.GetTrueGameplayRate(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
private class TestGameplayClockContainer : GameplayClockContainer
|
||||
{
|
||||
public override IEnumerable<double> NonGameplayAdjustments => new[] { 0.0 };
|
||||
public override IEnumerable<double> GameplayAdjustments => new[] { 2.0 };
|
||||
|
||||
public TestGameplayClockContainer(IFrameBasedClock underlyingClock)
|
||||
: base(underlyingClock)
|
||||
|
@ -370,7 +370,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private void confirmNoTrackAdjustments()
|
||||
{
|
||||
AddAssert("track has no adjustments", () => Beatmap.Value.Track.AggregateFrequency.Value == 1);
|
||||
AddUntilStep("track has no adjustments", () => Beatmap.Value.Track.AggregateFrequency.Value, () => Is.EqualTo(1));
|
||||
}
|
||||
|
||||
private void restart() => AddStep("restart", () => Player.Restart());
|
||||
|
@ -10,7 +10,6 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Input.Handlers;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
@ -263,11 +262,9 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
public FrameTimeInfo TimeInfo => framedClock.TimeInfo;
|
||||
|
||||
public double TrueGameplayRate => parentGameplayClock?.TrueGameplayRate ?? Rate;
|
||||
|
||||
public double StartTime => parentGameplayClock?.StartTime ?? 0;
|
||||
|
||||
public IEnumerable<double> NonGameplayAdjustments => parentGameplayClock?.NonGameplayAdjustments ?? Enumerable.Empty<double>();
|
||||
public IEnumerable<double> GameplayAdjustments => parentGameplayClock?.GameplayAdjustments ?? Enumerable.Empty<double>();
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Screens.Play
|
||||
/// </remarks>
|
||||
public double StartTime { get; protected set; }
|
||||
|
||||
public virtual IEnumerable<double> NonGameplayAdjustments => Enumerable.Empty<double>();
|
||||
public virtual IEnumerable<double> GameplayAdjustments => Enumerable.Empty<double>();
|
||||
|
||||
private readonly BindableBool isPaused = new BindableBool(true);
|
||||
|
||||
@ -223,7 +223,5 @@ namespace osu.Game.Screens.Play
|
||||
public double FramesPerSecond => GameplayClock.FramesPerSecond;
|
||||
|
||||
public FrameTimeInfo TimeInfo => GameplayClock.TimeInfo;
|
||||
|
||||
public virtual double TrueGameplayRate => Rate;
|
||||
}
|
||||
}
|
||||
|
22
osu.Game/Screens/Play/GameplayClockExtensions.cs
Normal file
22
osu.Game/Screens/Play/GameplayClockExtensions.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// 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;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public static class GameplayClockExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// The rate of gameplay when playback is at 100%.
|
||||
/// This excludes any seeking / user adjustments.
|
||||
/// </summary>
|
||||
public static double GetTrueGameplayRate(this IGameplayClock clock)
|
||||
{
|
||||
double rate = Math.Sign(clock.Rate);
|
||||
foreach (double a in clock.GameplayAdjustments)
|
||||
rate *= a;
|
||||
return rate;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,12 +9,6 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public interface IGameplayClock : IFrameBasedClock
|
||||
{
|
||||
/// <summary>
|
||||
/// The rate of gameplay when playback is at 100%.
|
||||
/// This excludes any seeking / user adjustments.
|
||||
/// </summary>
|
||||
double TrueGameplayRate { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The time from which the clock should start. Will be seeked to on calling <see cref="GameplayClockContainer.Reset"/>.
|
||||
/// </summary>
|
||||
@ -27,7 +21,7 @@ namespace osu.Game.Screens.Play
|
||||
/// <summary>
|
||||
/// All adjustments applied to this clock which don't come from gameplay or mods.
|
||||
/// </summary>
|
||||
IEnumerable<double> NonGameplayAdjustments { get; }
|
||||
IEnumerable<double> GameplayAdjustments { get; }
|
||||
|
||||
IBindable<bool> IsPaused { get; }
|
||||
}
|
||||
|
@ -224,16 +224,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private readonly List<IBindable<double>> speedAdjustments = new List<IBindable<double>>();
|
||||
|
||||
public override double TrueGameplayRate
|
||||
{
|
||||
get
|
||||
{
|
||||
double rate = Rate;
|
||||
foreach (var a in speedAdjustments)
|
||||
rate *= a.Value;
|
||||
return rate;
|
||||
}
|
||||
}
|
||||
public override IEnumerable<double> GameplayAdjustments => speedAdjustments.Select(bindable => bindable.Value);
|
||||
|
||||
void IAdjustableAudioComponent.AddAdjustment(AdjustableProperty type, IBindable<double> adjustBindable)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user