Make RoundEndSystem properly reset & CommunicationsConsoleComponent less crashy (#2629)
This commit is contained in:
@@ -42,9 +42,18 @@ namespace Content.Server.GameObjects.Components.Command
|
|||||||
|
|
||||||
private void UpdateBoundInterface()
|
private void UpdateBoundInterface()
|
||||||
{
|
{
|
||||||
|
if (!Deleted)
|
||||||
UserInterface?.SetState(new CommunicationsConsoleInterfaceState(RoundEndSystem.ExpectedCountdownEnd));
|
UserInterface?.SetState(new CommunicationsConsoleInterfaceState(RoundEndSystem.ExpectedCountdownEnd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnRemove()
|
||||||
|
{
|
||||||
|
RoundEndSystem.OnRoundEndCountdownStarted -= UpdateBoundInterface;
|
||||||
|
RoundEndSystem.OnRoundEndCountdownCancelled -= UpdateBoundInterface;
|
||||||
|
RoundEndSystem.OnRoundEndCountdownFinished -= UpdateBoundInterface;
|
||||||
|
base.OnRemove();
|
||||||
|
}
|
||||||
|
|
||||||
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage obj)
|
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage obj)
|
||||||
{
|
{
|
||||||
switch (obj.Message)
|
switch (obj.Message)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Content.Server.Interfaces.Chat;
|
using Content.Server.Interfaces.Chat;
|
||||||
using Content.Server.Interfaces.GameTicking;
|
using Content.Server.Interfaces.GameTicking;
|
||||||
|
using Content.Shared.GameTicking;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.Interfaces.Timing;
|
using Robust.Shared.Interfaces.Timing;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
@@ -10,7 +11,7 @@ using Timer = Robust.Shared.Timers.Timer;
|
|||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
{
|
{
|
||||||
public class RoundEndSystem : EntitySystem
|
public class RoundEndSystem : EntitySystem, IResettingEntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTicker _gameTicker = default!;
|
[Dependency] private readonly IGameTicker _gameTicker = default!;
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
@@ -32,6 +33,14 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
public delegate void RoundEndCountdownFinished();
|
public delegate void RoundEndCountdownFinished();
|
||||||
public event RoundEndCountdownFinished OnRoundEndCountdownFinished;
|
public event RoundEndCountdownFinished OnRoundEndCountdownFinished;
|
||||||
|
|
||||||
|
void IResettingEntitySystem.Reset()
|
||||||
|
{
|
||||||
|
IsRoundEndCountdownStarted = false;
|
||||||
|
_roundEndCancellationTokenSource.Cancel();
|
||||||
|
_roundEndCancellationTokenSource = new CancellationTokenSource();
|
||||||
|
ExpectedCountdownEnd = null;
|
||||||
|
}
|
||||||
|
|
||||||
public void RequestRoundEnd()
|
public void RequestRoundEnd()
|
||||||
{
|
{
|
||||||
if (IsRoundEndCountdownStarted)
|
if (IsRoundEndCountdownStarted)
|
||||||
|
|||||||
Reference in New Issue
Block a user