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 InfiniteMeleeDurability v3.4.0
InfiniteMeleeDurability.dll
Decompiled 4 hours 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 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("InfiniteMeleeDurability")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("InfiniteMeleeDurability")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4f88c25b-eb0e-45d6-a4b0-2dd6ca434af3")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace InfiniteMeleeDurability; [BepInPlugin("repo.matrock.infinitemeleedurability", "Infinite Melee Durability", "3.4.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class InfiniteMeleeDurabilityMod : BaseUnityPlugin { private static FieldInfo itemBatteryField; private static FieldInfo batteryLifeField; private static FieldInfo autoDrainField; public static ConfigEntry<bool> ModEnabled { get; private set; } public static ConfigEntry<bool> ProtectFryingPan { get; private set; } public static ConfigEntry<bool> ProtectBaseballBat { get; private set; } public static ConfigEntry<bool> ProtectSword { get; private set; } public static ConfigEntry<bool> ProtectSledgeHammer { get; private set; } public static ConfigEntry<bool> ProtectInflatableHammer { get; private set; } public static ConfigEntry<bool> ProtectProdzap { get; private set; } public static ConfigEntry<bool> ProtectAllOther { get; private set; } private void Awake() { //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"========================================"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Infinite Melee Durability LOADED! v3.4"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"========================================"); ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Mod Enabled", true, "Включить/выключить мод"); ProtectFryingPan = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Protect Frying Pan", true, "Сковородка"); ProtectBaseballBat = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Protect Baseball Bat", true, "Бейсбольная бита"); ProtectSword = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Protect Sword", true, "Меч"); ProtectSledgeHammer = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Protect Sledge Hammer", true, "Кувалда"); ProtectInflatableHammer = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Protect Inflatable Hammer", true, "Надувной молоток"); ProtectProdzap = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Protect Prodzap", true, "Электрошокер"); ProtectAllOther = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Protect All Other", true, "Все остальные"); FindFields(); Harmony val = new Harmony("repo.matrock.infinitemeleedurability"); val.PatchAll(); } private void FindFields() { BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; itemBatteryField = typeof(ItemMelee).GetField("itemBattery", bindingAttr); if (itemBatteryField != null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Found ItemMelee.itemBattery field"); } else { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not find ItemMelee.itemBattery field!"); } batteryLifeField = typeof(ItemBattery).GetField("batteryLife", bindingAttr); if (batteryLifeField != null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Found ItemBattery.batteryLife field"); } else { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not find ItemBattery.batteryLife field!"); } autoDrainField = typeof(ItemBattery).GetField("autoDrain", bindingAttr); if (autoDrainField != null) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Found ItemBattery.autoDrain field"); } } public static bool ShouldProtectItem(ItemMelee item) { if ((Object)(object)item == (Object)null) { return false; } if (!ModEnabled.Value) { return false; } string text = ((Object)item).name.ToLower(); if (text.Contains("fryingpan") || text.Contains("frying pan") || text.Contains("pan")) { return ProtectFryingPan.Value; } if (text.Contains("baseballbat") || text.Contains("baseball bat") || text.Contains("bat")) { return ProtectBaseballBat.Value; } if (text.Contains("sword")) { return ProtectSword.Value; } if (text.Contains("sledgehammer") || text.Contains("sledge hammer") || text.Contains("sledge")) { return ProtectSledgeHammer.Value; } if (text.Contains("inflatablehammer") || text.Contains("inflatable hammer") || text.Contains("hammer")) { return ProtectInflatableHammer.Value; } if (text.Contains("prodzap") || text.Contains("zap") || text.Contains("stun") || text.Contains("shock")) { return ProtectProdzap.Value; } return ProtectAllOther.Value; } public static void RestoreBatteryCharge(ItemMelee item) { if ((Object)(object)item == (Object)null || !ShouldProtectItem(item) || itemBatteryField == null || batteryLifeField == null) { return; } try { object? value = itemBatteryField.GetValue(item); ItemBattery val = (ItemBattery)((value is ItemBattery) ? value : null); if ((Object)(object)val != (Object)null) { batteryLifeField.SetValue(val, 1f); if (autoDrainField != null) { autoDrainField.SetValue(val, false); } } } catch (Exception ex) { Debug.LogError((object)("[InfiniteDurability] Error: " + ex.Message)); } } } [HarmonyPatch(typeof(ItemMelee), "SwingHitRPC")] public class Patch_SwingHitRPC { private static void Prefix(ItemMelee __instance) { InfiniteMeleeDurabilityMod.RestoreBatteryCharge(__instance); } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakRPC")] public class Patch_BreakRPC { private static bool Prefix(PhysGrabObjectImpactDetector __instance) { ItemMelee component = ((Component)__instance).GetComponent<ItemMelee>(); if ((Object)(object)component != (Object)null && InfiniteMeleeDurabilityMod.ShouldProtectItem(component)) { InfiniteMeleeDurabilityMod.RestoreBatteryCharge(component); return false; } return true; } } [HarmonyPatch(typeof(ItemMelee), "Update")] public class Patch_Update { private static void Postfix(ItemMelee __instance) { if ((Object)(object)__instance != (Object)null && InfiniteMeleeDurabilityMod.ShouldProtectItem(__instance)) { InfiniteMeleeDurabilityMod.RestoreBatteryCharge(__instance); } } }