0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.SinglePlayer/Patches/Healing/MainMenuControllerPatch.cs
chomp 1e238c426e 0.13.5.0 (!33)
Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Co-authored-by: CWX <CWX@noreply.dev.sp-tarkov.com>
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-authored-by: RaiRaiTheRaichu <rairaitheraichu@noreply.dev.sp-tarkov.com>
Co-authored-by: CWX <cwx@noreply.dev.sp-tarkov.com>
Co-authored-by: Kaeno <e>
Reviewed-on: SPT-AKI/Modules#33
2023-10-10 10:58:33 +00:00

51 lines
1.5 KiB
C#

using Aki.Reflection.Patching;
using Aki.Reflection.Utils;
using EFT.HealthSystem;
using System.Reflection;
namespace Aki.SinglePlayer.Patches.Healing
{
public class MainMenuControllerPatch : ModulePatch
{
static MainMenuControllerPatch()
{
_ = nameof(IHealthController.HydrationChangedEvent);
_ = nameof(MainMenuController.HealthController);
}
protected override MethodBase GetTargetMethod()
{
var desiredType = typeof(MainMenuController);
var desiredMethod = desiredType.GetMethod("method_1", PatchConstants.PrivateFlags);
Logger.LogDebug($"{this.GetType().Name} Type: {desiredType?.Name}");
Logger.LogDebug($"{this.GetType().Name} Method: {desiredMethod?.Name}");
return desiredMethod;
}
[PatchPostfix]
private static void PatchPostfix(MainMenuController __instance)
{
var healthController = __instance.HealthController;
var listener = Utils.Healing.HealthListener.Instance;
if (healthController == null)
{
Logger.LogInfo("MainMenuControllerPatch() - healthController is null");
}
if (listener == null)
{
Logger.LogInfo("MainMenuControllerPatch() - listener is null");
}
if (healthController != null && listener != null)
{
listener.Init(healthController, false);
}
}
}
}