storage open sound has cooldown now (#14811)

This commit is contained in:
deltanedas
2023-03-24 01:43:49 +00:00
committed by GitHub
parent 07667ae34b
commit e236a1facc
2 changed files with 11 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ using Content.Server.Hands.Components;
using Content.Server.Storage.Components;
using Content.Shared.Interaction;
using Content.Shared.Storage;
using Content.Shared.Timing;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
@@ -59,6 +60,7 @@ namespace Content.Server.Storage.EntitySystems
[Dependency] private readonly SharedCombatModeSystem _combatMode = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly UseDelaySystem _useDelay = default!;
/// <inheritdoc />
public override void Initialize()
@@ -601,8 +603,14 @@ namespace Content.Server.Storage.EntitySystems
if (!Resolve(uid, ref storageComp) || !TryComp(entity, out ActorComponent? player))
return;
// prevent spamming bag open / honkerton honk sound
silent |= TryComp<UseDelayComponent>(uid, out var useDelay) && _useDelay.ActiveDelay(uid, useDelay);
if (!silent)
{
_audio.PlayPvs(storageComp.StorageOpenSound, uid);
if (useDelay != null)
_useDelay.BeginDelay(uid, useDelay);
}
Logger.DebugS(storageComp.LoggerName, $"Storage (UID {uid}) \"used\" by player session (UID {player.PlayerSession.AttachedEntity}).");

View File

@@ -23,6 +23,9 @@
interfaces:
- key: enum.StorageUiKey.Key
type: StorageBoundUserInterface
# to prevent bag open/honk spam
- type: UseDelay
delay: 0.5
- type: entity
parent: ClothingBackpack