make admin interacts with storages silent (#35417)
* make admin interacts with storages silent * review * silent insert and transfer * i love code --------- Co-authored-by: ScarKy0 <scarky0@onet.eu>
This commit is contained in:
parent
721e848d46
commit
0653ee74a5
|
|
@ -23,6 +23,7 @@ using Content.Shared.Placeable;
|
|||
using Content.Shared.Popups;
|
||||
using Content.Shared.Stacks;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Timing;
|
||||
using Content.Shared.Storage.Events;
|
||||
using Content.Shared.Verbs;
|
||||
|
|
@ -67,6 +68,7 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||
[Dependency] private readonly SharedStackSystem _stack = default!;
|
||||
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
|
||||
[Dependency] protected readonly SharedUserInterfaceSystem UI = default!;
|
||||
[Dependency] private readonly TagSystem _tag = default!;
|
||||
[Dependency] protected readonly UseDelaySystem UseDelay = default!;
|
||||
|
||||
private EntityQuery<ItemComponent> _itemQuery;
|
||||
|
|
@ -277,7 +279,8 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||
if (!UI.IsUiOpen(uid, args.UiKey))
|
||||
{
|
||||
UpdateAppearance((uid, storageComp, null));
|
||||
Audio.PlayPredicted(storageComp.StorageCloseSound, uid, args.Actor);
|
||||
if (!_tag.HasTag(args.Actor, storageComp.SilentStorageUserTag))
|
||||
Audio.PlayPredicted(storageComp.StorageCloseSound, uid, args.Actor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -358,7 +361,7 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||
if (!UI.TryOpenUi(uid, StorageComponent.StorageUiKey.Key, entity))
|
||||
return;
|
||||
|
||||
if (!silent)
|
||||
if (!silent && !_tag.HasTag(entity, storageComp.SilentStorageUserTag))
|
||||
{
|
||||
Audio.PlayPredicted(storageComp.StorageOpenSound, uid, entity);
|
||||
|
||||
|
|
@ -603,7 +606,8 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||
// If we picked up at least one thing, play a sound and do a cool animation!
|
||||
if (successfullyInserted.Count > 0)
|
||||
{
|
||||
Audio.PlayPredicted(component.StorageInsertSound, uid, args.User, _audioParams);
|
||||
if (!_tag.HasTag(args.User, component.SilentStorageUserTag))
|
||||
Audio.PlayPredicted(component.StorageInsertSound, uid, args.User, _audioParams);
|
||||
EntityManager.RaiseSharedEvent(new AnimateInsertingEntitiesEvent(
|
||||
GetNetEntity(uid),
|
||||
GetNetEntityList(successfullyInserted),
|
||||
|
|
@ -646,7 +650,8 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||
$"{ToPrettyString(player):player} is attempting to take {ToPrettyString(item):item} out of {ToPrettyString(storage):storage}");
|
||||
|
||||
if (_sharedHandsSystem.TryPickupAnyHand(player, item, handsComp: player.Comp)
|
||||
&& storage.Comp.StorageRemoveSound != null)
|
||||
&& storage.Comp.StorageRemoveSound != null
|
||||
&& !_tag.HasTag(player, storage.Comp.SilentStorageUserTag))
|
||||
{
|
||||
Audio.PlayPredicted(storage.Comp.StorageRemoveSound, storage, player, _audioParams);
|
||||
}
|
||||
|
|
@ -907,8 +912,10 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||
|
||||
Insert(target, entity, out _, user: user, targetComp, playSound: false);
|
||||
}
|
||||
|
||||
Audio.PlayPredicted(sourceComp.StorageInsertSound, target, user, _audioParams);
|
||||
if (user != null
|
||||
&& (!_tag.HasTag(user.Value, sourceComp.SilentStorageUserTag)
|
||||
|| !_tag.HasTag(user.Value, targetComp.SilentStorageUserTag)))
|
||||
Audio.PlayPredicted(sourceComp.StorageInsertSound, target, user, _audioParams);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1081,12 +1088,17 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||
* For now we just treat items as always being the same size regardless of stack count.
|
||||
*/
|
||||
|
||||
// Check if the sound is expected to play.
|
||||
// If there is an user, the sound will not play if they have the SilentStorageUserTag
|
||||
// If there is no user, only playSound is checked.
|
||||
var canPlaySound = playSound && (user == null || !_tag.HasTag(user.Value, storageComp.SilentStorageUserTag));
|
||||
|
||||
if (!stackAutomatically || !_stackQuery.TryGetComponent(insertEnt, out var insertStack))
|
||||
{
|
||||
if (!ContainerSystem.Insert(insertEnt, storageComp.Container))
|
||||
return false;
|
||||
|
||||
if (playSound)
|
||||
if (canPlaySound)
|
||||
Audio.PlayPredicted(storageComp.StorageInsertSound, uid, user, _audioParams);
|
||||
|
||||
return true;
|
||||
|
|
@ -1116,7 +1128,7 @@ public abstract class SharedStorageSystem : EntitySystem
|
|||
return false;
|
||||
}
|
||||
|
||||
if (playSound)
|
||||
if (canPlaySound)
|
||||
Audio.PlayPredicted(storageComp.StorageInsertSound, uid, user, _audioParams);
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Content.Shared.Item;
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
|
|
@ -141,6 +142,12 @@ namespace Content.Shared.Storage
|
|||
[DataField]
|
||||
public bool HideStackVisualsWhenClosed = true;
|
||||
|
||||
/// <summary>
|
||||
/// Entities with this tag won't trigger storage sound.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public ProtoId<TagPrototype> SilentStorageUserTag = "SilentStorageUser";
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum StorageUiKey : byte
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
- BypassInteractionRangeChecks
|
||||
- BypassDropChecks
|
||||
- NoConsoleSound
|
||||
- SilentStorageUser
|
||||
- type: Input
|
||||
context: "aghost"
|
||||
- type: Ghost
|
||||
|
|
|
|||
|
|
@ -1165,6 +1165,9 @@
|
|||
- type: Tag
|
||||
id: SignalTrigger
|
||||
|
||||
- type: Tag
|
||||
id: SilentStorageUser # used in SharedStorageSystem, so the entity will do all silently
|
||||
|
||||
- type: Tag
|
||||
id: SkeletonMotorcycleKeys
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue