Add delaystart and forcepreset commands (#1163)
* 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>
This commit is contained in:
@@ -24,6 +24,7 @@ namespace Content.Client.GameTicking
|
||||
[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;
|
||||
@@ -36,6 +37,7 @@ namespace Content.Client.GameTicking
|
||||
_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;
|
||||
@@ -69,6 +71,12 @@ namespace Content.Client.GameTicking
|
||||
_stateManager.RequestStateChange<GameScreen>();
|
||||
}
|
||||
|
||||
private void LobbyCountdown(MsgTickerLobbyCountdown message)
|
||||
{
|
||||
StartTime = message.StartTime;
|
||||
Paused = message.Paused;
|
||||
}
|
||||
|
||||
private void RoundEnd(MsgRoundEndMessage message)
|
||||
{
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Content.Client.Interfaces
|
||||
string ServerInfoBlob { get; }
|
||||
bool AreWeReady { get; }
|
||||
DateTime StartTime { get; }
|
||||
bool Paused { get; }
|
||||
|
||||
void Initialize();
|
||||
event Action InfoBlobUpdated;
|
||||
|
||||
@@ -123,21 +123,29 @@ namespace Content.Client.State
|
||||
}
|
||||
|
||||
string text;
|
||||
var difference = _clientGameTicker.StartTime - DateTime.UtcNow;
|
||||
if (difference.Ticks < 0)
|
||||
|
||||
if (_clientGameTicker.Paused)
|
||||
{
|
||||
if (difference.TotalSeconds < -5)
|
||||
{
|
||||
text = Loc.GetString("Right Now?");
|
||||
}
|
||||
else
|
||||
{
|
||||
text = Loc.GetString("Right Now");
|
||||
}
|
||||
text = Loc.GetString("Paused");
|
||||
}
|
||||
else
|
||||
{
|
||||
text = $"{(int) Math.Floor(difference.TotalMinutes)}:{difference.Seconds:D2}";
|
||||
var difference = _clientGameTicker.StartTime - DateTime.UtcNow;
|
||||
if (difference.Ticks < 0)
|
||||
{
|
||||
if (difference.TotalSeconds < -5)
|
||||
{
|
||||
text = Loc.GetString("Right Now?");
|
||||
}
|
||||
else
|
||||
{
|
||||
text = Loc.GetString("Right Now");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
text = $"{(int) Math.Floor(difference.TotalMinutes)}:{difference.Seconds:D2}";
|
||||
}
|
||||
}
|
||||
|
||||
_lobby.StartTime.Text = Loc.GetString("Round Starts In: {0}", text);
|
||||
|
||||
Reference in New Issue
Block a user