Add new component to Make sound on interact (#26523)
* Adds new Component: EmitSoundOnInteractUsing * Missed an import * File-scoping * Replace ID check with Prototype check * Moved component and system to shared. Set prediction to true. * Removed impoper imports and changed namespace of component to reflect changed folder. * Following function naming theme * All this code is basically deltanedas's, but it was a learning experience for me * Update Content.Shared/Sound/Components/EmitSoundOnInteractUsingComponent.cs * Update Content.Shared/Sound/Components/EmitSoundOnInteractUsingComponent.cs --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -41,6 +41,7 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
||||
SubscribeLocalEvent<EmitSoundOnActivateComponent, ActivateInWorldEvent>(OnEmitSoundOnActivateInWorld);
|
||||
SubscribeLocalEvent<EmitSoundOnPickupComponent, GotEquippedHandEvent>(OnEmitSoundOnPickup);
|
||||
SubscribeLocalEvent<EmitSoundOnDropComponent, DroppedEvent>(OnEmitSoundOnDrop);
|
||||
SubscribeLocalEvent<EmitSoundOnInteractUsingComponent, InteractUsingEvent>(OnEmitSoundOnInteractUsing);
|
||||
|
||||
SubscribeLocalEvent<EmitSoundOnCollideComponent, StartCollideEvent>(OnEmitSoundOnCollide);
|
||||
}
|
||||
@@ -102,6 +103,13 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user