1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +08:00

Expose and set GameplayStartTime directly, rather than via Reset parameter

This commit is contained in:
Dean Herbert 2022-04-13 13:49:58 +09:00
parent 9c68b3edc5
commit d4286255a0
4 changed files with 8 additions and 10 deletions

View File

@ -197,7 +197,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
.DefaultIfEmpty(0)
.Min();
masterClockContainer.Reset(true, startTime);
masterClockContainer.StartTime = startTime;
masterClockContainer.Reset(true);
// Although the clock has been started, this flag is set to allow for later synchronisation state changes to also be able to start it.
canStartMasterClock = true;

View File

@ -48,7 +48,7 @@ namespace osu.Game.Screens.Play
/// If not set, a value of zero will be used.
/// Importantly, the value will be inferred from the current ruleset in <see cref="MasterGameplayClockContainer"/> unless specified.
/// </remarks>
protected double? StartTime { get; set; }
public double? StartTime { get; set; }
/// <summary>
/// Creates a new <see cref="GameplayClockContainer"/>.
@ -116,12 +116,8 @@ namespace osu.Game.Screens.Play
/// Resets this <see cref="GameplayClockContainer"/> and the source to an initial state ready for gameplay.
/// </summary>
/// <param name="startClock">Whether to start the clock immediately, if not already started.</param>
/// <param name="gameplayStartTime">A time to use for future <see cref="Reset"/> calls as the definite start of gameplay.</param>
public void Reset(bool startClock = false, double? gameplayStartTime = null)
public void Reset(bool startClock = false)
{
if (gameplayStartTime != null)
StartTime = gameplayStartTime;
// Manually stop the source in order to not affect the IsPaused state.
AdjustableSource.Stop();

View File

@ -100,9 +100,9 @@ namespace osu.Game.Screens.Play
bool isStarted = !IsPaused.Value;
// If a custom start time was not specified, calculate the best value to use.
double gameplayStartTime = StartTime ?? findEarliestStartTime();
StartTime ??= findEarliestStartTime();
Reset(startClock: isStarted, gameplayStartTime: gameplayStartTime);
Reset(startClock: isStarted);
}
private double findEarliestStartTime()

View File

@ -621,7 +621,8 @@ namespace osu.Game.Screens.Play
bool wasFrameStable = DrawableRuleset.FrameStablePlayback;
DrawableRuleset.FrameStablePlayback = false;
GameplayClockContainer.Reset(gameplayStartTime: time);
GameplayClockContainer.StartTime = time;
GameplayClockContainer.Reset();
// Delay resetting frame-stable playback for one frame to give the FrameStabilityContainer a chance to seek.
frameStablePlaybackResetDelegate = ScheduleAfterChildren(() => DrawableRuleset.FrameStablePlayback = wasFrameStable);