diff --git a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs index 10e8b40e53..7cb09b8725 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs @@ -93,7 +93,11 @@ public sealed partial class CargoSystem if (TryComp(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; } diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index c0e59d4ab6..cf6c7e9955 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -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 account) diff --git a/Content.Shared/Cargo/Components/CargoBountyConsoleComponent.cs b/Content.Shared/Cargo/Components/CargoBountyConsoleComponent.cs index 8c78312be1..dd01954d62 100644 --- a/Content.Shared/Cargo/Components/CargoBountyConsoleComponent.cs +++ b/Content.Shared/Cargo/Components/CargoBountyConsoleComponent.cs @@ -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 { /// @@ -44,6 +44,18 @@ public sealed partial class CargoBountyConsoleComponent : Component /// [DataField("denySound")] public SoundSpecifier DenySound = new SoundPathSpecifier("/Audio/Effects/Cargo/buzz_two.ogg"); + + /// + /// The time at which the console will be able to make the denial sound again. + /// + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField] + public TimeSpan NextDenySoundTime = TimeSpan.Zero; + + /// + /// The time between playing a denial sound. + /// + [DataField] + public TimeSpan DenySoundDelay = TimeSpan.FromSeconds(2); } [NetSerializable, Serializable] diff --git a/Content.Shared/Cargo/Components/CargoOrderConsoleComponent.cs b/Content.Shared/Cargo/Components/CargoOrderConsoleComponent.cs index 200dc7c575..8b189313ae 100644 --- a/Content.Shared/Cargo/Components/CargoOrderConsoleComponent.cs +++ b/Content.Shared/Cargo/Components/CargoOrderConsoleComponent.cs @@ -126,6 +126,18 @@ public sealed partial class CargoOrderConsoleComponent : Component /// [DataField] public SoundSpecifier ScanSound = new SoundCollectionSpecifier("CargoBeep"); + + /// + /// The time at which the console will be able to play the deny sound. + /// + [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField] + public TimeSpan NextDenySoundTime = TimeSpan.Zero; + + /// + /// The time between playing the deny sound. + /// + [DataField] + public TimeSpan DenySoundDelay = TimeSpan.FromSeconds(2); } ///