Fix direction and IsRunning not updating on first frame after becoming valid

The parent clock will not unpause until WaitingForFrames becomes false,
so I've moved the set of that before we start to propagate its values
across. Doesn't fix any visible issue but should make propagation one
game loop faster.
This commit is contained in:
Dean Herbert 2020-10-30 15:26:21 +09:00
parent 326fd03525
commit 0f997386ae

View File

@ -144,22 +144,22 @@ namespace osu.Game.Rulesets.UI
state = PlaybackState.NotValid;
}
if (proposedTime != manualClock.CurrentTime)
if (state == PlaybackState.Valid)
direction = proposedTime >= manualClock.CurrentTime ? 1 : -1;
double timeBehind = Math.Abs(proposedTime - parentGameplayClock.CurrentTime);
frameStableClock.IsCatchingUp.Value = timeBehind > 200;
frameStableClock.WaitingOnFrames.Value = state == PlaybackState.NotValid;
manualClock.CurrentTime = proposedTime;
manualClock.Rate = Math.Abs(parentGameplayClock.Rate) * direction;
manualClock.IsRunning = parentGameplayClock.IsRunning;
double timeBehind = Math.Abs(manualClock.CurrentTime - parentGameplayClock.CurrentTime);
// determine whether catch-up is required.
if (state == PlaybackState.Valid && timeBehind > 0)
state = PlaybackState.RequiresCatchUp;
frameStableClock.IsCatchingUp.Value = timeBehind > 200;
frameStableClock.WaitingOnFrames.Value = state == PlaybackState.NotValid;
// The manual clock time has changed in the above code. The framed clock now needs to be updated
// to ensure that the its time is valid for our children before input is processed
framedClock.ProcessFrame();