Allow game presets to disallow latejoining (#1816)

* Allow game presets to disallow latejoining

* Update Content.Server/GameTicking/GameTicker.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
Víctor Aguilera Puerto
2020-08-20 16:20:48 +02:00
committed by GitHub
parent 2bdf359289
commit 944ce2cc92
7 changed files with 68 additions and 2 deletions

View File

@@ -26,6 +26,7 @@ namespace Content.Client.GameTicking
[ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] public bool DisallowedLateJoin { get; private set; }
[ViewVariables] public string ServerInfoBlob { get; private set; }
[ViewVariables] public DateTime StartTime { get; private set; }
[ViewVariables] public bool Paused { get; private set; }
@@ -34,6 +35,7 @@ namespace Content.Client.GameTicking
public event Action InfoBlobUpdated;
public event Action LobbyStatusUpdated;
public event Action LobbyReadyUpdated;
public event Action LobbyLateJoinStatusUpdated;
public void Initialize()
{
@@ -50,11 +52,17 @@ namespace Content.Client.GameTicking
{
IoCManager.Resolve<IClyde>().RequestWindowAttention();
});
_netManager.RegisterNetMessage<MsgTickerLateJoinStatus>(nameof(MsgTickerLateJoinStatus), LateJoinStatus);
Ready = new Dictionary<NetSessionId, bool>();
_initialized = true;
}
private void LateJoinStatus(MsgTickerLateJoinStatus message)
{
DisallowedLateJoin = message.Disallowed;
LobbyLateJoinStatusUpdated?.Invoke();
}
private void JoinLobby(MsgTickerJoinLobby message)

View File

@@ -9,6 +9,7 @@ namespace Content.Client.Interfaces
bool IsGameStarted { get; }
string ServerInfoBlob { get; }
bool AreWeReady { get; }
bool DisallowedLateJoin { get; }
DateTime StartTime { get; }
bool Paused { get; }
Dictionary<NetSessionId, bool> Ready { get; }
@@ -17,5 +18,6 @@ namespace Content.Client.Interfaces
event Action InfoBlobUpdated;
event Action LobbyStatusUpdated;
event Action LobbyReadyUpdated;
event Action LobbyLateJoinStatusUpdated;
}
}

View File

@@ -101,6 +101,7 @@ namespace Content.Client.State
_clientGameTicker.InfoBlobUpdated += UpdateLobbyUi;
_clientGameTicker.LobbyStatusUpdated += LobbyStatusUpdated;
_clientGameTicker.LobbyReadyUpdated += LobbyReadyUpdated;
_clientGameTicker.LobbyLateJoinStatusUpdated += LobbyLateJoinStatusUpdated;
}
public override void Shutdown()
@@ -109,6 +110,7 @@ namespace Content.Client.State
_clientGameTicker.InfoBlobUpdated -= UpdateLobbyUi;
_clientGameTicker.LobbyStatusUpdated -= LobbyStatusUpdated;
_clientGameTicker.LobbyReadyUpdated -= LobbyReadyUpdated;
_clientGameTicker.LobbyLateJoinStatusUpdated -= LobbyLateJoinStatusUpdated;
_clientGameTicker.Ready.Clear();
@@ -173,6 +175,11 @@ namespace Content.Client.State
UpdateLobbyUi();
}
private void LobbyLateJoinStatusUpdated()
{
_lobby.ReadyButton.Disabled = _clientGameTicker.DisallowedLateJoin;
}
private void UpdateLobbyUi()
{
if (_lobby == null)
@@ -191,6 +198,7 @@ namespace Content.Client.State
_lobby.StartTime.Text = "";
_lobby.ReadyButton.Text = Loc.GetString("Ready Up");
_lobby.ReadyButton.ToggleMode = true;
_lobby.ReadyButton.Disabled = false;
_lobby.ReadyButton.Pressed = _clientGameTicker.AreWeReady;
}