]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Predict EmitSoundOnUIOpen (#31464)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Mon, 26 Aug 2024 07:40:14 +0000 (17:40 +1000)
committerGitHub <noreply@github.com>
Mon, 26 Aug 2024 07:40:14 +0000 (17:40 +1000)
* Predict EmitSoundOnUIOpen

BUI prediction led to this moment.

* unforky

Content.Server/Sound/Components/EmitSoundOnUIOpenComponent.cs [deleted file]
Content.Server/Sound/EmitSoundSystem.cs
Content.Shared/Sound/Components/EmitSoundOnUIOpenComponent.cs [new file with mode: 0644]
Content.Shared/Sound/SharedEmitSoundSystem.cs

diff --git a/Content.Server/Sound/Components/EmitSoundOnUIOpenComponent.cs b/Content.Server/Sound/Components/EmitSoundOnUIOpenComponent.cs
deleted file mode 100644 (file)
index 44e83b0..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-using Content.Shared.Sound.Components;
-
-namespace Content.Server.Sound.Components
-{
-    /// <summary>
-    /// Simple sound emitter that emits sound on AfterActivatableUIOpenEvent
-    /// </summary>
-    [RegisterComponent]
-    public sealed partial class EmitSoundOnUIOpenComponent : BaseEmitSoundComponent
-    {
-    }
-}
index fc10d951e76f3559abb445c89b5bf1fe7f67ba01..9d7e8496c3c4cb5f935d92ad3c607808a01a61ec 100644 (file)
@@ -39,15 +39,9 @@ public sealed class EmitSoundSystem : SharedEmitSoundSystem
         base.Initialize();
 
         SubscribeLocalEvent<EmitSoundOnTriggerComponent, TriggerEvent>(HandleEmitSoundOnTrigger);
-        SubscribeLocalEvent<EmitSoundOnUIOpenComponent, AfterActivatableUIOpenEvent>(HandleEmitSoundOnUIOpen);
         SubscribeLocalEvent<SpamEmitSoundComponent, MapInitEvent>(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 (file)
index 0000000..a979a6e
--- /dev/null
@@ -0,0 +1,11 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Sound.Components;
+
+/// <summary>
+/// Simple sound emitter that emits sound on AfterActivatableUIOpenEvent
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class EmitSoundOnUIOpenComponent : BaseEmitSoundComponent
+{
+}
index efc18abaa065dd0306cc87035a84eb17de176b5d..8733edf485d830a8f3be05b7da41616b23a111e6 100644 (file)
@@ -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<EmitSoundOnPickupComponent, GotEquippedHandEvent>(OnEmitSoundOnPickup);
         SubscribeLocalEvent<EmitSoundOnDropComponent, DroppedEvent>(OnEmitSoundOnDrop);
         SubscribeLocalEvent<EmitSoundOnInteractUsingComponent, InteractUsingEvent>(OnEmitSoundOnInteractUsing);
+        SubscribeLocalEvent<EmitSoundOnUIOpenComponent, AfterActivatableUIOpenEvent>(HandleEmitSoundOnUIOpen);
 
         SubscribeLocalEvent<EmitSoundOnCollideComponent, StartCollideEvent>(OnEmitSoundOnCollide);
 
         SubscribeLocalEvent<SoundWhileAliveComponent, MobStateChangedEvent>(OnMobState);
     }
 
+    private void HandleEmitSoundOnUIOpen(EntityUid uid, EmitSoundOnUIOpenComponent component, AfterActivatableUIOpenEvent args)
+    {
+        TryEmitSound(uid, component, args.User);
+    }
+
     private void OnMobState(Entity<SoundWhileAliveComponent> entity, ref MobStateChangedEvent args)
     {
         // Disable this component rather than removing it because it can be brought back to life.