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
This commit is contained in:
astriloqua
2023-08-04 22:24:20 +00:00
committed by GitHub
parent 2a87079909
commit 210ccf2e7f

View File

@@ -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);