Don't expose MasterClock in SpectatorClockSyncManager

This commit is contained in:
Dean Herbert 2022-08-24 15:09:00 +09:00
parent 995e6664b6
commit 0c9a4ec13c
2 changed files with 11 additions and 9 deletions

View File

@ -169,7 +169,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
if (!isCandidateAudioSource(currentAudioSource?.GameplayClock)) if (!isCandidateAudioSource(currentAudioSource?.GameplayClock))
{ {
currentAudioSource = instances.Where(i => isCandidateAudioSource(i.GameplayClock)) currentAudioSource = instances.Where(i => isCandidateAudioSource(i.GameplayClock))
.OrderBy(i => Math.Abs(i.GameplayClock.CurrentTime - syncManager.MasterClock.CurrentTime)) .OrderBy(i => Math.Abs(i.GameplayClock.CurrentTime - syncManager.CurrentMasterTime))
.FirstOrDefault(); .FirstOrDefault();
foreach (var instance in instances) foreach (var instance in instances)

View File

@ -35,16 +35,18 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// </summary> /// </summary>
public event Action? ReadyToStart; public event Action? ReadyToStart;
/// <summary>
/// The master clock which is used to control the timing of all player clocks clocks.
/// </summary>
public GameplayClockContainer MasterClock { get; }
/// <summary> /// <summary>
/// The catch-up state of the master clock. /// The catch-up state of the master clock.
/// </summary> /// </summary>
public IBindable<MasterClockState> MasterState => masterState; public IBindable<MasterClockState> MasterState => masterState;
public double CurrentMasterTime => masterClock.CurrentTime;
/// <summary>
/// The master clock which is used to control the timing of all player clocks clocks.
/// </summary>
private GameplayClockContainer masterClock { get; }
/// <summary> /// <summary>
/// The player clocks. /// The player clocks.
/// </summary> /// </summary>
@ -57,7 +59,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
public SpectatorSyncManager(GameplayClockContainer master) public SpectatorSyncManager(GameplayClockContainer master)
{ {
MasterClock = master; masterClock = master;
} }
/// <summary> /// <summary>
@ -66,7 +68,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// <returns>The newly created <see cref="SpectatorPlayerClock"/>.</returns> /// <returns>The newly created <see cref="SpectatorPlayerClock"/>.</returns>
public SpectatorPlayerClock CreateManagedClock() public SpectatorPlayerClock CreateManagedClock()
{ {
var clock = new SpectatorPlayerClock(MasterClock); var clock = new SpectatorPlayerClock(masterClock);
playerClocks.Add(clock); playerClocks.Add(clock);
return clock; return clock;
} }
@ -142,7 +144,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
// How far this player's clock is out of sync, compared to the master clock. // How far this player's clock is out of sync, compared to the master clock.
// A negative value means the player is running fast (ahead); a positive value means the player is running behind (catching up). // A negative value means the player is running fast (ahead); a positive value means the player is running behind (catching up).
double timeDelta = MasterClock.CurrentTime - clock.CurrentTime; double timeDelta = masterClock.CurrentTime - clock.CurrentTime;
// Check that the player clock isn't too far ahead. // Check that the player clock isn't too far ahead.
// This is a quiet case in which the catchup is done by the master clock, so IsCatchingUp is not set on the player clock. // This is a quiet case in which the catchup is done by the master clock, so IsCatchingUp is not set on the player clock.