From 4e69f69c846af9d58d85d8343a426834410039fe Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Fri, 24 May 2024 14:48:43 +0200 Subject: [PATCH] Fix endless firing loop for clients --- .../CoopObservedFirearmController.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs b/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs index 374e53a2..210dd508 100644 --- a/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs +++ b/Fika.Core/Coop/ObservedClasses/HandsControllers/CoopObservedFirearmController.cs @@ -130,7 +130,9 @@ public override void OnPlayerDead() { triggerPressed = false; SetTriggerPressed(false); - WeaponSoundPlayer.enabled = false; + + needsReset = false; + WeaponSoundPlayer.OnBreakLoop(); coopPlayer.HandsAnimator.Animator.Update(Time.fixedDeltaTime); ManualUpdate(Time.fixedDeltaTime); @@ -139,9 +141,23 @@ public override void OnPlayerDead() CurrentOperation.FastForward(); } + StartCoroutine(BreakFiringLoop()); + base.OnPlayerDead(); } + private IEnumerator BreakFiringLoop() + { + Traverse isFiring = Traverse.Create(WeaponSoundPlayer).Field("_isFiring"); + int attempts = 0; + while (isFiring.Value && attempts < 10) + { + yield return new WaitForEndOfFrame(); + WeaponSoundPlayer.OnBreakLoop(); + attempts++; + } + } + public override void SetScopeMode(GStruct165[] scopeStates) { _player.ProceduralWeaponAnimation.ObservedCalibration();