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;
}
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
{
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly EmagSystem _emag = default!;
+ [Dependency] private readonly IGameTiming _timing = default!;
private void InitializeConsole()
{
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)
-using Robust.Shared.Audio;
+using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Cargo.Components;
-[RegisterComponent]
+[RegisterComponent, AutoGenerateComponentPause]
public sealed partial class CargoBountyConsoleComponent : Component
{
/// <summary>
/// </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]
/// </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>