From 4138fedca2829ab818612cf1e37ca85c720b5a3a Mon Sep 17 00:00:00 2001
From: Morb <14136326+Morb0@users.noreply.github.com>
Date: Tue, 9 Aug 2022 12:14:55 +0300
Subject: [PATCH] Entity pickup/drop sound components (#10233)
---
.../Sound/Components/EmitSoundOnDropComponent.cs | 10 ++++++++++
.../Sound/Components/EmitSoundOnPickupComponent.cs | 10 ++++++++++
Content.Server/Sound/EmitSoundSystem.cs | 14 ++++++++++++++
3 files changed, 34 insertions(+)
create mode 100644 Content.Server/Sound/Components/EmitSoundOnDropComponent.cs
create mode 100644 Content.Server/Sound/Components/EmitSoundOnPickupComponent.cs
diff --git a/Content.Server/Sound/Components/EmitSoundOnDropComponent.cs b/Content.Server/Sound/Components/EmitSoundOnDropComponent.cs
new file mode 100644
index 0000000000..6653d50693
--- /dev/null
+++ b/Content.Server/Sound/Components/EmitSoundOnDropComponent.cs
@@ -0,0 +1,10 @@
+namespace Content.Server.Sound.Components
+{
+ ///
+ /// Simple sound emitter that emits sound on entity drop
+ ///
+ [RegisterComponent]
+ public sealed class EmitSoundOnDropComponent : BaseEmitSoundComponent
+ {
+ }
+}
diff --git a/Content.Server/Sound/Components/EmitSoundOnPickupComponent.cs b/Content.Server/Sound/Components/EmitSoundOnPickupComponent.cs
new file mode 100644
index 0000000000..9018565d9a
--- /dev/null
+++ b/Content.Server/Sound/Components/EmitSoundOnPickupComponent.cs
@@ -0,0 +1,10 @@
+namespace Content.Server.Sound.Components
+{
+ ///
+ /// Simple sound emitter that emits sound on entity pickup
+ ///
+ [RegisterComponent]
+ public sealed class EmitSoundOnPickupComponent : BaseEmitSoundComponent
+ {
+ }
+}
diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs
index 84b4deed38..5b19f60ae3 100644
--- a/Content.Server/Sound/EmitSoundSystem.cs
+++ b/Content.Server/Sound/EmitSoundSystem.cs
@@ -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(HandleEmitSoundOnActivateInWorld);
SubscribeLocalEvent(HandleEmitSoundOnTrigger);
SubscribeLocalEvent(HandleEmitSoundOnUIOpen);
+ SubscribeLocalEvent(HandleEmitSoundOnPickup);
+ SubscribeLocalEvent(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));