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 VargheimBlacksmithing v1.1.1
VargheimBlacksmithing.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using VargheimProfessions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace VargheimBlacksmithing { [BepInPlugin("digi.vargheim.blacksmithing", "VargheimBlacksmithing", "1.1.1")] [BepInDependency("digi.vargheim.professions", "0.4.0")] public class Plugin : BaseUnityPlugin { [HarmonyPatch] internal static class Patches { [HarmonyPatch(typeof(Humanoid), "UseItem")] [HarmonyPrefix] private static bool UseItem(Humanoid __instance, Inventory inventory, ItemData item) { if (item == null || (Object)(object)item.m_dropPrefab == (Object)null || ((Object)item.m_dropPrefab).name != "VP_RepairKit" || (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } try { int num = 0; foreach (ItemData allItem in __instance.GetInventory().GetAllItems()) { if (allItem != null && allItem.m_equipped && IsArmor(allItem) && allItem.m_shared.m_useDurability && allItem.m_durability < allItem.GetMaxDurability()) { allItem.m_durability = allItem.GetMaxDurability(); num++; } } if (num == 0) { Api.Message("Your armor doesn't need repairing."); return false; } (inventory ?? __instance.GetInventory()).RemoveItem(item, 1); Api.Message("Repaired " + num + " piece" + ((num == 1) ? "" : "s") + " of armor."); } catch (Exception ex) { Debug.LogWarning((object)("VargheimBlacksmithing: " + ex.Message)); } return false; } private static bool MinerNear(Vector3 pos) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) List<Player> list = new List<Player>(); Player.GetPlayersInRange(pos, MinerRange.Value, list); foreach (Player item in list) { if ((Object)(object)item != (Object)(object)Player.m_localPlayer && Api.PerkLevelOf(item, "Mining") >= MinerLevel.Value) { return true; } } return false; } [HarmonyPatch(typeof(Smelter), "OnAddOre")] [HarmonyPostfix] private static void AddOre(Smelter __instance, Humanoid user, ItemData item, bool __result) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) try { if (!__result || (Object)(object)user != (Object)(object)Player.m_localPlayer || item == null || (Object)(object)item.m_dropPrefab == (Object)null || !Api.HasPerk("Blacksmithing", SmeltLevel.Value) || Random.value >= SmeltChance.Value * (MinerNear(((Component)__instance).transform.position) ? 2f : 1f)) { return; } string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); if (!(prefabName != "smelter") || !(prefabName != "blastfurnace")) { ZNetView value = Traverse.Create((object)__instance).Field("m_nview").GetValue<ZNetView>(); if (!((Object)(object)value == (Object)null) && value.IsValid() && Traverse.Create((object)__instance).Method("GetQueueSize", Array.Empty<object>()).GetValue<int>() + ((!value.IsOwner()) ? 1 : 0) + 1 <= __instance.m_maxOre) { value.InvokeRPC("RPC_AddOre", new object[2] { ((Object)item.m_dropPrefab).name, false }); Api.Note("Efficient smelting: an extra bar's worth goes in."); } } } catch { } } } public const string Guid = "digi.vargheim.blacksmithing"; public const string Version = "1.1.1"; internal static ConfigEntry<float> MinerRange; internal static ConfigEntry<int> MinerLevel; private const string Prof = "Blacksmithing"; internal const string Kit = "VP_RepairKit"; internal static ConfigEntry<int> KitLevel; internal static ConfigEntry<int> SmeltLevel; internal static ConfigEntry<string> KitRecipe; internal static ConfigEntry<float> SmeltChance; private void Awake() { //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) KitLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "RepairKitLevel", 40, "Repair kits: level to craft them (anyone can use them)."); KitRecipe = ((BaseUnityPlugin)this).Config.Bind<string>("Perks", "RepairKitRecipe", "Bronze:1,LeatherScraps:2,Resin:2", "Materials for one repair kit (crafted at the forge)."); SmeltLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "EfficientSmeltingLevel", 55, "Efficient smelting level."); SmeltChance = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "EfficientSmeltingChance", 0.1f, "Efficient smelting: chance that ore a smith puts in a smelter or furnace makes an extra bar."); MinerLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "EfficientSmeltingMinerLevel", 25, "Efficient smelting: the chance doubles when a miner of this level is near the smelter."); MinerRange = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "EfficientSmeltingMinerRange", 30f, "How close the miner must be (metres)."); Content.AddItem("BronzeNails", "VP_RepairKit", "Repair Kit", "Tools, rivets and leather patches. Use it to fully repair the armor you're wearing, anywhere.", (Action<SharedData>)delegate(SharedData s) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) s.m_itemType = (ItemType)2; s.m_maxStackSize = 10; s.m_weight = 1f; s.m_food = 0f; s.m_foodStamina = 0f; s.m_foodEitr = 0f; s.m_consumeStatusEffect = null; }); Content.AddRecipe("VP_RepairKit", "forge", 1, 1, KitRecipe.Value, "Blacksmithing", KitLevel.Value); Api.RegisterLadder("Blacksmithing", "VargheimBlacksmithing 1.1.1", "Armorsmith. Modded armor (Therzie Armory, Southsil) is crafted and upgraded by blacksmiths by tier. Smoothbrain Blacksmithing gives the station bonuses, inventory repair (70) and an extra upgrade level (80).", (Perk[])(object)new Perk[7] { new Perk(25, "Workbench", "Workbench station bonuses (Smoothbrain Blacksmithing, 25 and 30)."), new Perk(35, "Forge", "Forge station bonuses (Smoothbrain Blacksmithing, 35 and 45)."), new Perk(KitLevel.Value, "Repair kits", "Craft single-use repair kits at the forge. Anyone can use one to fully repair the armor they're wearing."), new Perk(50, "Black forge", "Black forge and galdr table bonuses (Smoothbrain Blacksmithing, 50 and 60)."), new Perk(SmeltLevel.Value, "Efficient smelting", Mathf.RoundToInt(SmeltChance.Value * 100f) + "% chance that ore you put in a smelter or furnace makes an extra bar. Doubled with a miner nearby."), new Perk(70, "Inventory repair", "Repair from your inventory (Smoothbrain Blacksmithing)."), new Perk(80, "Extra upgrade", "One more upgrade level on gear (Smoothbrain Blacksmithing).") }); new Harmony("digi.vargheim.blacksmithing").PatchAll(typeof(Patches)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"VargheimBlacksmithing 1.1.1 loaded."); } internal static bool IsArmor(ItemData i) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Invalid comparison between Unknown and I4 ItemType itemType = i.m_shared.m_itemType; if (itemType - 6 <= 1 || itemType - 11 <= 1 || (int)itemType == 17) { return true; } return false; } } }