diff --git a/Content.Client/GameObjects/Components/Command/CommunicationsConsoleBoundUserInterface.cs b/Content.Client/GameObjects/Components/Command/CommunicationsConsoleBoundUserInterface.cs index 5401ac8537..9e90200515 100644 --- a/Content.Client/GameObjects/Components/Command/CommunicationsConsoleBoundUserInterface.cs +++ b/Content.Client/GameObjects/Components/Command/CommunicationsConsoleBoundUserInterface.cs @@ -3,6 +3,8 @@ using Content.Client.Command; using Content.Shared.GameObjects.Components.Command; using Robust.Client.GameObjects.Components.UserInterface; using Robust.Shared.GameObjects.Components.UserInterface; +using Robust.Shared.Interfaces.Timing; +using Robust.Shared.IoC; using Robust.Shared.ViewVariables; namespace Content.Client.GameObjects.Components.Command @@ -12,11 +14,13 @@ namespace Content.Client.GameObjects.Components.Command [ViewVariables] private CommunicationsConsoleMenu _menu; + [Dependency] private IGameTiming _gameTiming; + public bool CountdownStarted { get; private set; } public int Countdown => _expectedCountdownTime == null - ? 0 : Math.Max((int)(_expectedCountdownTime.Value.Subtract(DateTime.Now)).TotalSeconds, 0); - private DateTime? _expectedCountdownTime; + ? 0 : Math.Max((int)_expectedCountdownTime.Value.Subtract(_gameTiming.CurTime).TotalSeconds, 0); + private TimeSpan? _expectedCountdownTime; public CommunicationsConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { diff --git a/Content.Server/GameObjects/EntitySystems/RoundEndSystem.cs b/Content.Server/GameObjects/EntitySystems/RoundEndSystem.cs index e1b75529c6..62dfc01069 100644 --- a/Content.Server/GameObjects/EntitySystems/RoundEndSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/RoundEndSystem.cs @@ -2,6 +2,7 @@ using System; using System.Threading; using Content.Server.Interfaces.GameTicking; using Robust.Shared.GameObjects.Systems; +using Robust.Shared.Interfaces.Timing; using Robust.Shared.IoC; using Timer = Robust.Shared.Timers.Timer; @@ -11,12 +12,13 @@ namespace Content.Server.GameObjects.EntitySystems { #pragma warning disable 649 [Dependency] private IGameTicker _gameTicker; + [Dependency] private IGameTiming _gameTiming; #pragma warning restore 649 private CancellationTokenSource _roundEndCancellationTokenSource = new CancellationTokenSource(); public bool IsRoundEndCountdownStarted { get; private set; } public int RoundEndCountdownTime { get; set; } = 5000; - public DateTime? ExpectedCountdownEnd = null; + public TimeSpan? ExpectedCountdownEnd = null; public delegate void RoundEndCountdownStarted(); public event RoundEndCountdownStarted OnRoundEndCountdownStarted; @@ -34,7 +36,7 @@ namespace Content.Server.GameObjects.EntitySystems IsRoundEndCountdownStarted = true; - ExpectedCountdownEnd = DateTime.Now.AddMilliseconds(RoundEndCountdownTime); + ExpectedCountdownEnd = _gameTiming.CurTime.Add(new TimeSpan(0,0,0,0,RoundEndCountdownTime)); Timer.Spawn(RoundEndCountdownTime, EndRound, _roundEndCancellationTokenSource.Token); OnRoundEndCountdownStarted?.Invoke(); } diff --git a/Content.Shared/GameObjects/Components/Command/SharedCommunicationsConsoleComponent.cs b/Content.Shared/GameObjects/Components/Command/SharedCommunicationsConsoleComponent.cs index 00d73272b1..88fb0168fc 100644 --- a/Content.Shared/GameObjects/Components/Command/SharedCommunicationsConsoleComponent.cs +++ b/Content.Shared/GameObjects/Components/Command/SharedCommunicationsConsoleComponent.cs @@ -14,10 +14,10 @@ namespace Content.Shared.GameObjects.Components.Command [Serializable, NetSerializable] public class CommunicationsConsoleInterfaceState : BoundUserInterfaceState { - public readonly DateTime? ExpectedCountdownEnd; + public readonly TimeSpan? ExpectedCountdownEnd; public readonly bool CountdownStarted; - public CommunicationsConsoleInterfaceState(DateTime? expectedCountdownEnd = null) + public CommunicationsConsoleInterfaceState(TimeSpan? expectedCountdownEnd = null) { ExpectedCountdownEnd = expectedCountdownEnd; CountdownStarted = expectedCountdownEnd != null;