Use TimeSpan instead of DateTime in RoundEnd and Comms Console.
This commit is contained in:
@@ -3,6 +3,8 @@ using Content.Client.Command;
|
|||||||
using Content.Shared.GameObjects.Components.Command;
|
using Content.Shared.GameObjects.Components.Command;
|
||||||
using Robust.Client.GameObjects.Components.UserInterface;
|
using Robust.Client.GameObjects.Components.UserInterface;
|
||||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||||
|
using Robust.Shared.Interfaces.Timing;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components.Command
|
namespace Content.Client.GameObjects.Components.Command
|
||||||
@@ -12,11 +14,13 @@ namespace Content.Client.GameObjects.Components.Command
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private CommunicationsConsoleMenu _menu;
|
private CommunicationsConsoleMenu _menu;
|
||||||
|
|
||||||
|
[Dependency] private IGameTiming _gameTiming;
|
||||||
|
|
||||||
public bool CountdownStarted { get; private set; }
|
public bool CountdownStarted { get; private set; }
|
||||||
|
|
||||||
public int Countdown => _expectedCountdownTime == null
|
public int Countdown => _expectedCountdownTime == null
|
||||||
? 0 : Math.Max((int)(_expectedCountdownTime.Value.Subtract(DateTime.Now)).TotalSeconds, 0);
|
? 0 : Math.Max((int)_expectedCountdownTime.Value.Subtract(_gameTiming.CurTime).TotalSeconds, 0);
|
||||||
private DateTime? _expectedCountdownTime;
|
private TimeSpan? _expectedCountdownTime;
|
||||||
|
|
||||||
public CommunicationsConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
public CommunicationsConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Content.Server.Interfaces.GameTicking;
|
using Content.Server.Interfaces.GameTicking;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
using Robust.Shared.Interfaces.Timing;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Timer = Robust.Shared.Timers.Timer;
|
using Timer = Robust.Shared.Timers.Timer;
|
||||||
|
|
||||||
@@ -11,12 +12,13 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
{
|
{
|
||||||
#pragma warning disable 649
|
#pragma warning disable 649
|
||||||
[Dependency] private IGameTicker _gameTicker;
|
[Dependency] private IGameTicker _gameTicker;
|
||||||
|
[Dependency] private IGameTiming _gameTiming;
|
||||||
#pragma warning restore 649
|
#pragma warning restore 649
|
||||||
|
|
||||||
private CancellationTokenSource _roundEndCancellationTokenSource = new CancellationTokenSource();
|
private CancellationTokenSource _roundEndCancellationTokenSource = new CancellationTokenSource();
|
||||||
public bool IsRoundEndCountdownStarted { get; private set; }
|
public bool IsRoundEndCountdownStarted { get; private set; }
|
||||||
public int RoundEndCountdownTime { get; set; } = 5000;
|
public int RoundEndCountdownTime { get; set; } = 5000;
|
||||||
public DateTime? ExpectedCountdownEnd = null;
|
public TimeSpan? ExpectedCountdownEnd = null;
|
||||||
|
|
||||||
public delegate void RoundEndCountdownStarted();
|
public delegate void RoundEndCountdownStarted();
|
||||||
public event RoundEndCountdownStarted OnRoundEndCountdownStarted;
|
public event RoundEndCountdownStarted OnRoundEndCountdownStarted;
|
||||||
@@ -34,7 +36,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
|
|
||||||
IsRoundEndCountdownStarted = true;
|
IsRoundEndCountdownStarted = true;
|
||||||
|
|
||||||
ExpectedCountdownEnd = DateTime.Now.AddMilliseconds(RoundEndCountdownTime);
|
ExpectedCountdownEnd = _gameTiming.CurTime.Add(new TimeSpan(0,0,0,0,RoundEndCountdownTime));
|
||||||
Timer.Spawn(RoundEndCountdownTime, EndRound, _roundEndCancellationTokenSource.Token);
|
Timer.Spawn(RoundEndCountdownTime, EndRound, _roundEndCancellationTokenSource.Token);
|
||||||
OnRoundEndCountdownStarted?.Invoke();
|
OnRoundEndCountdownStarted?.Invoke();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ namespace Content.Shared.GameObjects.Components.Command
|
|||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public class CommunicationsConsoleInterfaceState : BoundUserInterfaceState
|
public class CommunicationsConsoleInterfaceState : BoundUserInterfaceState
|
||||||
{
|
{
|
||||||
public readonly DateTime? ExpectedCountdownEnd;
|
public readonly TimeSpan? ExpectedCountdownEnd;
|
||||||
public readonly bool CountdownStarted;
|
public readonly bool CountdownStarted;
|
||||||
|
|
||||||
public CommunicationsConsoleInterfaceState(DateTime? expectedCountdownEnd = null)
|
public CommunicationsConsoleInterfaceState(TimeSpan? expectedCountdownEnd = null)
|
||||||
{
|
{
|
||||||
ExpectedCountdownEnd = expectedCountdownEnd;
|
ExpectedCountdownEnd = expectedCountdownEnd;
|
||||||
CountdownStarted = expectedCountdownEnd != null;
|
CountdownStarted = expectedCountdownEnd != null;
|
||||||
|
|||||||
Reference in New Issue
Block a user