2021-12-24 13:23:09 +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.
|
|
|
|
|
|
|
|
using System;
|
2022-04-21 21:55:13 +08:00
|
|
|
using osu.Framework.Allocation;
|
2021-12-24 13:23:09 +08:00
|
|
|
using osu.Framework.Screens;
|
2022-04-21 21:55:13 +08:00
|
|
|
using osu.Game.Online.Multiplayer;
|
2021-12-24 13:23:09 +08:00
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|
|
|
{
|
|
|
|
public class MultiplayerPlayerLoader : PlayerLoader
|
|
|
|
{
|
2022-01-26 00:45:11 +08:00
|
|
|
public bool GameplayPassed => player?.GameplayState.HasPassed == true;
|
2021-12-24 13:23:09 +08:00
|
|
|
|
2022-04-21 21:55:13 +08:00
|
|
|
[Resolved]
|
|
|
|
private MultiplayerClient multiplayerClient { get; set; }
|
|
|
|
|
2021-12-24 13:23:09 +08:00
|
|
|
private Player player;
|
|
|
|
|
|
|
|
public MultiplayerPlayerLoader(Func<Player> createPlayer)
|
|
|
|
: base(createPlayer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-04-21 21:55:13 +08:00
|
|
|
protected override bool ReadyForGameplay =>
|
|
|
|
base.ReadyForGameplay
|
|
|
|
// The server is forcefully starting gameplay.
|
|
|
|
|| multiplayerClient.LocalUser?.State == MultiplayerUserState.Playing;
|
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
public override void OnSuspending(ScreenTransitionEvent e)
|
2021-12-24 13:23:09 +08:00
|
|
|
{
|
2022-04-21 23:52:44 +08:00
|
|
|
base.OnSuspending(e);
|
|
|
|
player = (Player)e.Next;
|
2021-12-24 13:23:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|