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 UpgradeAntlerPickaxe v1.2.0
plugins\UpgradeAntlerPickaxe.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using Jotunn; using Jotunn.Configs; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; using UpgradeAntlerPickaxe.Configs; using UpgradeAntlerPickaxe.Types; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("UpgradeAntlerPickaxe")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("UpgradeAntlerPickaxe")] [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.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] namespace UpgradeAntlerPickaxe { internal class RecipeHelper { private static readonly Regex nukeWhiteSpaceRegex = new Regex("\\s+"); private static readonly Regex recipeEntryRegex = new Regex("^([a-zA-Z]+:[0-9]+)$"); public static RequirementConfig[] GetAsRequirementConfigArray(string configRecipe, string upgradeRecipe, int multiplier) { return GetAsRequirementConfigList(configRecipe, upgradeRecipe, multiplier).ToArray(); } public static Requirement[] GetAsPieceRequirementArray(string configRecipe, string upgradeRecipe, int multiplier) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown try { List<RequirementConfig> asRequirementConfigList = GetAsRequirementConfigList(configRecipe, upgradeRecipe, multiplier); List<Requirement> list = new List<Requirement>(); foreach (RequirementConfig item in asRequirementConfigList) { GameObject prefab = PrefabManager.Instance.GetPrefab(item.Item); if ((Object)(object)prefab == (Object)null) { throw new Exception("Could not find item, please check config!"); } Requirement val = new Requirement(); val.m_resItem = prefab.GetComponent<ItemDrop>(); val.m_amount = item.Amount; val.m_amountPerLevel = item.AmountPerLevel; val.m_recover = item.Recover; list.Add(val); } return list.ToArray(); } catch (Exception ex) { Logger.LogError((object)("Could not convert recipe to Piece.Requirement array: " + ex)); return null; } } public static List<RequirementConfig> GetAsRequirementConfigList(string configRecipe, string upgradeRecipe, int multiplier) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown try { configRecipe = nukeWhiteSpaceRegex.Replace(configRecipe, ""); upgradeRecipe = nukeWhiteSpaceRegex.Replace(upgradeRecipe, ""); if (!IsConfigRecipeValid(configRecipe, upgradeRecipe)) { throw new Exception("Config is not valid, please check the values!"); } List<RequirementConfig> list = new List<RequirementConfig>(); string[] array = configRecipe.Trim().Split(new char[1] { ',' }); foreach (string obj in array) { RequirementConfig val = new RequirementConfig(); string[] array2 = obj.Split(new char[1] { ':' }); val.Item = array2[0]; val.Amount = int.Parse(array2[1]); val.Recover = true; if (!Utility.IsNullOrWhiteSpace(upgradeRecipe)) { string[] array3 = upgradeRecipe.Trim().Split(new char[1] { ',' }); for (int j = 0; j < array3.Length; j++) { string[] array4 = array3[j].Split(new char[1] { ':' }); if (val.Item == array4[0]) { val.AmountPerLevel = int.Parse(array4[1]) * multiplier; break; } } } list.Add(val); } return list; } catch (Exception ex) { Logger.LogError((object)("Could not convert recipe to RequirementConfig list: " + ex)); return null; } } public static bool IsConfigRecipeValid(string configRecipe, string upgradeRecipe) { try { bool result = true; string[] array = configRecipe.Split(new char[1] { ',' }); foreach (string text in array) { if (!recipeEntryRegex.IsMatch(text)) { result = false; Logger.LogError((object)("Cannot resolve " + text + " from the crafting recipe")); } } if (Utility.IsNullOrWhiteSpace(upgradeRecipe)) { return result; } array = upgradeRecipe.Split(new char[1] { ',' }); foreach (string text2 in array) { if (!recipeEntryRegex.IsMatch(text2)) { result = false; Logger.LogError((object)("Cannot resolve " + text2 + " from the upgrade recipe")); } } return result; } catch (Exception ex) { Logger.LogError((object)("Could not validate recipe due to an error: " + ex)); return false; } } } internal enum RecipeUpdateType { Recipe, CraftingStation, MinRequiredLevel } [BepInPlugin("DeathWizsh.UpgradeAntlerPickaxe", "Upgrade Antler Pickaxe", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class UpgradeAntlerPickaxe : BaseUnityPlugin { public const string PluginGUID = "DeathWizsh.UpgradeAntlerPickaxe"; public const string PluginName = "Upgrade Antler Pickaxe"; public const string PluginVersion = "1.2.0"; public static UpgradeAntlerPickaxe Instance; public static string configFileName = "DeathWizsh.UpgradeAntlerPickaxe.cfg"; public static string configFileFullPath; public void Awake() { try { Instance = this; PluginConfig.Init(); if (PluginConfig.configEnable.Value) { PrefabManager.OnVanillaPrefabsAvailable += PatchStats; ItemManager.OnItemsRegistered += PatchOriginalRecipe; } } catch (Exception ex) { Logger.LogError((object)("Something went wrong with the initialisation of UpgradeAntlerPickaxe: " + ex)); } } public void PatchStats() { try { ItemDrop component = PrefabManager.Instance.GetPrefab("PickaxeAntler").GetComponent<ItemDrop>(); UpdateItemStats(component); PrefabManager.OnVanillaPrefabsAvailable -= PatchStats; } catch (Exception ex) { Logger.LogError((object)("Unable to patch stats onto the antler pickaxe: " + ex.Message)); } } public void UnpatchStats() { try { ItemDrop component = PrefabManager.Instance.GetPrefab("PickaxeAntler").GetComponent<ItemDrop>(); UpdateItemStats(component, unpatch: true); } catch (Exception ex) { Logger.LogError((object)("Unable to unpatch stats from the antler pickaxe: " + ex.Message)); } } private void UpdateItemStats(ItemDrop item, bool unpatch = false) { if (unpatch) { item.m_itemData.m_shared.m_maxQuality = 1; return; } item.m_itemData.m_shared.m_maxQuality = 4; item.m_itemData.m_shared.m_damagesPerLevel.m_pickaxe = 5f; item.m_itemData.m_shared.m_damagesPerLevel.m_pierce = 5f; item.m_itemData.m_shared.m_blockPowerPerLevel = 0f; item.m_itemData.m_shared.m_deflectionForcePerLevel = 5f; item.m_itemData.m_shared.m_durabilityPerLevel = 50f; } private Recipe GetOriginalRecipe() { ItemDrop component = PrefabManager.Instance.GetPrefab("PickaxeAntler").GetComponent<ItemDrop>(); return ObjectDB.instance.GetRecipe(component.m_itemData); } private void PatchOriginalRecipe() { PatchRecipe(); PatchRecipe(RecipeUpdateType.CraftingStation); PatchRecipe(RecipeUpdateType.MinRequiredLevel); } public void PatchRecipe(RecipeUpdateType updateType = RecipeUpdateType.Recipe) { try { Recipe originalRecipe = GetOriginalRecipe(); if ((Object)(object)originalRecipe == (Object)null) { throw new Exception("Could not find recipe!"); } if (!PluginConfig.configEnable.Value) { return; } switch (updateType) { case RecipeUpdateType.Recipe: { Requirement[] asPieceRequirementArray = RecipeHelper.GetAsPieceRequirementArray(PluginConfig.configRecipe.Value, PluginConfig.configRecipeUpgrade.Value, PluginConfig.configRecipeMultiplier.Value); if (asPieceRequirementArray == null) { throw new Exception("Requirements is null"); } originalRecipe.m_resources = asPieceRequirementArray; break; } case RecipeUpdateType.CraftingStation: if (PluginConfig.configCraftingStation.Value == "None") { originalRecipe.m_craftingStation = null; originalRecipe.m_enabled = true; } else if (PluginConfig.configCraftingStation.Value == "Disabled") { originalRecipe.m_craftingStation = null; originalRecipe.m_enabled = false; } else { string internalName = CraftingStations.GetInternalName(PluginConfig.configCraftingStation.Value); originalRecipe.m_enabled = true; originalRecipe.m_craftingStation = PrefabManager.Instance.GetPrefab(internalName).GetComponent<CraftingStation>(); } break; case RecipeUpdateType.MinRequiredLevel: originalRecipe.m_minStationLevel = PluginConfig.configMinStationLevel.Value; break; } } catch (Exception ex) { Logger.LogError((object)("Could not update recipe: " + ex)); } } static UpgradeAntlerPickaxe() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; configFileFullPath = configPath + directorySeparatorChar + configFileName; } } } namespace UpgradeAntlerPickaxe.Types { internal class CraftingStationType { public static string None => "None"; public static string Disabled => "Disabled"; public static string Workbench => "Workbench"; public static string Forge => "Forge"; public static string Cauldron => "Cauldron"; public static string Stonecutter => "Stonecutter"; public static string ArtisanTable => "ArtisanTable"; public static string BlackForge => "BlackForge"; public static string GaldrTable => "GaldrTable"; } } namespace UpgradeAntlerPickaxe.Configs { internal static class PluginConfig { public static string sectionGeneral = "General"; public static string[] craftingStationOptions = new string[9] { CraftingStationType.None, CraftingStationType.Disabled, CraftingStationType.Workbench, CraftingStationType.Forge, CraftingStationType.Stonecutter, CraftingStationType.Cauldron, CraftingStationType.ArtisanTable, CraftingStationType.BlackForge, CraftingStationType.GaldrTable }; public static ConfigEntry<bool> configEnable; public static ConfigEntry<string> configCraftingStation; public static ConfigEntry<int> configMinStationLevel; public static ConfigEntry<string> configRecipe; public static ConfigEntry<string> configRecipeUpgrade; public static ConfigEntry<int> configRecipeMultiplier; private static int entryCount = 1000; private static FileSystemWatcher configWatcher; public static void Init() { InitGeneralConfig(); } public static void InitGeneralConfig() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_005f: Expected O, but got Unknown //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_00e9: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_0166: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_01e7: Expected O, but got Unknown //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Expected O, but got Unknown //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Expected O, but got Unknown //IL_0268: Expected O, but got Unknown //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Expected O, but got Unknown //IL_02f5: Expected O, but got Unknown try { ((BaseUnityPlugin)UpgradeAntlerPickaxe.Instance).Config.SaveOnConfigSet = false; configEnable = ((BaseUnityPlugin)UpgradeAntlerPickaxe.Instance).Config.Bind<bool>(new ConfigDefinition(sectionGeneral, "Enable"), true, new ConfigDescription("Wether or not to enable this mod. When changed while the game is running it will disable the ability to upgrade\nthe pickaxe but will not modify already upgraded ones. They will be reverted back to normal on next game start.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = HandleOrder() } })); configEnable.SettingChanged += delegate { if (!configEnable.Value) { UpgradeAntlerPickaxe.Instance.UnpatchStats(); Logger.LogWarning((object)"UpgradeAntlerPickaxe is now disabled! The Antler Pickaxe can no longer be upgraded"); } else { UpgradeAntlerPickaxe.Instance.PatchStats(); } }; configCraftingStation = ((BaseUnityPlugin)UpgradeAntlerPickaxe.Instance).Config.Bind<string>(new ConfigDefinition(sectionGeneral, "Crafting station"), "Workbench", new ConfigDescription("The crafting station the item can be created in", (AcceptableValueBase)(object)new AcceptableValueList<string>(craftingStationOptions), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = HandleOrder() } })); configCraftingStation.SettingChanged += delegate { UpgradeAntlerPickaxe.Instance.PatchRecipe(RecipeUpdateType.CraftingStation); }; configMinStationLevel = ((BaseUnityPlugin)UpgradeAntlerPickaxe.Instance).Config.Bind<int>(new ConfigDefinition(sectionGeneral, "Required station level"), 1, new ConfigDescription("The required station level to craft the item", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = HandleOrder() } })); configMinStationLevel.SettingChanged += delegate { UpgradeAntlerPickaxe.Instance.PatchRecipe(RecipeUpdateType.MinRequiredLevel); }; configRecipe = ((BaseUnityPlugin)UpgradeAntlerPickaxe.Instance).Config.Bind<string>(new ConfigDefinition(sectionGeneral, "Crafting costs"), "Wood:10,HardAntler:1", new ConfigDescription("The items required to craft the item", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = HandleOrder() } })); configRecipe.SettingChanged += delegate { UpgradeAntlerPickaxe.Instance.PatchRecipe(); }; configRecipeUpgrade = ((BaseUnityPlugin)UpgradeAntlerPickaxe.Instance).Config.Bind<string>(new ConfigDefinition(sectionGeneral, "Upgrade costs"), "Wood:4,HardAntler:1", new ConfigDescription("The costs to upgrade the item", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = HandleOrder() } })); configRecipeUpgrade.SettingChanged += delegate { UpgradeAntlerPickaxe.Instance.PatchRecipe(); }; ((BaseUnityPlugin)UpgradeAntlerPickaxe.Instance).Config.SaveOnConfigSet = true; configRecipeMultiplier = ((BaseUnityPlugin)UpgradeAntlerPickaxe.Instance).Config.Bind<int>(new ConfigDefinition(sectionGeneral, "Upgrade multiplier"), 1, new ConfigDescription("The multiplier applied to the upgrade costs", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = HandleOrder() } })); configRecipeMultiplier.SettingChanged += delegate { UpgradeAntlerPickaxe.Instance.PatchRecipe(); }; configWatcher = new FileSystemWatcher(Paths.ConfigPath, UpgradeAntlerPickaxe.configFileName); configWatcher.Changed += OnConfigFileChange; configWatcher.Created += OnConfigFileChange; configWatcher.Renamed += OnConfigFileChange; configWatcher.IncludeSubdirectories = true; configWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; configWatcher.EnableRaisingEvents = true; } catch (Exception ex) { Logger.LogError((object)("Something went wrong with initialising the config or config events: " + ex)); } } private static void OnConfigFileChange(object sender, FileSystemEventArgs e) { if (!File.Exists(UpgradeAntlerPickaxe.configFileFullPath)) { return; } try { ((BaseUnityPlugin)UpgradeAntlerPickaxe.Instance).Config.Reload(); } catch (Exception ex) { Logger.LogError((object)("Something went wrong while reloading the config, please check if the file exists and the entries are valid! " + ex)); } } private static int HandleOrder() { entryCount--; if (entryCount >= 0) { return entryCount; } return 0; } } }