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;
|
2024-01-13 22:08:29 +00:00
|
|
|
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()
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|