2019-03-05 12:53:47 +08:00
|
|
|
// 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.
|
|
|
|
|
2019-03-25 19:25:47 +08:00
|
|
|
using osu.Framework.Bindables;
|
2019-03-05 12:53:47 +08:00
|
|
|
using osu.Framework.Timing;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A clock which is used for gameplay elements that need to follow audio time 1:1.
|
2019-04-25 16:36:17 +08:00
|
|
|
/// Exposed via DI by <see cref="GameplayClockContainer"/>.
|
2019-03-05 12:53:47 +08:00
|
|
|
/// <remarks>
|
2019-03-05 17:50:46 +08:00
|
|
|
/// The main purpose of this clock is to stop components using it from accidentally processing the main
|
2019-03-05 12:53:47 +08:00
|
|
|
/// <see cref="IFrameBasedClock"/>, as this should only be done once to ensure accuracy.
|
|
|
|
/// </remarks>
|
|
|
|
/// </summary>
|
2020-09-28 17:16:19 +08:00
|
|
|
public class GameplayClock : IFrameBasedClock, ISeekableClock
|
2019-03-05 12:53:47 +08:00
|
|
|
{
|
|
|
|
private readonly IFrameBasedClock underlyingClock;
|
|
|
|
|
2019-03-25 19:25:47 +08:00
|
|
|
public readonly BindableBool IsPaused = new BindableBool();
|
|
|
|
|
2019-03-05 12:53:47 +08:00
|
|
|
public GameplayClock(IFrameBasedClock underlyingClock)
|
|
|
|
{
|
|
|
|
this.underlyingClock = underlyingClock;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double CurrentTime => underlyingClock.CurrentTime;
|
|
|
|
|
|
|
|
public double Rate => underlyingClock.Rate;
|
|
|
|
|
|
|
|
public bool IsRunning => underlyingClock.IsRunning;
|
|
|
|
|
2020-05-21 09:58:30 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether an ongoing seek operation is active.
|
|
|
|
/// </summary>
|
|
|
|
public virtual bool IsSeeking => false;
|
|
|
|
|
2019-03-05 12:53:47 +08:00
|
|
|
public void ProcessFrame()
|
|
|
|
{
|
|
|
|
// we do not want to process the underlying clock.
|
|
|
|
}
|
|
|
|
|
|
|
|
public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime;
|
|
|
|
|
|
|
|
public double FramesPerSecond => underlyingClock.FramesPerSecond;
|
|
|
|
|
|
|
|
public FrameTimeInfo TimeInfo => underlyingClock.TimeInfo;
|
2019-09-17 21:33:27 +08:00
|
|
|
|
|
|
|
public IClock Source => underlyingClock;
|
2019-03-05 12:53:47 +08:00
|
|
|
}
|
2019-03-05 17:50:46 +08:00
|
|
|
}
|