2023-03-03 18:52:31 +00:00
|
|
|
|
using EFT;
|
|
|
|
|
using Comfort.Common;
|
|
|
|
|
using System.Reflection;
|
2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
using System.Collections;
|
2023-10-10 10:58:33 +00:00
|
|
|
|
using EFT.HealthSystem;
|
2024-01-13 22:08:29 +00:00
|
|
|
|
using HarmonyLib;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.SinglePlayer.Patches.RaidFix
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
|
|
|
|
public class TinnitusFixPatch : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
|
return AccessTools.Method(typeof(BetterAudio), nameof(BetterAudio.StartTinnitusEffect));
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// checks on invoke whether the player is stunned before allowing tinnitus
|
|
|
|
|
[PatchPrefix]
|
2024-08-02 16:57:59 +01:00
|
|
|
|
public static bool PatchPrefix()
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
|
var baseMethod = AccessTools.Method(typeof(ActiveHealthController), nameof(ActiveHealthController.FindActiveEffect));
|
|
|
|
|
|
|
|
|
|
bool shouldInvoke = baseMethod
|
2023-10-10 10:58:33 +00:00
|
|
|
|
.MakeGenericMethod(typeof(ActiveHealthController)
|
2023-03-03 18:52:31 +00:00
|
|
|
|
.GetNestedType("Stun", BindingFlags.Instance | BindingFlags.NonPublic))
|
2023-07-07 10:37:47 +01:00
|
|
|
|
.Invoke(Singleton<GameWorld>.Instance.MainPlayer.ActiveHealthController, new object[] { EBodyPart.Common }) != null;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
|
|
|
|
return shouldInvoke;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// prevent null coroutine exceptions
|
|
|
|
|
static IEnumerator CoroutinePassthrough()
|
|
|
|
|
{
|
|
|
|
|
yield return null;
|
|
|
|
|
yield break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|