From 210ccf2e7f47897a0643e81cf313a6fef49f83a6 Mon Sep 17 00:00:00 2001 From: astriloqua <129308840+astriloqua@users.noreply.github.com> Date: Fri, 4 Aug 2023 22:24:20 +0000 Subject: [PATCH] Buckle sound fix (#18662) * Resolve buckle audio playing twice Note: Unbuckling other still plays twice. :( * Resolve unbuckling other AAAAAAAAAAAAAAAAAAAAAAAAAAA * Remove newline that I added for no reason at all --- Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs index 399070b12c..ac55b647e5 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Numerics; using Content.Shared.Alert; using Content.Shared.Bed.Sleep; @@ -357,7 +357,8 @@ public abstract partial class SharedBuckleSystem ReAttach(buckleUid, strapUid, buckleComp, strapComp); SetBuckledTo(buckleUid,strapUid, strapComp, buckleComp); // TODO user is currently set to null because if it isn't the sound fails to play in some situations, fix that - _audioSystem.PlayPredicted(strapComp.BuckleSound, strapUid, null); + var audioSourceUid = userUid == buckleUid ? userUid : strapUid; + _audioSystem.PlayPredicted(strapComp.BuckleSound, strapUid, audioSourceUid); var ev = new BuckleChangeEvent(strapUid, buckleUid, true); RaiseLocalEvent(ev.BuckledEntity, ref ev); @@ -483,7 +484,8 @@ public abstract partial class SharedBuckleSystem } AppearanceSystem.SetData(strapUid, StrapVisuals.State, strapComp.BuckledEntities.Count != 0); - _audioSystem.PlayPredicted(strapComp.UnbuckleSound, strapUid, null); + var audioSourceUid = userUid != buckleUid ? userUid : strapUid; + _audioSystem.PlayPredicted(strapComp.UnbuckleSound, strapUid, audioSourceUid); var ev = new BuckleChangeEvent(strapUid, buckleUid, false); RaiseLocalEvent(buckleUid, ref ev);