--- /dev/null
+using Content.Shared.Whitelist;
+using Robust.Shared.Prototypes;
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Sound.Components;
+
+/// <summary>
+/// Whenever this item is used upon by an entity, with a tag or component within a whitelist, in the hand of a user, play a sound
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class EmitSoundOnInteractUsingComponent : BaseEmitSoundComponent
+{
+ [DataField(required: true)]
+ public EntityWhitelist Whitelist = new();
+}
SubscribeLocalEvent<EmitSoundOnActivateComponent, ActivateInWorldEvent>(OnEmitSoundOnActivateInWorld);
SubscribeLocalEvent<EmitSoundOnPickupComponent, GotEquippedHandEvent>(OnEmitSoundOnPickup);
SubscribeLocalEvent<EmitSoundOnDropComponent, DroppedEvent>(OnEmitSoundOnDrop);
+ SubscribeLocalEvent<EmitSoundOnInteractUsingComponent, InteractUsingEvent>(OnEmitSoundOnInteractUsing);
SubscribeLocalEvent<EmitSoundOnCollideComponent, StartCollideEvent>(OnEmitSoundOnCollide);
}
TryEmitSound(uid, component, args.User);
}
+ private void OnEmitSoundOnInteractUsing(Entity<EmitSoundOnInteractUsingComponent> ent, ref InteractUsingEvent args)
+ {
+ if (ent.Comp.Whitelist.IsValid(args.Used, EntityManager))
+ {
+ TryEmitSound(ent, ent.Comp, args.User);
+ }
+ }
protected void TryEmitSound(EntityUid uid, BaseEmitSoundComponent component, EntityUid? user=null, bool predict=true)
{
if (component.Sound == null)