diff --git a/Content.Server/StationEvents/PowerGridCheck.cs b/Content.Server/StationEvents/PowerGridCheck.cs
index 11ef585c5f..5292776b8b 100644
--- a/Content.Server/StationEvents/PowerGridCheck.cs
+++ b/Content.Server/StationEvents/PowerGridCheck.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Threading;
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using JetBrains.Annotations;
using Robust.Server.GameObjects.EntitySystems;
@@ -7,6 +8,7 @@ using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
+using Timer = Robust.Shared.Timers.Timer;
namespace Content.Server.StationEvents
{
@@ -28,6 +30,13 @@ namespace Content.Server.StationEvents
private float _elapsedTime;
private int _failDuration;
+ ///
+ /// So we don't overlap the announcement with power-down sounds we'll delay it a few seconds.
+ ///
+ private bool _announced;
+
+ private CancellationTokenSource _announceCancelToken;
+
private List _powered = new List();
@@ -35,8 +44,8 @@ namespace Content.Server.StationEvents
public override void Startup()
{
base.Startup();
- EntitySystem.Get().PlayGlobal("/Audio/Announcements/power_off.ogg");
+ _announced = false;
_elapsedTime = 0.0f;
_failDuration = IoCManager.Resolve().Next(30, 120);
var componentManager = IoCManager.Resolve();
@@ -51,7 +60,6 @@ namespace Content.Server.StationEvents
public override void Shutdown()
{
base.Shutdown();
- EntitySystem.Get().PlayGlobal("/Audio/Announcements/power_on.ogg");
foreach (var entity in _powered)
{
@@ -63,6 +71,12 @@ namespace Content.Server.StationEvents
}
}
+ _announceCancelToken?.Cancel();
+ _announceCancelToken = new CancellationTokenSource();
+ Timer.Spawn(3000, () =>
+ {
+ EntitySystem.Get().PlayGlobal("/Audio/Announcements/power_on.ogg");
+ }, _announceCancelToken.Token);
_powered.Clear();
}
@@ -72,6 +86,12 @@ namespace Content.Server.StationEvents
{
return;
}
+
+ if (!_announced && _elapsedTime > 3.0f)
+ {
+ EntitySystem.Get().PlayGlobal("/Audio/Announcements/power_off.ogg");
+ _announced = true;
+ }
_elapsedTime += frameTime;