Remove ISyncManager interface

Too many levels of redirection.

One interface with one implementation is not useful, IMO.
This commit is contained in:
Dean Herbert 2022-08-24 15:01:57 +09:00
parent 22963ab951
commit 882dd93942
4 changed files with 18 additions and 46 deletions

View File

@ -11,9 +11,9 @@ using osu.Game.Screens.Play;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{
/// <summary>
/// A <see cref="ISyncManager"/> which synchronises de-synced player clocks through catchup.
/// Manages the synchronisation between one or more <see cref="ISpectatorPlayerClock"/>s in relation to a master clock.
/// </summary>
public class CatchUpSyncManager : Component, ISyncManager
public class CatchUpSyncManager : Component
{
/// <summary>
/// The offset from the master clock to which player clocks should remain within to be considered in-sync.
@ -30,6 +30,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// </summary>
public const double MAXIMUM_START_DELAY = 15000;
/// <summary>
/// An event which is invoked when gameplay is ready to start.
/// </summary>
public event Action? ReadyToStart;
/// <summary>
@ -37,6 +40,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// </summary>
public GameplayClockContainer MasterClock { get; }
/// <summary>
/// The catch-up state of the master clock.
/// </summary>
public IBindable<MasterClockState> MasterState => masterState;
/// <summary>
@ -54,6 +60,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
MasterClock = master;
}
/// <summary>
/// Create a new managed <see cref="ISpectatorPlayerClock"/>.
/// </summary>
/// <returns>The newly created <see cref="ISpectatorPlayerClock"/>.</returns>
public ISpectatorPlayerClock CreateManagedClock()
{
var clock = new CatchUpSpectatorPlayerClock(MasterClock);
@ -61,6 +71,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
return clock;
}
/// <summary>
/// Removes an <see cref="ISpectatorPlayerClock"/>, stopping it from being managed by this <see cref="CatchUpSyncManager"/>.
/// </summary>
/// <param name="clock">The <see cref="ISpectatorPlayerClock"/> to remove.</param>
public void RemoveManagedClock(ISpectatorPlayerClock clock)
{
playerClocks.Remove(clock);

View File

@ -7,7 +7,7 @@ using osu.Framework.Timing;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{
/// <summary>
/// A clock which is used by <see cref="MultiSpectatorPlayer"/>s and managed by an <see cref="ISyncManager"/>.
/// A clock which is used by <see cref="MultiSpectatorPlayer"/>s and managed by an <see cref="CatchUpSyncManager"/>.
/// </summary>
public interface ISpectatorPlayerClock : IFrameBasedClock, IAdjustableClock
{

View File

@ -1,42 +0,0 @@
// 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.
using System;
using osu.Framework.Bindables;
using osu.Game.Screens.Play;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
{
/// <summary>
/// Manages the synchronisation between one or more <see cref="ISpectatorPlayerClock"/>s in relation to a master clock.
/// </summary>
public interface ISyncManager
{
/// <summary>
/// An event which is invoked when gameplay is ready to start.
/// </summary>
event Action? ReadyToStart;
/// <summary>
/// The master clock which player clocks should synchronise to.
/// </summary>
GameplayClockContainer MasterClock { get; }
/// <summary>
/// An event which is invoked when the state of <see cref="MasterClock"/> is changed.
/// </summary>
IBindable<MasterClockState> MasterState { get; }
/// <summary>
/// Create a new managed <see cref="ISpectatorPlayerClock"/>.
/// </summary>
/// <returns>The newly created <see cref="ISpectatorPlayerClock"/>.</returns>
ISpectatorPlayerClock CreateManagedClock();
/// <summary>
/// Removes an <see cref="ISpectatorPlayerClock"/>, stopping it from being managed by this <see cref="ISyncManager"/>.
/// </summary>
/// <param name="clock">The <see cref="ISpectatorPlayerClock"/> to remove.</param>
void RemoveManagedClock(ISpectatorPlayerClock clock);
}
}

View File

@ -48,7 +48,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
private readonly PlayerArea[] instances;
private MasterGameplayClockContainer masterClockContainer = null!;
private ISyncManager syncManager = null!;
private CatchUpSyncManager syncManager = null!;
private PlayerGrid grid = null!;
private MultiSpectatorLeaderboard leaderboard = null!;
private PlayerArea? currentAudioSource;