]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cargo request and bounty console deny sound cooldown (#37234)
authorthemias <89101928+themias@users.noreply.github.com>
Thu, 8 May 2025 00:34:44 +0000 (20:34 -0400)
committerGitHub <noreply@github.com>
Thu, 8 May 2025 00:34:44 +0000 (20:34 -0400)
* Cargo bounty console deny sound cooldown

* ordering computer cooldown

* Update Content.Shared/Cargo/Components/CargoBountyConsoleComponent.cs

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
* Update Content.Shared/Cargo/Components/CargoBountyConsoleComponent.cs

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
* Update Content.Server/Cargo/Systems/CargoSystem.Bounty.cs

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
* AutoGenerateComponentPause

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Server/Cargo/Systems/CargoSystem.Bounty.cs
Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Content.Shared/Cargo/Components/CargoBountyConsoleComponent.cs
Content.Shared/Cargo/Components/CargoOrderConsoleComponent.cs

index 10e8b40e53e0d244578fed1dca3a43e5cd072b96..7cb09b8725c30c0f8af4d3eb979efcbff4615cfa 100644 (file)
@@ -93,7 +93,11 @@ public sealed partial class CargoSystem
         if (TryComp<AccessReaderComponent>(uid, out var accessReaderComponent) &&
             !_accessReaderSystem.IsAllowed(mob, uid, accessReaderComponent))
         {
-            _audio.PlayPvs(component.DenySound, uid);
+            if (Timing.CurTime >= component.NextDenySoundTime)
+            {
+                component.NextDenySoundTime = Timing.CurTime + component.DenySoundDelay;
+                _audio.PlayPvs(component.DenySound, uid);
+            }
             return;
         }
 
index c0e59d4ab651155e04c2455e946212792ae6d820..cf6c7e995595e8e6f28fcea455d1e70f0dafbca5 100644 (file)
@@ -16,6 +16,7 @@ using JetBrains.Annotations;
 using Robust.Shared.Audio;
 using Robust.Shared.Map;
 using Robust.Shared.Prototypes;
+using Robust.Shared.Timing;
 using Robust.Shared.Utility;
 
 namespace Content.Server.Cargo.Systems
@@ -24,6 +25,7 @@ namespace Content.Server.Cargo.Systems
     {
         [Dependency] private readonly SharedTransformSystem _transformSystem = default!;
         [Dependency] private readonly EmagSystem _emag = default!;
+        [Dependency] private readonly IGameTiming _timing = default!;
 
         private void InitializeConsole()
         {
@@ -431,7 +433,11 @@ namespace Content.Server.Cargo.Systems
 
         private void PlayDenySound(EntityUid uid, CargoOrderConsoleComponent component)
         {
-            _audio.PlayPvs(_audio.ResolveSound(component.ErrorSound), uid);
+            if (_timing.CurTime >= component.NextDenySoundTime)
+            {
+                component.NextDenySoundTime = _timing.CurTime + component.DenySoundDelay;
+                _audio.PlayPvs(_audio.ResolveSound(component.ErrorSound), uid);
+            }
         }
 
         private static CargoOrderData GetOrderData(CargoConsoleAddOrderMessage args, CargoProductPrototype cargoProduct, int id, ProtoId<CargoAccountPrototype> account)
index 8c78312be19b858889c0caf335dd2d20630d8417..dd01954d629a829804e1df8a3cedc27e2217682f 100644 (file)
@@ -1,4 +1,4 @@
-using Robust.Shared.Audio;
+using Robust.Shared.Audio;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Serialization;
 using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
@@ -6,7 +6,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
 
 namespace Content.Shared.Cargo.Components;
 
-[RegisterComponent]
+[RegisterComponent, AutoGenerateComponentPause]
 public sealed partial class CargoBountyConsoleComponent : Component
 {
     /// <summary>
@@ -44,6 +44,18 @@ public sealed partial class CargoBountyConsoleComponent : Component
     /// </summary>
     [DataField("denySound")]
     public SoundSpecifier DenySound = new SoundPathSpecifier("/Audio/Effects/Cargo/buzz_two.ogg");
+
+    /// <summary>
+    /// The time at which the console will be able to make the denial sound again.
+    /// </summary>
+    [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
+    public TimeSpan NextDenySoundTime = TimeSpan.Zero;
+
+    /// <summary>
+    /// The time between playing a denial sound.
+    /// </summary>
+    [DataField]
+    public TimeSpan DenySoundDelay = TimeSpan.FromSeconds(2);
 }
 
 [NetSerializable, Serializable]
index 200dc7c5754af9f79eb84a53ec204998b328ad5a..8b189313ae4ce080b1ee41cacb61ed8e1573de3b 100644 (file)
@@ -126,6 +126,18 @@ public sealed partial class CargoOrderConsoleComponent : Component
     /// </summary>
     [DataField]
     public SoundSpecifier ScanSound = new SoundCollectionSpecifier("CargoBeep");
+
+    /// <summary>
+    /// The time at which the console will be able to play the deny sound.
+    /// </summary>
+    [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
+    public TimeSpan NextDenySoundTime = TimeSpan.Zero;
+
+    /// <summary>
+    /// The time between playing the deny sound.
+    /// </summary>
+    [DataField]
+    public TimeSpan DenySoundDelay = TimeSpan.FromSeconds(2);
 }
 
 /// <summary>