* Add extendroundstart message to extend lobby start timer * Rename StartExtend to DelayStart * Fix delaystart amounts above 59 not working * Change delaystart seconds type from int to uint * Change delaystart wrong args amount message * Add forcegamepreset command * Rename forcegamepreset to forcepreset and merged start and forcestart preset methods * Fix index out of bounds exception when forcing suspicion to start * Change game preset to match regardless of casing * Add forcepreset unknown preset message * Add and move in lobby checks * Remove testing changes * Change delaystart to pause/resume the timer when no seconds are specified * Change pause message * Remove testing code * Change 0 seconds to not be a valid amount of seconds * Replace MsgTickerLobbyCountdown Seconds with DateTime instead of uint * Add one entire dot * Replace Math.Min + Math.Max with Math.Clamp Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com>
89 lines
3.0 KiB
C#
89 lines
3.0 KiB
C#
using System;
|
|
using Content.Client.Interfaces;
|
|
using Content.Client.State;
|
|
using Content.Client.UserInterface;
|
|
using Content.Shared;
|
|
using Robust.Client.Interfaces.State;
|
|
using Robust.Shared.Interfaces.Network;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Utility;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Content.Client.GameTicking
|
|
{
|
|
public class ClientGameTicker : SharedGameTicker, IClientGameTicker
|
|
{
|
|
#pragma warning disable 649
|
|
[Dependency] private IClientNetManager _netManager;
|
|
[Dependency] private IStateManager _stateManager;
|
|
#pragma warning restore 649
|
|
|
|
[ViewVariables] private bool _initialized;
|
|
|
|
[ViewVariables] public bool AreWeReady { get; private set; }
|
|
[ViewVariables] public bool IsGameStarted { get; private set; }
|
|
[ViewVariables] public string ServerInfoBlob { get; private set; }
|
|
[ViewVariables] public DateTime StartTime { get; private set; }
|
|
[ViewVariables] public bool Paused { get; private set; }
|
|
|
|
public event Action InfoBlobUpdated;
|
|
public event Action LobbyStatusUpdated;
|
|
|
|
public void Initialize()
|
|
{
|
|
DebugTools.Assert(!_initialized);
|
|
|
|
_netManager.RegisterNetMessage<MsgTickerJoinLobby>(nameof(MsgTickerJoinLobby), JoinLobby);
|
|
_netManager.RegisterNetMessage<MsgTickerJoinGame>(nameof(MsgTickerJoinGame), JoinGame);
|
|
_netManager.RegisterNetMessage<MsgTickerLobbyStatus>(nameof(MsgTickerLobbyStatus), LobbyStatus);
|
|
_netManager.RegisterNetMessage<MsgTickerLobbyInfo>(nameof(MsgTickerLobbyInfo), LobbyInfo);
|
|
_netManager.RegisterNetMessage<MsgTickerLobbyCountdown>(nameof(MsgTickerLobbyCountdown), LobbyCountdown);
|
|
_netManager.RegisterNetMessage<MsgRoundEndMessage>(nameof(MsgRoundEndMessage), RoundEnd);
|
|
|
|
_initialized = true;
|
|
}
|
|
|
|
|
|
|
|
private void JoinLobby(MsgTickerJoinLobby message)
|
|
{
|
|
_stateManager.RequestStateChange<LobbyState>();
|
|
}
|
|
|
|
private void LobbyStatus(MsgTickerLobbyStatus message)
|
|
{
|
|
StartTime = message.StartTime;
|
|
IsGameStarted = message.IsRoundStarted;
|
|
AreWeReady = message.YouAreReady;
|
|
|
|
LobbyStatusUpdated?.Invoke();
|
|
}
|
|
|
|
private void LobbyInfo(MsgTickerLobbyInfo message)
|
|
{
|
|
ServerInfoBlob = message.TextBlob;
|
|
|
|
InfoBlobUpdated?.Invoke();
|
|
}
|
|
|
|
private void JoinGame(MsgTickerJoinGame message)
|
|
{
|
|
_stateManager.RequestStateChange<GameScreen>();
|
|
}
|
|
|
|
private void LobbyCountdown(MsgTickerLobbyCountdown message)
|
|
{
|
|
StartTime = message.StartTime;
|
|
Paused = message.Paused;
|
|
}
|
|
|
|
private void RoundEnd(MsgRoundEndMessage message)
|
|
{
|
|
|
|
//This is not ideal at all, but I don't see an immediately better fit anywhere else.
|
|
var roundEnd = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundDuration, message.AllPlayersEndInfo);
|
|
|
|
}
|
|
}
|
|
}
|