mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 14:42:56 +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;
|
currentRotation += angle;
|
||||||
// rate has to be applied each frame, because it's not guaranteed to be constant throughout playback
|
// rate has to be applied each frame, because it's not guaranteed to be constant throughout playback
|
||||||
// (see: ModTimeRamp)
|
// (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)
|
private void resetState(DrawableHitObject obj)
|
||||||
|
@ -13,17 +13,17 @@ namespace osu.Game.Tests.NonVisual
|
|||||||
{
|
{
|
||||||
[TestCase(0)]
|
[TestCase(0)]
|
||||||
[TestCase(1)]
|
[TestCase(1)]
|
||||||
public void TestTrueGameplayRateWithZeroAdjustment(double underlyingClockRate)
|
public void TestTrueGameplayRateWithGameplayAdjustment(double underlyingClockRate)
|
||||||
{
|
{
|
||||||
var framedClock = new FramedClock(new ManualClock { Rate = underlyingClockRate });
|
var framedClock = new FramedClock(new ManualClock { Rate = underlyingClockRate });
|
||||||
var gameplayClock = new TestGameplayClockContainer(framedClock);
|
var gameplayClock = new TestGameplayClockContainer(framedClock);
|
||||||
|
|
||||||
Assert.That(gameplayClock.TrueGameplayRate, Is.EqualTo(0));
|
Assert.That(gameplayClock.GetTrueGameplayRate(), Is.EqualTo(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestGameplayClockContainer : GameplayClockContainer
|
private class TestGameplayClockContainer : GameplayClockContainer
|
||||||
{
|
{
|
||||||
public override IEnumerable<double> NonGameplayAdjustments => new[] { 0.0 };
|
public override IEnumerable<double> GameplayAdjustments => new[] { 2.0 };
|
||||||
|
|
||||||
public TestGameplayClockContainer(IFrameBasedClock underlyingClock)
|
public TestGameplayClockContainer(IFrameBasedClock underlyingClock)
|
||||||
: base(underlyingClock)
|
: base(underlyingClock)
|
||||||
|
@ -370,7 +370,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private void confirmNoTrackAdjustments()
|
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());
|
private void restart() => AddStep("restart", () => Player.Restart());
|
||||||
|
@ -10,7 +10,6 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Game.Input.Handlers;
|
using osu.Game.Input.Handlers;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
@ -263,11 +262,9 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
public FrameTimeInfo TimeInfo => framedClock.TimeInfo;
|
public FrameTimeInfo TimeInfo => framedClock.TimeInfo;
|
||||||
|
|
||||||
public double TrueGameplayRate => parentGameplayClock?.TrueGameplayRate ?? Rate;
|
|
||||||
|
|
||||||
public double StartTime => parentGameplayClock?.StartTime ?? 0;
|
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
|
#endregion
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public double StartTime { get; protected set; }
|
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);
|
private readonly BindableBool isPaused = new BindableBool(true);
|
||||||
|
|
||||||
@ -223,7 +223,5 @@ namespace osu.Game.Screens.Play
|
|||||||
public double FramesPerSecond => GameplayClock.FramesPerSecond;
|
public double FramesPerSecond => GameplayClock.FramesPerSecond;
|
||||||
|
|
||||||
public FrameTimeInfo TimeInfo => GameplayClock.TimeInfo;
|
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
|
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>
|
/// <summary>
|
||||||
/// The time from which the clock should start. Will be seeked to on calling <see cref="GameplayClockContainer.Reset"/>.
|
/// The time from which the clock should start. Will be seeked to on calling <see cref="GameplayClockContainer.Reset"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -27,7 +21,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// All adjustments applied to this clock which don't come from gameplay or mods.
|
/// All adjustments applied to this clock which don't come from gameplay or mods.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IEnumerable<double> NonGameplayAdjustments { get; }
|
IEnumerable<double> GameplayAdjustments { get; }
|
||||||
|
|
||||||
IBindable<bool> IsPaused { get; }
|
IBindable<bool> IsPaused { get; }
|
||||||
}
|
}
|
||||||
|
@ -224,16 +224,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private readonly List<IBindable<double>> speedAdjustments = new List<IBindable<double>>();
|
private readonly List<IBindable<double>> speedAdjustments = new List<IBindable<double>>();
|
||||||
|
|
||||||
public override double TrueGameplayRate
|
public override IEnumerable<double> GameplayAdjustments => speedAdjustments.Select(bindable => bindable.Value);
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
double rate = Rate;
|
|
||||||
foreach (var a in speedAdjustments)
|
|
||||||
rate *= a.Value;
|
|
||||||
return rate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IAdjustableAudioComponent.AddAdjustment(AdjustableProperty type, IBindable<double> adjustBindable)
|
void IAdjustableAudioComponent.AddAdjustment(AdjustableProperty type, IBindable<double> adjustBindable)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user