From 83ec96745563e129020adc71942500ba911352ce Mon Sep 17 00:00:00 2001
From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Date: Mon, 26 Aug 2024 17:40:14 +1000
Subject: [PATCH] Predict EmitSoundOnUIOpen (#31464)
* Predict EmitSoundOnUIOpen
BUI prediction led to this moment.
* unforky
---
.../Sound/Components/EmitSoundOnUIOpenComponent.cs | 12 ------------
Content.Server/Sound/EmitSoundSystem.cs | 6 ------
.../Sound/Components/EmitSoundOnUIOpenComponent.cs | 11 +++++++++++
Content.Shared/Sound/SharedEmitSoundSystem.cs | 8 +++++++-
4 files changed, 18 insertions(+), 19 deletions(-)
delete mode 100644 Content.Server/Sound/Components/EmitSoundOnUIOpenComponent.cs
create mode 100644 Content.Shared/Sound/Components/EmitSoundOnUIOpenComponent.cs
diff --git a/Content.Server/Sound/Components/EmitSoundOnUIOpenComponent.cs b/Content.Server/Sound/Components/EmitSoundOnUIOpenComponent.cs
deleted file mode 100644
index 44e83b0e79..0000000000
--- a/Content.Server/Sound/Components/EmitSoundOnUIOpenComponent.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using Content.Shared.Sound.Components;
-
-namespace Content.Server.Sound.Components
-{
- ///
- /// Simple sound emitter that emits sound on AfterActivatableUIOpenEvent
- ///
- [RegisterComponent]
- public sealed partial class EmitSoundOnUIOpenComponent : BaseEmitSoundComponent
- {
- }
-}
diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs
index fc10d951e7..9d7e8496c3 100644
--- a/Content.Server/Sound/EmitSoundSystem.cs
+++ b/Content.Server/Sound/EmitSoundSystem.cs
@@ -39,15 +39,9 @@ public sealed class EmitSoundSystem : SharedEmitSoundSystem
base.Initialize();
SubscribeLocalEvent(HandleEmitSoundOnTrigger);
- SubscribeLocalEvent(HandleEmitSoundOnUIOpen);
SubscribeLocalEvent(HandleSpamEmitSoundMapInit);
}
- private void HandleEmitSoundOnUIOpen(EntityUid uid, EmitSoundOnUIOpenComponent component, AfterActivatableUIOpenEvent args)
- {
- TryEmitSound(uid, component, args.User, false);
- }
-
private void HandleEmitSoundOnTrigger(EntityUid uid, EmitSoundOnTriggerComponent component, TriggerEvent args)
{
TryEmitSound(uid, component, args.User, false);
diff --git a/Content.Shared/Sound/Components/EmitSoundOnUIOpenComponent.cs b/Content.Shared/Sound/Components/EmitSoundOnUIOpenComponent.cs
new file mode 100644
index 0000000000..a979a6ec50
--- /dev/null
+++ b/Content.Shared/Sound/Components/EmitSoundOnUIOpenComponent.cs
@@ -0,0 +1,11 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Sound.Components;
+
+///
+/// Simple sound emitter that emits sound on AfterActivatableUIOpenEvent
+///
+[RegisterComponent, NetworkedComponent]
+public sealed partial class EmitSoundOnUIOpenComponent : BaseEmitSoundComponent
+{
+}
diff --git a/Content.Shared/Sound/SharedEmitSoundSystem.cs b/Content.Shared/Sound/SharedEmitSoundSystem.cs
index efc18abaa0..8733edf485 100644
--- a/Content.Shared/Sound/SharedEmitSoundSystem.cs
+++ b/Content.Shared/Sound/SharedEmitSoundSystem.cs
@@ -1,6 +1,5 @@
using Content.Shared.Audio;
using Content.Shared.Hands;
-using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Maps;
@@ -8,6 +7,7 @@ using Content.Shared.Mobs;
using Content.Shared.Popups;
using Content.Shared.Sound.Components;
using Content.Shared.Throwing;
+using Content.Shared.UserInterface;
using Content.Shared.Whitelist;
using JetBrains.Annotations;
using Robust.Shared.Audio;
@@ -48,12 +48,18 @@ public abstract class SharedEmitSoundSystem : EntitySystem
SubscribeLocalEvent(OnEmitSoundOnPickup);
SubscribeLocalEvent(OnEmitSoundOnDrop);
SubscribeLocalEvent(OnEmitSoundOnInteractUsing);
+ SubscribeLocalEvent(HandleEmitSoundOnUIOpen);
SubscribeLocalEvent(OnEmitSoundOnCollide);
SubscribeLocalEvent(OnMobState);
}
+ private void HandleEmitSoundOnUIOpen(EntityUid uid, EmitSoundOnUIOpenComponent component, AfterActivatableUIOpenEvent args)
+ {
+ TryEmitSound(uid, component, args.User);
+ }
+
private void OnMobState(Entity entity, ref MobStateChangedEvent args)
{
// Disable this component rather than removing it because it can be brought back to life.
--
2.51.2