using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BetterTruckHeals")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterTruckHeals")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("819aea69-b910-4066-83d4-ca334402331c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterTruckHeals;
[BepInPlugin("Lazarus.BetterTruckHeals", "Better Truck Heals", "1.0.0")]
public class BetterTruckHeals : BaseUnityPlugin
{
[HarmonyPatch(typeof(PlayerAvatar), "FinalHealRPC")]
public class PlayerAvatarPatch
{
private static readonly FieldInfo FinalHealField = typeof(PlayerAvatar).GetField("finalHeal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo IsLocalField = typeof(PlayerAvatar).GetField("isLocal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
private static readonly FieldInfo PlayerNameField = typeof(PlayerAvatar).GetField("playerName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
[HarmonyPrefix]
private static bool Prefix(PlayerAvatar __instance)
{
if (FinalHealField == null || IsLocalField == null || PlayerNameField == null)
{
ModLogger.LogError((object)"Failed to reflect fields in PlayerAvatar. Check assembly reference.");
return true;
}
if ((bool)FinalHealField.GetValue(__instance))
{
return true;
}
if ((bool)IsLocalField.GetValue(__instance))
{
int value = HealAmountConfig.Value;
string text = (string)PlayerNameField.GetValue(__instance);
ModLogger.LogInfo((object)$"Applying custom heal amount: {value} for player: {text}");
__instance.playerHealth.EyeMaterialOverride((EyeOverrideState)2, 2f, 1);
TruckScreenText.instance.MessageSendCustom("", text + " {arrowright}{truck}{check}\n {point}{shades}{pointright}<b><color=#00FF00>+" + value + "</color></b>{heart}", 0);
__instance.playerHealth.Heal(value, true);
FinalHealField.SetValue(__instance, true);
}
return false;
}
[HarmonyPostfix]
private static void Postfix(PlayerAvatar __instance)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
TruckHealer.instance.Heal(__instance);
__instance.truckReturn.Play(__instance.PlayerVisionTarget.VisionTransform.position, 1f, 1f, 1f, 1f);
__instance.truckReturnGlobal.Play(__instance.PlayerVisionTarget.VisionTransform.position, 1f, 1f, 1f, 1f);
((Component)__instance.playerAvatarVisuals.effectGetIntoTruck).gameObject.SetActive(true);
}
}
private const string PluginGUID = "Lazarus.BetterTruckHeals";
private const string PluginName = "Better Truck Heals";
private const string PluginVersion = "1.0.0";
public static ConfigEntry<int> HealAmountConfig;
internal static ManualLogSource ModLogger;
private void Awake()
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"John 11:11!");
((BaseUnityPlugin)this).Logger.LogInfo((object)"WAKEY WAKEY!");
((BaseUnityPlugin)this).Logger.LogInfo((object)"BetterTruckHeals has risen!");
HealAmountConfig = ((BaseUnityPlugin)this).Config.Bind<int>("General", "HealAmount", 50, new ConfigDescription("The amount of health the truck healer restores to the player.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
ModLogger = ((BaseUnityPlugin)this).Logger;
ModLogger.LogInfo((object)string.Format("{0} v{1} is loading with heal amount: {2}", "Better Truck Heals", "1.0.0", HealAmountConfig.Value));
Harmony val = new Harmony("Lazarus.BetterTruckHeals");
val.PatchAll();
ModLogger.LogInfo((object)"Harmony patches applied successfully!");
}
}