Entity pickup/drop sound components (#10233)
This commit is contained in:
10
Content.Server/Sound/Components/EmitSoundOnDropComponent.cs
Normal file
10
Content.Server/Sound/Components/EmitSoundOnDropComponent.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Content.Server.Sound.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple sound emitter that emits sound on entity drop
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class EmitSoundOnDropComponent : BaseEmitSoundComponent
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Content.Server.Sound.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple sound emitter that emits sound on entity pickup
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class EmitSoundOnPickupComponent : BaseEmitSoundComponent
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,10 @@ using Content.Server.Sound.Components;
|
||||
using Content.Server.Throwing;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Throwing;
|
||||
using JetBrains.Annotations;
|
||||
@@ -58,6 +60,8 @@ namespace Content.Server.Sound
|
||||
SubscribeLocalEvent<EmitSoundOnActivateComponent, ActivateInWorldEvent>(HandleEmitSoundOnActivateInWorld);
|
||||
SubscribeLocalEvent<EmitSoundOnTriggerComponent, TriggerEvent>(HandleEmitSoundOnTrigger);
|
||||
SubscribeLocalEvent<EmitSoundOnUIOpenComponent, AfterActivatableUIOpenEvent>(HandleEmitSoundOnUIOpen);
|
||||
SubscribeLocalEvent<EmitSoundOnPickupComponent, GotEquippedHandEvent>(HandleEmitSoundOnPickup);
|
||||
SubscribeLocalEvent<EmitSoundOnDropComponent, DroppedEvent>(HandleEmitSoundOnDrop);
|
||||
}
|
||||
|
||||
private void HandleEmitSoundOnTrigger(EntityUid uid, EmitSoundOnTriggerComponent component, TriggerEvent args)
|
||||
@@ -106,6 +110,16 @@ namespace Content.Server.Sound
|
||||
TryEmitSound(component);
|
||||
}
|
||||
|
||||
private void HandleEmitSoundOnPickup(EntityUid uid, EmitSoundOnPickupComponent component, GotEquippedHandEvent args)
|
||||
{
|
||||
TryEmitSound(component);
|
||||
}
|
||||
|
||||
private void HandleEmitSoundOnDrop(EntityUid uid, EmitSoundOnDropComponent component, DroppedEvent args)
|
||||
{
|
||||
TryEmitSound(component);
|
||||
}
|
||||
|
||||
private void TryEmitSound(BaseEmitSoundComponent component)
|
||||
{
|
||||
_audioSystem.PlayPvs(component.Sound, component.Owner, component.Sound.Params.AddVolume(-2f));
|
||||
|
||||
Reference in New Issue
Block a user