diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index ee65384bc9..3da28f3560 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -29,17 +29,22 @@ public abstract class GameplayClockContainer : Container /// protected readonly DecoupleableInterpolatingFramedClock AdjustableSource; + /// + /// The source clock. + /// + protected IClock SourceClock { get; private set; } + /// /// Creates a new . /// /// The source used for timing. protected GameplayClockContainer(IClock sourceClock) { + SourceClock = sourceClock; + RelativeSizeAxes = Axes.Both; AdjustableSource = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; - AdjustableSource.ChangeSource(sourceClock); - IsPaused.BindValueChanged(OnIsPausedChanged); } @@ -86,6 +91,8 @@ public virtual void Start() /// public virtual void Reset() { + ChangeSource(SourceClock); + AdjustableSource.Seek(0); AdjustableSource.Stop(); @@ -93,6 +100,12 @@ public virtual void Reset() Start(); } + /// + /// Changes the source clock. + /// + /// The new source. + protected void ChangeSource(IClock sourceClock) => AdjustableSource.ChangeSource(SourceClock = sourceClock); + protected override void Update() { if (!IsPaused.Value) diff --git a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs index 5ea50cbdc7..f019e50b60 100644 --- a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs +++ b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs @@ -33,7 +33,7 @@ public class MasterGameplayClockContainer : GameplayClockContainer /// public const double MINIMUM_SKIP_TIME = 1000; - protected Track Track => (Track)AdjustableSource.Source; + protected Track Track => (Track)SourceClock; public readonly BindableNumber UserPlaybackRate = new BindableDouble(1) { @@ -164,7 +164,7 @@ protected override GameplayClock CreateGameplayClock(IFrameBasedClock source) public void StopUsingBeatmapClock() { removeSourceClockAdjustments(); - AdjustableSource.ChangeSource(new TrackVirtual(beatmap.Track.Length)); + ChangeSource(new TrackVirtual(beatmap.Track.Length)); } private bool speedAdjustmentsApplied;