Entity pickup/drop sound components (#10233)

This commit is contained in:
Morb
2022-08-09 12:14:55 +03:00
committed by GitHub
parent e8de8df981
commit 4138fedca2
3 changed files with 34 additions and 0 deletions

View 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
{
}
}

View File

@@ -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
{
}
}

View File

@@ -4,8 +4,10 @@ using Content.Server.Sound.Components;
using Content.Server.Throwing; using Content.Server.Throwing;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Content.Server.Popups; using Content.Server.Popups;
using Content.Shared.Hands;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Maps; using Content.Shared.Maps;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using JetBrains.Annotations; using JetBrains.Annotations;
@@ -58,6 +60,8 @@ namespace Content.Server.Sound
SubscribeLocalEvent<EmitSoundOnActivateComponent, ActivateInWorldEvent>(HandleEmitSoundOnActivateInWorld); SubscribeLocalEvent<EmitSoundOnActivateComponent, ActivateInWorldEvent>(HandleEmitSoundOnActivateInWorld);
SubscribeLocalEvent<EmitSoundOnTriggerComponent, TriggerEvent>(HandleEmitSoundOnTrigger); SubscribeLocalEvent<EmitSoundOnTriggerComponent, TriggerEvent>(HandleEmitSoundOnTrigger);
SubscribeLocalEvent<EmitSoundOnUIOpenComponent, AfterActivatableUIOpenEvent>(HandleEmitSoundOnUIOpen); SubscribeLocalEvent<EmitSoundOnUIOpenComponent, AfterActivatableUIOpenEvent>(HandleEmitSoundOnUIOpen);
SubscribeLocalEvent<EmitSoundOnPickupComponent, GotEquippedHandEvent>(HandleEmitSoundOnPickup);
SubscribeLocalEvent<EmitSoundOnDropComponent, DroppedEvent>(HandleEmitSoundOnDrop);
} }
private void HandleEmitSoundOnTrigger(EntityUid uid, EmitSoundOnTriggerComponent component, TriggerEvent args) private void HandleEmitSoundOnTrigger(EntityUid uid, EmitSoundOnTriggerComponent component, TriggerEvent args)
@@ -106,6 +110,16 @@ namespace Content.Server.Sound
TryEmitSound(component); 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) private void TryEmitSound(BaseEmitSoundComponent component)
{ {
_audioSystem.PlayPvs(component.Sound, component.Owner, component.Sound.Params.AddVolume(-2f)); _audioSystem.PlayPvs(component.Sound, component.Owner, component.Sound.Params.AddVolume(-2f));