]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cardboard Boxes will play effect & sound again (#14859)
authorkeronshb <54602815+keronshb@users.noreply.github.com>
Sun, 26 Mar 2023 02:26:39 +0000 (22:26 -0400)
committerGitHub <noreply@github.com>
Sun, 26 Mar 2023 02:26:39 +0000 (13:26 +1100)
Content.Server/CardboardBox/CardboardBoxSystem.cs

index 890ff0f4e2f20a48a07a96c4b8a0cdde53a55e66..0e0c171f02cfd26b43955c96d8aa13aed54e8220 100644 (file)
@@ -29,6 +29,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
     {
         base.Initialize();
         SubscribeLocalEvent<CardboardBoxComponent, StorageAfterOpenEvent>(AfterStorageOpen);
+        SubscribeLocalEvent<CardboardBoxComponent, StorageBeforeOpenEvent>(BeforeStorageOpen);
         SubscribeLocalEvent<CardboardBoxComponent, StorageAfterCloseEvent>(AfterStorageClosed);
         SubscribeLocalEvent<CardboardBoxComponent, InteractedNoHandEvent>(OnNoHandInteracted);
         SubscribeLocalEvent<CardboardBoxComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
@@ -46,19 +47,22 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
         _storage.OpenStorage(uid);
     }
 
-    private void AfterStorageOpen(EntityUid uid, CardboardBoxComponent component, ref StorageAfterOpenEvent args)
+    private void BeforeStorageOpen(EntityUid uid, CardboardBoxComponent component, ref StorageBeforeOpenEvent args)
     {
-        //Remove the mover after the box is opened and play the effect if it hasn't been played yet.
+        //Play effect & sound
         if (component.Mover != null)
         {
             if (_timing.CurTime > component.EffectCooldown)
             {
-                RaiseNetworkEvent(new PlayBoxEffectMessage(component.Owner, component.Mover.Value), Filter.PvsExcept(component.Owner));
-                _audio.PlayPvs(component.EffectSound, component.Owner);
+                RaiseNetworkEvent(new PlayBoxEffectMessage(uid, component.Mover.Value));
+                _audio.PlayPvs(component.EffectSound, uid);
                 component.EffectCooldown = _timing.CurTime + CardboardBoxComponent.MaxEffectCooldown;
             }
         }
+    }
 
+    private void AfterStorageOpen(EntityUid uid, CardboardBoxComponent component, ref StorageAfterOpenEvent args)
+    {
         // If this box has a stealth/chameleon effect, disable the stealth effect while the box is open.
         _stealth.SetEnabled(uid, false);
     }