0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.SinglePlayer/Patches/RaidFix/PlayerToggleSoundFixPatch.cs

38 lines
1.2 KiB
C#
Raw Normal View History

2023-06-30 19:29:56 +01:00
using System.Reflection;
2024-05-21 19:10:17 +01:00
using SPT.Reflection.Patching;
2023-06-30 19:29:56 +01:00
using Comfort.Common;
using EFT;
using HarmonyLib;
2023-06-30 19:29:56 +01:00
using UnityEngine;
2024-05-21 19:10:17 +01:00
namespace SPT.SinglePlayer.Patches.RaidFix
2023-06-30 19:29:56 +01:00
{
/// <summary>
/// Fixes an issue with the visor toggle sound not following the player in offline raids
/// </summary>
public class PlayerToggleSoundFixPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(Player), nameof(Player.PlayToggleSound));
2023-06-30 19:29:56 +01:00
}
[PatchPrefix]
private static bool PatchPrefix(ref bool previousState, bool isOn, AudioClip toggleOn, AudioClip toggleOff, Player __instance)
{
// Don't change anything and execute original method if it's not the player that triggers the method
if (!__instance.IsYourPlayer)
{
return true;
}
if (previousState != isOn)
{
Singleton<BetterAudio>.Instance.PlayNonspatial(isOn ? toggleOn : toggleOff, BetterAudio.AudioSourceGroupType.Character);
}
previousState = isOn;
return false;
}
}
}