@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using Content.Client.Interfaces;
|
using Content.Client.Interfaces;
|
||||||
using Content.Client.State;
|
using Content.Client.State;
|
||||||
using Content.Client.UserInterface;
|
using Content.Client.UserInterface;
|
||||||
using Content.Shared;
|
|
||||||
using Content.Shared.GameTicking;
|
using Content.Shared.GameTicking;
|
||||||
using Content.Shared.Network.NetMessages;
|
using Content.Shared.Network.NetMessages;
|
||||||
using Robust.Client.Interfaces.Graphics;
|
using Robust.Client.Interfaces.Graphics;
|
||||||
@@ -11,6 +10,7 @@ using Robust.Client.Interfaces.State;
|
|||||||
using Robust.Shared.Interfaces.Network;
|
using Robust.Shared.Interfaces.Network;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ namespace Content.Client.GameTicking
|
|||||||
[ViewVariables] public bool IsGameStarted { get; private set; }
|
[ViewVariables] public bool IsGameStarted { get; private set; }
|
||||||
[ViewVariables] public bool DisallowedLateJoin { get; private set; }
|
[ViewVariables] public bool DisallowedLateJoin { get; private set; }
|
||||||
[ViewVariables] public string ServerInfoBlob { get; private set; }
|
[ViewVariables] public string ServerInfoBlob { get; private set; }
|
||||||
[ViewVariables] public DateTime StartTime { get; private set; }
|
[ViewVariables] public TimeSpan StartTime { get; private set; }
|
||||||
[ViewVariables] public bool Paused { get; private set; }
|
[ViewVariables] public bool Paused { get; private set; }
|
||||||
[ViewVariables] public Dictionary<NetUserId, PlayerStatus> Status { get; private set; }
|
[ViewVariables] public Dictionary<NetUserId, PlayerStatus> Status { get; private set; }
|
||||||
[ViewVariables] public IReadOnlyList<string> JobsAvailable => _jobsAvailable;
|
[ViewVariables] public IReadOnlyList<string> JobsAvailable => _jobsAvailable;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
using static Content.Shared.GameTicking.SharedGameTicker;
|
using static Content.Shared.GameTicking.SharedGameTicker;
|
||||||
|
|
||||||
namespace Content.Client.Interfaces
|
namespace Content.Client.Interfaces
|
||||||
@@ -11,7 +12,7 @@ namespace Content.Client.Interfaces
|
|||||||
string ServerInfoBlob { get; }
|
string ServerInfoBlob { get; }
|
||||||
bool AreWeReady { get; }
|
bool AreWeReady { get; }
|
||||||
bool DisallowedLateJoin { get; }
|
bool DisallowedLateJoin { get; }
|
||||||
DateTime StartTime { get; }
|
TimeSpan StartTime { get; }
|
||||||
bool Paused { get; }
|
bool Paused { get; }
|
||||||
Dictionary<NetUserId, PlayerStatus> Status { get; }
|
Dictionary<NetUserId, PlayerStatus> Status { get; }
|
||||||
IReadOnlyList<string> JobsAvailable { get; }
|
IReadOnlyList<string> JobsAvailable { get; }
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using Robust.Client.Player;
|
|||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Shared.Input.Binding;
|
using Robust.Shared.Input.Binding;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.Timing;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -35,6 +36,7 @@ namespace Content.Client.State
|
|||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
||||||
[Dependency] private readonly IClientPreferencesManager _preferencesManager = default!;
|
[Dependency] private readonly IClientPreferencesManager _preferencesManager = default!;
|
||||||
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
|
||||||
[ViewVariables] private CharacterSetupGui _characterSetup;
|
[ViewVariables] private CharacterSetupGui _characterSetup;
|
||||||
[ViewVariables] private LobbyGui _lobby;
|
[ViewVariables] private LobbyGui _lobby;
|
||||||
@@ -144,10 +146,11 @@ namespace Content.Client.State
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var difference = _clientGameTicker.StartTime - DateTime.UtcNow;
|
var difference = _clientGameTicker.StartTime - _gameTiming.CurTime;
|
||||||
if (difference.Ticks < 0)
|
var seconds = difference.TotalSeconds;
|
||||||
|
if (seconds < 0)
|
||||||
{
|
{
|
||||||
if (difference.TotalSeconds < -5)
|
if (seconds < -5)
|
||||||
{
|
{
|
||||||
text = Loc.GetString("Right Now?");
|
text = Loc.GetString("Right Now?");
|
||||||
}
|
}
|
||||||
@@ -158,7 +161,7 @@ namespace Content.Client.State
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
text = $"{(int) Math.Floor(difference.TotalMinutes)}:{difference.Seconds:D2}";
|
text = $"{(int) Math.Floor(difference.TotalMinutes / 60)}:{difference.Seconds:D2}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,8 +181,10 @@ namespace Content.Client.State
|
|||||||
_clientGameTicker.Status.Remove(p.Key);
|
_clientGameTicker.Status.Remove(p.Key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdatePlayerList();
|
UpdatePlayerList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LobbyReadyUpdated() => UpdatePlayerList();
|
private void LobbyReadyUpdated() => UpdatePlayerList();
|
||||||
|
|
||||||
private void LobbyStatusUpdated()
|
private void LobbyStatusUpdated()
|
||||||
@@ -224,8 +229,6 @@ namespace Content.Client.State
|
|||||||
|
|
||||||
foreach (var session in _playerManager.Sessions.OrderBy(s => s.Name))
|
foreach (var session in _playerManager.Sessions.OrderBy(s => s.Name))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var readyState = "";
|
var readyState = "";
|
||||||
// Don't show ready state if we're ingame
|
// Don't show ready state if we're ingame
|
||||||
if (!_clientGameTicker.IsGameStarted)
|
if (!_clientGameTicker.IsGameStarted)
|
||||||
@@ -244,6 +247,7 @@ namespace Content.Client.State
|
|||||||
_ => "",
|
_ => "",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
_lobby.OnlinePlayerList.AddItem(session.Name, readyState);
|
_lobby.OnlinePlayerList.AddItem(session.Name, readyState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Content.Server.Administration;
|
|
||||||
using Content.Server.Commands.Observer;
|
|
||||||
using Content.Server.GameObjects.Components.Access;
|
using Content.Server.GameObjects.Components.Access;
|
||||||
using Content.Server.GameObjects.Components.GUI;
|
using Content.Server.GameObjects.Components.GUI;
|
||||||
using Content.Server.GameObjects.Components.Items.Storage;
|
using Content.Server.GameObjects.Components.Items.Storage;
|
||||||
@@ -32,7 +30,6 @@ using Robust.Server.Interfaces.Maps;
|
|||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Server.ServerStatus;
|
using Robust.Server.ServerStatus;
|
||||||
using Robust.Server.Interfaces.Console;
|
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Interfaces.Configuration;
|
using Robust.Shared.Interfaces.Configuration;
|
||||||
@@ -71,7 +68,7 @@ namespace Content.Server.GameTicking
|
|||||||
public const float PresetFailedCooldownIncrease = 30f;
|
public const float PresetFailedCooldownIncrease = 30f;
|
||||||
private const string PlayerPrototypeName = "HumanMob_Content";
|
private const string PlayerPrototypeName = "HumanMob_Content";
|
||||||
private const string ObserverPrototypeName = "MobObserver";
|
private const string ObserverPrototypeName = "MobObserver";
|
||||||
private static TimeSpan _roundStartTimeSpan;
|
private TimeSpan _roundStartTimeSpan;
|
||||||
|
|
||||||
[ViewVariables] private readonly List<GameRule> _gameRules = new();
|
[ViewVariables] private readonly List<GameRule> _gameRules = new();
|
||||||
[ViewVariables] private readonly List<ManifestEntry> _manifest = new();
|
[ViewVariables] private readonly List<ManifestEntry> _manifest = new();
|
||||||
@@ -83,9 +80,9 @@ namespace Content.Server.GameTicking
|
|||||||
|
|
||||||
[ViewVariables] private Type _presetType;
|
[ViewVariables] private Type _presetType;
|
||||||
|
|
||||||
[ViewVariables] private DateTime _pauseTime;
|
[ViewVariables] private TimeSpan _pauseTime;
|
||||||
[ViewVariables] private bool _roundStartCountdownHasNotStartedYetDueToNoPlayers;
|
[ViewVariables] private bool _roundStartCountdownHasNotStartedYetDueToNoPlayers;
|
||||||
private DateTime _roundStartTimeUtc;
|
[ViewVariables] private TimeSpan _roundStartTime;
|
||||||
[ViewVariables] private GameRunLevel _runLevel;
|
[ViewVariables] private GameRunLevel _runLevel;
|
||||||
[ViewVariables(VVAccess.ReadWrite)] private EntityCoordinates _spawnPoint;
|
[ViewVariables(VVAccess.ReadWrite)] private EntityCoordinates _spawnPoint;
|
||||||
|
|
||||||
@@ -178,7 +175,7 @@ namespace Content.Server.GameTicking
|
|||||||
|
|
||||||
if (RunLevel != GameRunLevel.PreRoundLobby ||
|
if (RunLevel != GameRunLevel.PreRoundLobby ||
|
||||||
Paused ||
|
Paused ||
|
||||||
_roundStartTimeUtc > DateTime.UtcNow ||
|
_roundStartTime > _gameTiming.CurTime ||
|
||||||
_roundStartCountdownHasNotStartedYetDueToNoPlayers)
|
_roundStartCountdownHasNotStartedYetDueToNoPlayers)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -217,7 +214,7 @@ namespace Content.Server.GameTicking
|
|||||||
if (PlayerManager.PlayerCount == 0)
|
if (PlayerManager.PlayerCount == 0)
|
||||||
_roundStartCountdownHasNotStartedYetDueToNoPlayers = true;
|
_roundStartCountdownHasNotStartedYetDueToNoPlayers = true;
|
||||||
else
|
else
|
||||||
_roundStartTimeUtc = DateTime.UtcNow + LobbyDuration;
|
_roundStartTime = _gameTiming.CurTime + LobbyDuration;
|
||||||
|
|
||||||
_sendStatusToAll();
|
_sendStatusToAll();
|
||||||
|
|
||||||
@@ -532,10 +529,10 @@ namespace Content.Server.GameTicking
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_roundStartTimeUtc += time;
|
_roundStartTime += time;
|
||||||
|
|
||||||
var lobbyCountdownMessage = _netManager.CreateNetMessage<MsgTickerLobbyCountdown>();
|
var lobbyCountdownMessage = _netManager.CreateNetMessage<MsgTickerLobbyCountdown>();
|
||||||
lobbyCountdownMessage.StartTime = _roundStartTimeUtc;
|
lobbyCountdownMessage.StartTime = _roundStartTime;
|
||||||
lobbyCountdownMessage.Paused = Paused;
|
lobbyCountdownMessage.Paused = Paused;
|
||||||
_netManager.ServerSendToAll(lobbyCountdownMessage);
|
_netManager.ServerSendToAll(lobbyCountdownMessage);
|
||||||
|
|
||||||
@@ -555,15 +552,15 @@ namespace Content.Server.GameTicking
|
|||||||
|
|
||||||
if (pause)
|
if (pause)
|
||||||
{
|
{
|
||||||
_pauseTime = DateTime.UtcNow;
|
_pauseTime = _gameTiming.CurTime;
|
||||||
}
|
}
|
||||||
else if (_pauseTime != default)
|
else if (_pauseTime != default)
|
||||||
{
|
{
|
||||||
_roundStartTimeUtc += DateTime.UtcNow - _pauseTime;
|
_roundStartTime += _gameTiming.CurTime - _pauseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lobbyCountdownMessage = _netManager.CreateNetMessage<MsgTickerLobbyCountdown>();
|
var lobbyCountdownMessage = _netManager.CreateNetMessage<MsgTickerLobbyCountdown>();
|
||||||
lobbyCountdownMessage.StartTime = _roundStartTimeUtc;
|
lobbyCountdownMessage.StartTime = _roundStartTime;
|
||||||
lobbyCountdownMessage.Paused = Paused;
|
lobbyCountdownMessage.Paused = Paused;
|
||||||
_netManager.ServerSendToAll(lobbyCountdownMessage);
|
_netManager.ServerSendToAll(lobbyCountdownMessage);
|
||||||
|
|
||||||
@@ -766,7 +763,7 @@ namespace Content.Server.GameTicking
|
|||||||
if (LobbyEnabled && _roundStartCountdownHasNotStartedYetDueToNoPlayers)
|
if (LobbyEnabled && _roundStartCountdownHasNotStartedYetDueToNoPlayers)
|
||||||
{
|
{
|
||||||
_roundStartCountdownHasNotStartedYetDueToNoPlayers = false;
|
_roundStartCountdownHasNotStartedYetDueToNoPlayers = false;
|
||||||
_roundStartTimeUtc = DateTime.UtcNow + LobbyDuration;
|
_roundStartTime = _gameTiming.CurTime + LobbyDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -1020,7 +1017,7 @@ namespace Content.Server.GameTicking
|
|||||||
_playersInLobby.TryGetValue(session, out var status);
|
_playersInLobby.TryGetValue(session, out var status);
|
||||||
var msg = _netManager.CreateNetMessage<MsgTickerLobbyStatus>();
|
var msg = _netManager.CreateNetMessage<MsgTickerLobbyStatus>();
|
||||||
msg.IsRoundStarted = RunLevel != GameRunLevel.PreRoundLobby;
|
msg.IsRoundStarted = RunLevel != GameRunLevel.PreRoundLobby;
|
||||||
msg.StartTime = _roundStartTimeUtc;
|
msg.StartTime = _roundStartTime;
|
||||||
msg.YouAreReady = status == PlayerStatus.Ready;
|
msg.YouAreReady = status == PlayerStatus.Ready;
|
||||||
msg.Paused = Paused;
|
msg.Paused = Paused;
|
||||||
return msg;
|
return msg;
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace Content.Shared.GameTicking
|
|||||||
public bool IsRoundStarted { get; set; }
|
public bool IsRoundStarted { get; set; }
|
||||||
public bool YouAreReady { get; set; }
|
public bool YouAreReady { get; set; }
|
||||||
// UTC.
|
// UTC.
|
||||||
public DateTime StartTime { get; set; }
|
public TimeSpan StartTime { get; set; }
|
||||||
public bool Paused { get; set; }
|
public bool Paused { get; set; }
|
||||||
|
|
||||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||||
@@ -105,7 +105,7 @@ namespace Content.Shared.GameTicking
|
|||||||
}
|
}
|
||||||
|
|
||||||
YouAreReady = buffer.ReadBoolean();
|
YouAreReady = buffer.ReadBoolean();
|
||||||
StartTime = new DateTime(buffer.ReadInt64(), DateTimeKind.Utc);
|
StartTime = new TimeSpan(buffer.ReadInt64());
|
||||||
Paused = buffer.ReadBoolean();
|
Paused = buffer.ReadBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,9 +158,9 @@ namespace Content.Shared.GameTicking
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The total amount of seconds to go until the countdown finishes
|
/// The game time that the game will start at.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime StartTime { get; set; }
|
public TimeSpan StartTime { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not the countdown is paused
|
/// Whether or not the countdown is paused
|
||||||
@@ -169,7 +169,7 @@ namespace Content.Shared.GameTicking
|
|||||||
|
|
||||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||||
{
|
{
|
||||||
StartTime = new DateTime(buffer.ReadInt64(), DateTimeKind.Utc);
|
StartTime = new TimeSpan(buffer.ReadInt64());
|
||||||
Paused = buffer.ReadBoolean();
|
Paused = buffer.ReadBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user