2021-04-08 21:07:00 +08:00
|
|
|
// 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.
|
|
|
|
|
2021-04-14 19:39:14 +08:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
using osu.Game.Beatmaps;
|
2021-04-08 21:07:00 +08:00
|
|
|
using osu.Game.Scoring;
|
2021-04-15 18:32:55 +08:00
|
|
|
using osu.Game.Screens.OnlinePlay.Multiplayer.Spectate.Sync;
|
2021-04-08 21:07:00 +08:00
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|
|
|
{
|
|
|
|
public class MultiplayerSpectatorPlayer : SpectatorPlayer
|
|
|
|
{
|
2021-04-15 18:32:55 +08:00
|
|
|
private readonly SpectatorCatchUpSlaveClock gameplayClock;
|
2021-04-08 21:07:00 +08:00
|
|
|
|
2021-04-15 18:32:55 +08:00
|
|
|
public MultiplayerSpectatorPlayer(Score score, SpectatorCatchUpSlaveClock gameplayClock)
|
2021-04-08 21:07:00 +08:00
|
|
|
: base(score)
|
|
|
|
{
|
2021-04-14 19:39:14 +08:00
|
|
|
this.gameplayClock = gameplayClock;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
|
|
|
|
=> new SubGameplayClockContainer(gameplayClock);
|
|
|
|
}
|
|
|
|
|
|
|
|
public class SubGameplayClockContainer : GameplayClockContainer
|
|
|
|
{
|
|
|
|
public new DecoupleableInterpolatingFramedClock AdjustableClock => base.AdjustableClock;
|
|
|
|
|
|
|
|
public SubGameplayClockContainer(IClock sourceClock)
|
|
|
|
: base(sourceClock)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnIsPausedChanged(ValueChangedEvent<bool> isPaused)
|
|
|
|
{
|
|
|
|
if (isPaused.NewValue)
|
|
|
|
AdjustableClock.Stop();
|
|
|
|
else
|
|
|
|
AdjustableClock.Start();
|
2021-04-08 21:07:00 +08:00
|
|
|
}
|
2021-04-14 19:39:14 +08:00
|
|
|
|
|
|
|
protected override GameplayClock CreateGameplayClock(IFrameBasedClock source) => new GameplayClock(source);
|
2021-04-08 21:07:00 +08:00
|
|
|
}
|
|
|
|
}
|