]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix sound on material reclaimer (#21030)
authorShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
Mon, 16 Oct 2023 05:30:35 +0000 (22:30 -0700)
committerGitHub <noreply@github.com>
Mon, 16 Oct 2023 05:30:35 +0000 (23:30 -0600)
* Fix saw sound error on client

The sound tried to play using shared PlayPvs which doesn't work on client. PlayPredicted handles client and server.

Fixed NextSound not playing again while continuously gibbing items.

* Fix duplicate splat sound on Recycler gibbing

Content.Server/Materials/MaterialReclaimerSystem.cs
Content.Shared/Materials/SharedMaterialReclaimerSystem.cs

index ce1f285fcf6123da635e17e1c3b69eedc2298349..2f8b43e83287f7f5ad0f952cc55e0cddd3ec4ccb 100644 (file)
@@ -166,13 +166,17 @@ public sealed class MaterialReclaimerSystem : SharedMaterialReclaimerSystem
         var xform = Transform(uid);
 
         SpawnMaterialsFromComposition(uid, item, completion * component.Efficiency, xform: xform);
-        SpawnChemicalsFromComposition(uid, item, completion, component, xform);
 
         if (CanGib(uid, item, component))
         {
+            SpawnChemicalsFromComposition(uid, item, completion, false, component, xform);
             _body.GibBody(item, true);
             _appearance.SetData(uid, RecyclerVisuals.Bloody, true);
         }
+        else
+        {
+            SpawnChemicalsFromComposition(uid, item, completion, true, component, xform);
+        }
 
         QueueDel(item);
     }
@@ -213,6 +217,7 @@ public sealed class MaterialReclaimerSystem : SharedMaterialReclaimerSystem
     private void SpawnChemicalsFromComposition(EntityUid reclaimer,
         EntityUid item,
         float efficiency,
+        bool sound = true,
         MaterialReclaimerComponent? reclaimerComponent = null,
         TransformComponent? xform = null,
         PhysicalCompositionComponent? composition = null)
@@ -248,7 +253,7 @@ public sealed class MaterialReclaimerSystem : SharedMaterialReclaimerSystem
         _solutionContainer.TryTransferSolution(reclaimer, reclaimerComponent.OutputSolution, totalChemicals, totalChemicals.Volume);
         if (totalChemicals.Volume > 0)
         {
-            _puddle.TrySpillAt(reclaimer, totalChemicals, out _, transformComponent: xform);
+            _puddle.TrySpillAt(reclaimer, totalChemicals, out _, sound, transformComponent: xform);
         }
     }
 }
index 3f5832f69a9557550098c5e6eeb82350753d7997..c3c712b617b31add390a12e66b78503703b3362c 100644 (file)
@@ -35,11 +35,17 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem
         SubscribeLocalEvent<MaterialReclaimerComponent, EntityUnpausedEvent>(OnUnpaused);
         SubscribeLocalEvent<MaterialReclaimerComponent, ExaminedEvent>(OnExamined);
         SubscribeLocalEvent<MaterialReclaimerComponent, GotEmaggedEvent>(OnEmagged);
+        SubscribeLocalEvent<MaterialReclaimerComponent, MapInitEvent>(OnMapInit);
         SubscribeLocalEvent<CollideMaterialReclaimerComponent, StartCollideEvent>(OnCollide);
         SubscribeLocalEvent<ActiveMaterialReclaimerComponent, ComponentStartup>(OnActiveStartup);
         SubscribeLocalEvent<ActiveMaterialReclaimerComponent, EntityUnpausedEvent>(OnActiveUnpaused);
     }
 
+    private void OnMapInit(EntityUid uid, MaterialReclaimerComponent component, MapInitEvent args)
+    {
+        component.NextSound = Timing.CurTime;
+    }
+
     private void OnShutdown(EntityUid uid, MaterialReclaimerComponent component, ComponentShutdown args)
     {
         component.Stream?.Stop();
@@ -109,8 +115,11 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem
         }
 
         if (Timing.CurTime > component.NextSound)
-            component.Stream = _audio.PlayPvs(component.Sound, uid);
-        component.NextSound = Timing.CurTime + component.SoundCooldown;
+        {
+            component.Stream = _audio.PlayPredicted(component.Sound, uid, user);
+
+            component.NextSound = Timing.CurTime + component.SoundCooldown;
+        }
 
         var duration = GetReclaimingDuration(uid, item, component);
         // if it's instant, don't bother with all the active comp stuff.