Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BetterTruckHeals v2.3.2
BetterTruckHeals.dll
Decompiled 2 weeks agousing 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("e91b96fc-65b3-4a7a-b918-993b32dcbfd4")] [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", "2.3.2")] 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); private static readonly FieldInfo MaxHealthField = typeof(PlayerHealth).GetField("maxHealth", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); [HarmonyPrefix] private static bool Prefix(PlayerAvatar __instance) { //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) if (FinalHealField == null || IsLocalField == null || PlayerNameField == null) { ModLogger.LogError((object)"Failed to reflect fields on PlayerAvatar. Check assembly reference."); return true; } if ((bool)FinalHealField.GetValue(__instance)) { return true; } if (!(bool)IsLocalField.GetValue(__instance)) { return true; } string text = (string)PlayerNameField.GetValue(__instance); int num2; if (UsePercentageHealConfig.Value) { if (MaxHealthField == null) { ModLogger.LogError((object)"Failed to reflect 'maxHealth' on PlayerHealth. Falling back to vanilla."); return true; } int num = (int)MaxHealthField.GetValue(__instance.playerHealth); if (num <= 0) { ModLogger.LogError((object)$"Invalid maxHealth ({num}) for player: {text}. Falling back to vanilla."); return true; } num2 = Math.Max(1, (int)((float)num * HealPercentageConfig.Value)); ModLogger.LogInfo((object)$"Applying percentage heal: {num2} ({HealPercentageConfig.Value * 100f}% of {num}) for player: {text}"); } else { num2 = HealAmountConfig.Value; ModLogger.LogInfo((object)$"Applying fixed heal: {num2} for player: {text}"); } __instance.playerHealth.EyeMaterialOverride((EyeOverrideState)2, 2f, 1); __instance.playerHealth.Heal(num2, true); if (SemiFunc.IsMasterClientOrSingleplayer()) { TruckScreenText.instance.MessageSendCustom("", text + " {arrowright}{truck}{check}\n {point}{shades}{pointright}<b><color=#00FF00>+" + num2 + "</color></b>{heart}", 0); } 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); FinalHealField.SetValue(__instance, true); return false; } } private const string PluginGUID = "Lazarus.BetterTruckHeals"; private const string PluginName = "Better Truck Heals"; private const string PluginVersion = "2.3.2"; public static ConfigEntry<int> HealAmountConfig; public static ConfigEntry<bool> UsePercentageHealConfig; public static ConfigEntry<float> HealPercentageConfig; 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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 when UsePercentageHeal is false.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>())); UsePercentageHealConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UsePercentageHeal", false, "If true, heals a percentage of the player's max health. If false, heals a fixed amount."); HealPercentageConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HealPercentage", 0.5f, new ConfigDescription("The percentage of max health to restore when UsePercentageHeal is true (e.g., 0.5 = 50%, 2.0 = 200%).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); ModLogger = ((BaseUnityPlugin)this).Logger; ModLogger.LogInfo((object)("Better Truck Heals v2.3.2 is loading with heal settings: " + $"Fixed Amount = {HealAmountConfig.Value}, " + $"Use Percentage = {UsePercentageHealConfig.Value}, " + $"Percentage = {HealPercentageConfig.Value * 100f}%")); Harmony val = new Harmony("Lazarus.BetterTruckHeals"); val.PatchAll(); ModLogger.LogInfo((object)"Harmony patches applied successfully!"); } }