0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00

36 lines
1.2 KiB
C#
Raw Normal View History

using System;
2024-05-21 19:10:17 +01:00
using SPT.Reflection.Patching;
2023-03-03 18:52:31 +00:00
using EFT;
using System.Reflection;
using System.Threading.Tasks;
using HarmonyLib;
2023-03-03 18:52:31 +00:00
2024-05-21 19:10:17 +01:00
namespace SPT.SinglePlayer.Patches.Healing
2023-03-03 18:52:31 +00:00
{
public class PlayerPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(Player), nameof(Player.Init));
2023-03-03 18:52:31 +00:00
}
[PatchPostfix]
private static async void PatchPostfix(Task __result, Player __instance, Profile profile)
{
await __result;
if (profile?.Id.Equals(Common.Http.RequestHandler.SessionId, StringComparison.InvariantCultureIgnoreCase) ?? false)
2023-03-03 18:52:31 +00:00
{
Logger.LogDebug($"Hooking up health listener to profile: {profile.Id}");
var listener = Utils.Healing.HealthListener.Instance;
listener.Init(__instance.HealthController, true);
Logger.LogDebug($"HealthController instance: {__instance.HealthController.GetHashCode()}");
}
else
{
Logger.LogDebug($"Skipped on HealthController instance: {__instance.HealthController.GetHashCode()} for profile id: {profile?.Id}");
}
}
}
}