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 RepairAllButton v1.0.0
RepairAllButton.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace RepairAll; [BepInPlugin("karamelev.valheim.repairall", "RepairAllButton", "1.0.0")] public class RepairAllPlugin : BaseUnityPlugin { public const string ModGuid = "karamelev.valheim.repairall"; public const string ModName = "RepairAllButton"; public const string ModVersion = "1.0.0"; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<KeyCode> SingleItemKey; internal static ConfigEntry<bool> ShowSummary; internal static ConfigEntry<string> SummaryText; internal static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Repair all items with a single press of the repair button."); SingleItemKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "SingleItemModifier", (KeyCode)304, "Hold this key while pressing the repair button to repair only one item (vanilla behaviour). None = disabled."); ShowSummary = ((BaseUnityPlugin)this).Config.Bind<bool>("Messages", "ShowSummary", true, "Show one summary message instead of a message per item."); SummaryText = ((BaseUnityPlugin)this).Config.Bind<string>("Messages", "SummaryText", string.Empty, "Summary message text, {0} = number of items. Empty = automatic (Russian or English by game language)."); _harmony = new Harmony("karamelev.valheim.repairall"); _harmony.PatchAll(typeof(RepairPatch)); Log.LogInfo((object)"RepairAllButton 1.0.0 loaded"); } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(InventoryGui), "RepairOneItem")] internal static class RepairPatch { private static readonly MethodInfo CanRepairMethod = AccessTools.Method(typeof(InventoryGui), "CanRepair", new Type[1] { typeof(ItemData) }, (Type[])null); private static readonly List<ItemData> Worn = new List<ItemData>(); private static readonly object[] Args = new object[1]; [HarmonyPrefix] private static bool Prefix(InventoryGui __instance) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) if (!RepairAllPlugin.Enabled.Value || CanRepairMethod == null) { return true; } KeyCode value = RepairAllPlugin.SingleItemKey.Value; if ((int)value != 0 && Input.GetKey(value)) { return true; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return false; } CraftingStation currentCraftingStation = localPlayer.GetCurrentCraftingStation(); if ((Object)(object)currentCraftingStation == (Object)null && !localPlayer.NoCostCheat()) { return false; } if ((Object)(object)currentCraftingStation != (Object)null && !currentCraftingStation.CheckUsable(localPlayer, false)) { return false; } Worn.Clear(); ((Humanoid)localPlayer).GetInventory().GetWornItems(Worn); int num = 0; string text = null; foreach (ItemData item in Worn) { Args[0] = item; if ((bool)CanRepairMethod.Invoke(__instance, Args)) { ((Character)localPlayer).RaiseSkill((SkillType)107, 1f - item.m_durability / item.GetMaxDurability()); item.m_durability = item.GetMaxDurability(); num++; text = item.m_shared.m_name; if (!RepairAllPlugin.ShowSummary.Value) { ((Character)localPlayer).Message((MessageType)2, Localization.instance.Localize("$msg_repaired", new string[1] { item.m_shared.m_name }), 0, (Sprite)null, false); } } } Worn.Clear(); if (num == 0) { ((Character)localPlayer).Message((MessageType)2, "No more item to repair", 0, (Sprite)null, false); return false; } if ((Object)(object)currentCraftingStation != (Object)null) { currentCraftingStation.m_repairItemDoneEffects.Create(((Component)currentCraftingStation).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID)); } if (RepairAllPlugin.ShowSummary.Value) { string text2 = ((num != 1) ? string.Format(GetSummaryFormat(), num) : Localization.instance.Localize("$msg_repaired", new string[1] { text })); ((Character)localPlayer).Message((MessageType)2, text2, 0, (Sprite)null, false); } return false; } private static string GetSummaryFormat() { string value = RepairAllPlugin.SummaryText.Value; if (!string.IsNullOrEmpty(value)) { return value; } string text = ((Localization.instance == null) ? "English" : Localization.instance.GetSelectedLanguage()); return (!(text == "Russian")) ? "Repaired {0} items" : "Отремонтировано предметов: {0}"; } }