]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
AME and PA make a warning sound to admins when overloaded along with the warning...
authorVasilis <vasilis@pikachu.systems>
Sat, 18 Nov 2023 03:18:37 +0000 (04:18 +0100)
committerGitHub <noreply@github.com>
Sat, 18 Nov 2023 03:18:37 +0000 (21:18 -0600)
* WOOP WOOP

* i forgor to add this

* I totally did not steal code

* OH FUCK

* Ok i'm done using webedit.

* Reviews and AME anti spam

* make sound shorter

Content.Server/Ame/Components/AmeControllerComponent.cs
Content.Server/Ame/EntitySystems/AmeControllerSystem.cs
Content.Server/ParticleAccelerator/Components/ParticleAcceleratorControlBoxComponent.cs
Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.ControlBox.cs
Resources/Audio/Misc/adminlarm.ogg [new file with mode: 0644]
Resources/Changelog/Admin.yml

index 1bf1ac2c927c389be40e559d7ac67f520134bb12..abdb76c9e33cd0bc722b41430d5a7ea0ae12ba9a 100644 (file)
@@ -2,6 +2,7 @@ using Content.Server.Ame.EntitySystems;
 using Content.Shared.Ame;
 using Robust.Shared.Audio;
 using Robust.Shared.Containers;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
 
 namespace Content.Server.Ame.Components;
 
@@ -89,4 +90,16 @@ public sealed partial class AmeControllerComponent : SharedAmeControllerComponen
     /// </summary>
     [ViewVariables]
     public TimeSpan UpdateUIPeriod = TimeSpan.FromSeconds(3.0);
+
+    /// <summary>
+    /// Time at which the admin alarm sound effect can next be played.
+    /// </summary>
+    [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
+    public TimeSpan EffectCooldown;
+
+    /// <summary>
+    /// Time between admin alarm sound effects. Prevents spam
+    /// </summary>
+    [DataField]
+    public TimeSpan CooldownDuration = TimeSpan.FromSeconds(10f);
 }
index 44140193d2a3f01cdb25134cf6296ed1dc56f45d..0dddff3637ded87f865fe065da21d9d4212555f7 100644 (file)
@@ -1,6 +1,7 @@
 using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using Content.Server.Administration.Logs;
+using Content.Server.Administration.Managers;
 using Content.Server.Ame.Components;
 using Content.Server.Chat.Managers;
 using Content.Server.NodeContainer;
@@ -16,6 +17,7 @@ using Robust.Server.Containers;
 using Robust.Server.GameObjects;
 using Robust.Shared.Audio;
 using Robust.Shared.Containers;
+using Robust.Shared.Player;
 using Robust.Shared.Timing;
 
 namespace Content.Server.Ame.EntitySystems;
@@ -23,6 +25,7 @@ namespace Content.Server.Ame.EntitySystems;
 public sealed class AmeControllerSystem : EntitySystem
 {
     [Dependency] private readonly IAdminLogManager _adminLogger = default!;
+    [Dependency] private readonly IAdminManager _adminManager = default!;
     [Dependency] private readonly IChatManager _chatManager = default!;
     [Dependency] private readonly IGameTiming _gameTiming = default!;
     [Dependency] private readonly AppearanceSystem _appearanceSystem = default!;
@@ -233,7 +236,15 @@ public sealed class AmeControllerSystem : EntitySystem
             safeLimit = group.CoreCount * 2;
 
         if (oldValue <= safeLimit && value > safeLimit)
-            _chatManager.SendAdminAlert(user.Value, $"increased AME over safe limit to {controller.InjectionAmount}");
+        {
+            if (_gameTiming.CurTime > controller.EffectCooldown)
+            {
+                _chatManager.SendAdminAlert(user.Value, $"increased AME over safe limit to {controller.InjectionAmount}");
+                _audioSystem.PlayGlobal("/Audio/Misc/adminlarm.ogg",
+                    Filter.Empty().AddPlayers(_adminManager.ActiveAdmins), false, AudioParams.Default.WithVolume(-8f));
+                controller.EffectCooldown = _gameTiming.CurTime + controller.CooldownDuration;
+            }
+        }
     }
 
     public void AdjustInjectionAmount(EntityUid uid, int delta, int min = 0, int max = int.MaxValue, EntityUid? user = null, AmeControllerComponent? controller = null)
index 2adbbe05f793f03a1f643d225b4461d8143ce3b2..b460e96accf8425ba048db3bf23efc560287165f 100644 (file)
@@ -1,5 +1,6 @@
 using Content.Server.ParticleAccelerator.Wires;
 using Content.Shared.Singularity.Components;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
 
 namespace Content.Server.ParticleAccelerator.Components;
 
@@ -167,6 +168,18 @@ public sealed partial class ParticleAcceleratorControlBoxComponent : Component
     [ViewVariables]
     public bool StrengthLocked = false;
 
+    /// <summary>
+    /// Time at which the admin alarm sound effect can next be played.
+    /// </summary>
+    [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
+    public TimeSpan EffectCooldown;
+
+    /// <summary>
+    /// Time between admin alarm sound effects. Prevents spam
+    /// </summary>
+    [DataField]
+    public TimeSpan CooldownDuration = TimeSpan.FromSeconds(10f);
+
     /// <summary>
     /// Whether the PA can be turned on.
     /// Modified by <see cref="ParticleAcceleratorPowerWireAction"/>.
index f200c991d7f1323fa475626dc352725e498d4154..5900dc55b3eff13c30889440a306cc3a3f390483 100644 (file)
@@ -4,13 +4,19 @@ using Content.Shared.Database;
 using Content.Shared.Singularity.Components;
 using Robust.Shared.Utility;
 using System.Diagnostics;
+using Content.Server.Administration.Managers;
 using Content.Shared.CCVar;
+using Robust.Shared.Audio;
+using Robust.Shared.Timing;
 using Robust.Shared.Player;
 
 namespace Content.Server.ParticleAccelerator.EntitySystems;
 
 public sealed partial class ParticleAcceleratorSystem
 {
+    [Dependency] private readonly IAdminManager _adminManager = default!;
+    [Dependency] private readonly SharedAudioSystem _audio = default!;
+    [Dependency] private readonly IGameTiming _timing = default!;
     private void InitializeControlBoxSystem()
     {
         SubscribeLocalEvent<ParticleAcceleratorControlBoxComponent, ComponentStartup>(OnComponentStartup);
@@ -165,10 +171,17 @@ public sealed partial class ParticleAcceleratorSystem
             if (strength >= alertMinPowerState)
             {
                 var pos = Transform(uid);
-                _chat.SendAdminAlert(player, Loc.GetString("particle-accelerator-admin-power-strength-warning",
-                    ("machine", ToPrettyString(uid)),
-                    ("powerState", strength),
-                    ("coordinates", pos.Coordinates)));
+                if (_timing.CurTime > comp.EffectCooldown)
+                {
+                    _chat.SendAdminAlert(player, Loc.GetString("particle-accelerator-admin-power-strength-warning",
+                        ("machine", ToPrettyString(uid)),
+                        ("powerState", strength),
+                        ("coordinates", pos.Coordinates)));
+                    _audio.PlayGlobal("/Audio/Misc/adminlarm.ogg",
+                        Filter.Empty().AddPlayers(_adminManager.ActiveAdmins), false,
+                        AudioParams.Default.WithVolume(-8f));
+                    comp.EffectCooldown = _timing.CurTime + comp.CooldownDuration;
+                }
             }
         }
 
diff --git a/Resources/Audio/Misc/adminlarm.ogg b/Resources/Audio/Misc/adminlarm.ogg
new file mode 100644 (file)
index 0000000..7c75e20
Binary files /dev/null and b/Resources/Audio/Misc/adminlarm.ogg differ
index 92641ad69e71a1ac23ab39ca3c96d6c002d4e4f6..6b7763d14d25447ea28ab053b42b3f40b9d75b25 100644 (file)
@@ -61,3 +61,8 @@ Entries:
       in some cases.', type: Fix}
   id: 9
   time: '2023-10-30T01:28:00.0000000+00:00'
+- author: Vasilis
+  changes:
+  - {message: 'AME and PA make a sound effect when they are being overloaded. Similar to being sent a fax.', type: Add}
+  id: 10
+  time: '2023-11-07T15:03:00.0000000+00:00'