Remove unnecessary setClock shenanigans

This commit is contained in:
Dean Herbert
2022-08-15 19:01:28 +09:00
parent 27569e2ed5
commit 828b6f2c30

View File

@ -77,7 +77,7 @@ namespace osu.Game.Rulesets.UI
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
setClock(); Clock = this;
} }
private PlaybackState state; private PlaybackState state;
@ -128,12 +128,7 @@ namespace osu.Game.Rulesets.UI
state = PlaybackState.Valid; state = PlaybackState.Valid;
} }
if (parentGameplayClock == null) double proposedTime = Clock.CurrentTime;
setClock(); // LoadComplete may not be run yet, but we still want the clock.
Debug.Assert(parentGameplayClock != null);
double proposedTime = parentGameplayClock.CurrentTime;
if (FrameStablePlayback) if (FrameStablePlayback)
// if we require frame stability, the proposed time will be adjusted to move at most one known // if we require frame stability, the proposed time will be adjusted to move at most one known
@ -153,14 +148,14 @@ namespace osu.Game.Rulesets.UI
if (state == PlaybackState.Valid && proposedTime != manualClock.CurrentTime) if (state == PlaybackState.Valid && proposedTime != manualClock.CurrentTime)
direction = proposedTime >= manualClock.CurrentTime ? 1 : -1; direction = proposedTime >= manualClock.CurrentTime ? 1 : -1;
double timeBehind = Math.Abs(proposedTime - parentGameplayClock.CurrentTime); double timeBehind = Math.Abs(proposedTime - Clock.CurrentTime);
IsCatchingUp.Value = timeBehind > 200; IsCatchingUp.Value = timeBehind > 200;
WaitingOnFrames.Value = state == PlaybackState.NotValid; WaitingOnFrames.Value = state == PlaybackState.NotValid;
manualClock.CurrentTime = proposedTime; manualClock.CurrentTime = proposedTime;
manualClock.Rate = Math.Abs(parentGameplayClock.Rate) * direction; manualClock.Rate = Math.Abs(Clock.Rate) * direction;
manualClock.IsRunning = parentGameplayClock.IsRunning; manualClock.IsRunning = Clock.IsRunning;
// determine whether catch-up is required. // determine whether catch-up is required.
if (state == PlaybackState.Valid && timeBehind > 0) if (state == PlaybackState.Valid && timeBehind > 0)
@ -239,12 +234,6 @@ namespace osu.Game.Rulesets.UI
} }
} }
private void setClock()
{
if (parentGameplayClock != null)
Clock = this;
}
public ReplayInputHandler? ReplayInputHandler { get; set; } public ReplayInputHandler? ReplayInputHandler { get; set; }
#region Delegation of IFrameStableClock #region Delegation of IFrameStableClock