From 4e33a98dbca57b722ae4e5d3dbb93ecbcb48e591 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Mar 2019 13:53:47 +0900 Subject: [PATCH] Move gameplay clock to own class --- osu.Game/Screens/Play/GameplayClock.cs | 43 +++++++++++++++++++++++++ osu.Game/Screens/Play/PauseContainer.cs | 36 --------------------- 2 files changed, 43 insertions(+), 36 deletions(-) create mode 100644 osu.Game/Screens/Play/GameplayClock.cs diff --git a/osu.Game/Screens/Play/GameplayClock.cs b/osu.Game/Screens/Play/GameplayClock.cs new file mode 100644 index 0000000000..e7b80b6d76 --- /dev/null +++ b/osu.Game/Screens/Play/GameplayClock.cs @@ -0,0 +1,43 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Timing; + +namespace osu.Game.Screens.Play +{ + /// + /// A clock which is used for gameplay elements that need to follow audio time 1:1. + /// Exposed via DI by . + /// + /// THe main purpose of this clock is to stop components using it from accidentally processing the main + /// , as this should only be done once to ensure accuracy. + /// + /// + public class GameplayClock : IFrameBasedClock + { + private readonly IFrameBasedClock underlyingClock; + + public GameplayClock(IFrameBasedClock underlyingClock) + { + this.underlyingClock = underlyingClock; + } + + public double CurrentTime => underlyingClock.CurrentTime; + + public double Rate => underlyingClock.Rate; + + public bool IsRunning => underlyingClock.IsRunning; + + public void ProcessFrame() + { + // we do not want to process the underlying clock. + // this is handled by PauseContainer. + } + + public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime; + + public double FramesPerSecond => underlyingClock.FramesPerSecond; + + public FrameTimeInfo TimeInfo => underlyingClock.TimeInfo; + } +} \ No newline at end of file diff --git a/osu.Game/Screens/Play/PauseContainer.cs b/osu.Game/Screens/Play/PauseContainer.cs index c12e5227c8..da1d6ede5e 100644 --- a/osu.Game/Screens/Play/PauseContainer.cs +++ b/osu.Game/Screens/Play/PauseContainer.cs @@ -154,40 +154,4 @@ namespace osu.Game.Screens.Play } } } - - /// - /// A clock which is used for gameplay elements that need to follow audio time 1:1. - /// Exposed via DI by . - /// - /// THe main purpose of this clock is to stop components using it from accidentally processing the main - /// , as this should only be done once to ensure accuracy. - /// - /// - public class GameplayClock : IFrameBasedClock - { - private readonly IFrameBasedClock underlyingClock; - - public GameplayClock(IFrameBasedClock underlyingClock) - { - this.underlyingClock = underlyingClock; - } - - public double CurrentTime => underlyingClock.CurrentTime; - - public double Rate => underlyingClock.Rate; - - public bool IsRunning => underlyingClock.IsRunning; - - public void ProcessFrame() - { - // we do not want to process the underlying clock. - // this is handled by PauseContainer. - } - - public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime; - - public double FramesPerSecond => underlyingClock.FramesPerSecond; - - public FrameTimeInfo TimeInfo => underlyingClock.TimeInfo; - } }