From c20bf50f4039bd6ba422dd35e910d10f410d1a85 Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Sun, 15 Oct 2023 22:30:35 -0700 Subject: [PATCH] Fix sound on material reclaimer (#21030) * 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 | 9 +++++++-- .../Materials/SharedMaterialReclaimerSystem.cs | 13 +++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Content.Server/Materials/MaterialReclaimerSystem.cs b/Content.Server/Materials/MaterialReclaimerSystem.cs index ce1f285fcf..2f8b43e832 100644 --- a/Content.Server/Materials/MaterialReclaimerSystem.cs +++ b/Content.Server/Materials/MaterialReclaimerSystem.cs @@ -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); } } } diff --git a/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs b/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs index 3f5832f69a..c3c712b617 100644 --- a/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs +++ b/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs @@ -35,11 +35,17 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem SubscribeLocalEvent(OnUnpaused); SubscribeLocalEvent(OnExamined); SubscribeLocalEvent(OnEmagged); + SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnCollide); SubscribeLocalEvent(OnActiveStartup); SubscribeLocalEvent(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.