0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
2023-03-03 18:52:31 +00:00

36 lines
1.2 KiB
C#

using EFT;
using Comfort.Common;
using System.Reflection;
using Aki.Reflection.Patching;
using System.Collections;
namespace Aki.SinglePlayer.Patches.RaidFix
{
public class TinnitusFixPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return typeof(BetterAudio).GetMethod("StartTinnitusEffect", BindingFlags.Instance | BindingFlags.Public);
}
// checks on invoke whether the player is stunned before allowing tinnitus
[PatchPrefix]
static bool PatchPrefix()
{
bool shouldInvoke = typeof(ActiveHealthControllerClass)
.GetMethod("FindActiveEffect", BindingFlags.Instance | BindingFlags.Public)
.MakeGenericMethod(typeof(ActiveHealthControllerClass)
.GetNestedType("Stun", BindingFlags.Instance | BindingFlags.NonPublic))
.Invoke(Singleton<GameWorld>.Instance.AllPlayers[0].ActiveHealthController, new object[] { EBodyPart.Common }) != null;
return shouldInvoke;
}
// prevent null coroutine exceptions
static IEnumerator CoroutinePassthrough()
{
yield return null;
yield break;
}
}
}