Please disclose if your mod was created primarily 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 InfiniteDurability v1.1.1
InfiniteDurability.dll
Decompiled 2 years agousing System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Utils; 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("InfiniteDurability")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("InfiniteDurability")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] namespace InfiniteDurability; public static class Configs { public static ConfigEntry<string> IgnoreItemList; public static ConfigurationManagerAttributes IsAdminOnly = new ConfigurationManagerAttributes { IsAdminOnly = true }; public static void SetupConfigs(ConfigFile config) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown string text = GenerateConfigKey("IgnoreItemList"); object[] array = new object[1]; ConfigurationManagerAttributes val = new ConfigurationManagerAttributes(); val.IsAdminOnly = true; val.CustomDrawer = TextAreaDrawer; array[0] = val; IgnoreItemList = config.Bind<string>("General", text, "RuneFocus", new ConfigDescription("Defines the prefabs to be ignored from the durability tweaks. Format: item_prefab_1,item_prefab_2,(...). Example: RuneFocus,Torch. Please refer to https://valheim-modding.github.io/Jotunn/data/objects/item-list.html for a list of prefabs.", (AcceptableValueBase)null, array)); config.SettingChanged += Config_SettingChanged; } private static void Config_SettingChanged(object sender, SettingChangedEventArgs e) { InfiniteDurability.LoadIgnoreItemList(); } public static string GenerateConfigKey(string key) { return GenerateConfigKey(key, null); } public static string GenerateConfigKey(string key, string unit) { key = string.Concat(key.Select((char x) => char.IsUpper(x) ? (" " + x) : x.ToString())).TrimStart(new char[1] { ' ' }); if (!string.IsNullOrEmpty(unit)) { key += $" ({unit})"; } return key; } public static ConfigurationManagerAttributes SetOrder(int order, bool isAdminOnly = true) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown return new ConfigurationManagerAttributes { Order = order, IsAdminOnly = isAdminOnly }; } private static void TextAreaDrawer(ConfigEntryBase entry) { GUILayout.ExpandHeight(true); GUILayout.ExpandWidth(true); entry.BoxedValue = GUILayout.TextArea((string)entry.BoxedValue, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); } } [BepInPlugin("InfiniteDurability", "InfiniteDurability", "1.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class InfiniteDurability : BaseUnityPlugin { [HarmonyPatch(typeof(Attack), "DoAreaAttack")] public static class Attack_DoAreaAttack_Patch { public static void Postfix(ItemData ___m_weapon) { RestoreDurability(___m_weapon); } } [HarmonyPatch(typeof(Attack), "DoMeleeAttack")] public static class Attack_DoMeleeAttack_Patch { public static void Postfix(ItemData ___m_weapon) { RestoreDurability(___m_weapon); } } [HarmonyPatch(typeof(Attack), "DoNonAttack")] public static class Attack_DoNonAttack_Patch { public static void Postfix(ItemData ___m_weapon) { RestoreDurability(___m_weapon); } } [HarmonyPatch(typeof(Attack), "ProjectileAttackTriggered")] public static class Attack_ProjectileAttackTriggered_Patch { public static void Postfix(ItemData ___m_weapon) { RestoreDurability(___m_weapon); } } [HarmonyPatch(typeof(Humanoid), "BlockAttack")] public static class Humanoid_BlockAttack_Patch { public static void Postfix(Humanoid __instance) { RestoreDurability(__instance.GetCurrentBlocker()); } } [HarmonyPatch(typeof(Humanoid), "DrainEquipedItemDurability")] public static class Humanoid_DrainEquipedItemDurability_Patch { public static void Postfix(ref ItemData item) { RestoreDurability(item); } } [HarmonyPatch(typeof(Player), "UpdatePlacement")] public static class Player_UpdatePlacement_Patch { public static void Postfix(Player __instance) { RestoreDurability(((Humanoid)__instance).GetRightItem()); } } [HarmonyPatch(typeof(Player), "DamageArmorDurability")] public static class Player_DamageArmorDurability_Patch { public static void Postfix(Player __instance) { RestoreDurability(((Humanoid)__instance).m_helmetItem); RestoreDurability(((Humanoid)__instance).m_chestItem); RestoreDurability(((Humanoid)__instance).m_legItem); RestoreDurability(((Humanoid)__instance).m_shoulderItem); } } public const string PluginGUID = "InfiniteDurability"; public const string PluginName = "InfiniteDurability"; public const string PluginVersion = "1.1.1"; public static readonly List<string> IgnoredItems = new List<string>(); public Harmony MyHarmony; private void Awake() { Configs.SetupConfigs(((BaseUnityPlugin)this).Config); LoadIgnoreItemList(); MyHarmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "InfiniteDurability"); } private void OnDestroy() { Harmony myHarmony = MyHarmony; if (myHarmony != null) { myHarmony.UnpatchSelf(); } } private static void RestoreDurability(ItemData item) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Invalid comparison between Unknown and I4 //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Invalid comparison between Unknown and I4 if (item != null && (Object)(object)item.m_dropPrefab != (Object)null && ((int)item.m_shared.m_itemType == 6 || (int)item.m_shared.m_itemType == 7 || (int)item.m_shared.m_itemType == 11 || (int)item.m_shared.m_itemType == 17 || (int)item.m_shared.m_itemType == 3 || (int)item.m_shared.m_itemType == 14 || (int)item.m_shared.m_itemType == 22 || (int)item.m_shared.m_itemType == 4 || (int)item.m_shared.m_itemType == 5 || (int)item.m_shared.m_itemType == 19 || (int)item.m_shared.m_itemType == 15) && !IgnoredItems.Contains(((Object)item.m_dropPrefab).name)) { item.m_durability = item.GetMaxDurability(); } } public static void LoadIgnoreItemList() { if (string.IsNullOrEmpty(Configs.IgnoreItemList.Value)) { return; } string[] array = Configs.IgnoreItemList.Value.Split(new char[1] { ',' }); string[] array2 = array; foreach (string text in array2) { if (string.IsNullOrEmpty(text)) { Logger.LogError((object)"Ignore Item List not in the expected format. Please see the documentation and adhere to the correct format."); IgnoredItems.Clear(); return; } IgnoredItems.Add(text.Trim()); } Logger.LogInfo((object)"Ignore Item List loaded successfully."); } }