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 ZorzMoreOres v0.1.2
ZorzMoreOres.dll
Decompiled 2 years agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using ModGeneratorNS; using ModVarsNS; 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("vmod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("vmod")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("19bcdcbc-06a2-4481-bc19-97c6812b7e41")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace ModGeneratorNS { public static class OreGenerator { public static void ProcessRock(Vector3 hitPoint, string weapon, Biome biome) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0215: 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_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) bool flag = !Mod.dropOneType.Value; Mod.logger.LogInfo((object)("Pickaxe " + weapon)); uint num = Mod.tinChance.Value; uint num2 = Mod.copperChance.Value; uint num3 = Mod.ironChance.Value; uint num4 = Mod.silverChance.Value; uint num5 = Mod.blackmetalChance.Value; if (Mod.dropFromSkillLevel.Value) { num = Mod.PASkillLevel; num2 = Mod.PASkillLevel; num3 = Mod.PASkillLevel; num4 = Mod.PASkillLevel; num5 = Mod.PASkillLevel; } if (Mod.silverDropEnabled.Value && weapon == "PickaxeSilver" && IsValidBiome(biome, "SilverOre") && IsLucky(num4)) { uint num6 = (uint)Random.Range(1, (int)Mod.silverMaxAmount.Value); Mod.logger.LogInfo((object)$"What a luck! got {num6} SilverOre Chance = {num4}"); Drop("SilverOre", num6, hitPoint); if (!flag) { return; } } if (Mod.ironDropEnabled.Value && weapon == "PickaxeIron" && IsValidBiome(biome, "IronScrap") && IsLucky(num3)) { uint num7 = (uint)Random.Range(1, (int)Mod.ironMaxAmount.Value); Mod.logger.LogInfo((object)$"What a luck! got {num7} IronScrap Chance = {num3}"); Drop("IronScrap", num7, hitPoint); if (!flag) { return; } } if (Mod.copperDropEnabled.Value && weapon == "PickaxeBronze" && IsValidBiome(biome, "CopperOre") && IsLucky(num2)) { uint num8 = (uint)Random.Range(1, (int)Mod.copperMaxAmount.Value); Mod.logger.LogInfo((object)$"What a luck! got {num8} CopperOre Chance = {num2}"); Drop("CopperOre", num8, hitPoint); if (!flag) { return; } } if (Mod.tinDropEnabled.Value && weapon == "PickaxeAntler" && IsValidBiome(biome, "TinOre") && IsLucky(num)) { uint num9 = (uint)Random.Range(1, (int)Mod.tinMaxAmount.Value); Mod.logger.LogInfo((object)$"What a luck! got {num9} TinOre Chance = {num}"); Drop("TinOre", num9, hitPoint); if (!flag) { return; } } if (Mod.blackmetalDropEnabled.Value && weapon == "PickaxeBlackMetal" && IsValidBiome(biome, "BlackMetalScrap") && IsLucky(num5)) { uint num10 = (uint)Random.Range(1, (int)Mod.blackmetalMaxAmount.Value); Mod.logger.LogInfo((object)$"What a luck! got {num10} BlackMetalScrap Chance = {num5}"); Drop("BlackMetalScrap", num10, hitPoint); if (!flag) { return; } } if (Mod.obsidianDropEnabled.Value && IsValidBiome(biome, "Obsidian") && IsLucky(Mod.obsidianChance.Value)) { uint num11 = (uint)Random.Range(1, (int)Mod.obsidianMaxAmount.Value); Mod.logger.LogInfo((object)$"What a luck! got {num11} Obsidian - Chance = {Mod.obsidianChance.Value}"); Drop("Obsidian", num11, hitPoint); if (!flag) { return; } } if (Mod.coalDropEnabled.Value && IsValidBiome(biome, "Coal") && IsLucky(Mod.coalChance.Value)) { uint num12 = (uint)Random.Range(1, (int)Mod.coalMaxAmount.Value); Mod.logger.LogInfo((object)$"What a luck! got {num12} Coal"); Drop("Coal", num12, hitPoint); } } internal static bool IsValidBiome(Biome biome, string dropCode) { if (Mod.dropEverywhere.Value) { return true; } return true; } internal static void Drop(string oreName, uint amount, Vector3 hitPoint) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < amount; i++) { Vector3 val = hitPoint + Random.insideUnitSphere * 0.3f; Object.Instantiate<GameObject>(ObjectDB.instance.GetItemPrefab(oreName), val, Quaternion.identity); } } internal static bool IsLucky(uint chance) { int num = Random.Range(0, 100); Mod.logger.LogInfo((object)$"Roll Results = {num} out of 100"); return chance > num; } } } namespace ModItemsNS { internal static class ItemNames { internal const string TinOre = "TinOre"; internal const string CopperOre = "CopperOre"; internal const string SilverOre = "SilverOre"; internal const string Coal = "Coal"; internal const string IronScrap = "IronScrap"; internal const string Obsidian = "Obsidian"; internal const string BlackMetal = "BlackMetalScrap"; } [HarmonyPatch(typeof(MineRock5), "DamageArea")] public class MineRock5Patch { private static void Postfix(ref HitData hit, bool __result) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f); if (!((Object)(object)closestPlayer == (Object)null)) { Biome currentBiome = closestPlayer.GetCurrentBiome(); Mod.logger.LogInfo((object)$"biome : {currentBiome}"); float skillFactor = ((Character)closestPlayer).GetSkillFactor((SkillType)12); Mod.PASkillLevel = (uint)Mathf.Floor(skillFactor * 100f); Mod.logger.LogInfo((object)$"skill level : {Mod.PASkillLevel}"); ItemData currentWeapon = ((Humanoid)closestPlayer).GetCurrentWeapon(); if (!((Object)(object)currentWeapon?.m_dropPrefab == (Object)null) && __result) { OreGenerator.ProcessRock(hit.m_point, ((Object)currentWeapon.m_dropPrefab).name, currentBiome); } } } } [HarmonyPatch(typeof(Destructible), "Destroy")] public class DestructiblePatch { private static void Postfix(Destructible __instance, HitData hit) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = hit?.m_point ?? Vector3.zero; Vector3 val2 = hit?.m_dir ?? Vector3.zero; Mod.logger.LogInfo((object)$"something destroyed : {__instance}"); string text = ((object)__instance).ToString(); if (!(text == "Rock_4(Clone) (Destructible)") && !(text == "Rock_7(Clone) (Destructible)") && !(text == "Rock_4_plains(Clone) (Destructible)")) { return; } Mod.logger.LogInfo((object)$"a rock has destroyed : {__instance}"); Player closestPlayer = Player.GetClosestPlayer(val, 10f); if (!((Object)(object)closestPlayer == (Object)null)) { Biome currentBiome = closestPlayer.GetCurrentBiome(); Mod.logger.LogInfo((object)$"biome : {currentBiome}"); float skillFactor = ((Character)closestPlayer).GetSkillFactor((SkillType)12); Mod.PASkillLevel = (uint)Mathf.Floor(skillFactor * 100f); Mod.logger.LogInfo((object)$"skill level : {Mod.PASkillLevel}"); ItemData currentWeapon = ((Humanoid)closestPlayer).GetCurrentWeapon(); if (!((Object)(object)currentWeapon?.m_dropPrefab == (Object)null)) { OreGenerator.ProcessRock(val, ((Object)currentWeapon.m_dropPrefab).name, currentBiome); } } } } } namespace ModAttacksNS { [HarmonyPatch(typeof(Attack))] public class AttackPatch { [HarmonyPostfix] [HarmonyPatch("SpawnOnHitTerrain")] private static void SpawnOnHitTerrainPostfix(Attack __instance, ref Vector3 hitPoint, ref GameObject prefab) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (Mod.dropFromTerrain.Value && ((Object)prefab).name == "digg") { Player closestPlayer = Player.GetClosestPlayer(hitPoint, 10f); ItemData currentWeapon = ((Humanoid)closestPlayer).GetCurrentWeapon(); Biome currentBiome = closestPlayer.GetCurrentBiome(); Mod.logger.LogInfo((object)$"biome : {currentBiome}"); if (!((Object)(object)currentWeapon?.m_dropPrefab == (Object)null)) { OreGenerator.ProcessRock(hitPoint, ((Object)currentWeapon.m_dropPrefab).name, currentBiome); } } } } } namespace ModVarsNS { [BepInPlugin("Zorz.MoreOre", "Zorz More Ore", "1.2.0")] [BepInProcess("valheim.exe")] public class Mod : BaseUnityPlugin { internal static ConfigEntry<bool> copperDropEnabled; internal static ConfigEntry<uint> copperChance; internal static ConfigEntry<uint> copperMaxAmount; internal static ConfigEntry<bool> ironDropEnabled; internal static ConfigEntry<uint> ironMaxAmount; internal static ConfigEntry<uint> ironChance; internal static ConfigEntry<bool> tinDropEnabled; internal static ConfigEntry<uint> tinMaxAmount; internal static ConfigEntry<uint> tinChance; internal static ConfigEntry<bool> coalDropEnabled; internal static ConfigEntry<uint> coalMaxAmount; internal static ConfigEntry<uint> coalChance; internal static ConfigEntry<bool> blackmetalDropEnabled; internal static ConfigEntry<uint> blackmetalMaxAmount; internal static ConfigEntry<uint> blackmetalChance; internal static ConfigEntry<bool> silverDropEnabled; internal static ConfigEntry<uint> silverMaxAmount; internal static ConfigEntry<uint> silverChance; internal static ConfigEntry<bool> obsidianDropEnabled; internal static ConfigEntry<uint> obsidianMaxAmount; internal static ConfigEntry<uint> obsidianChance; internal static ConfigEntry<bool> dropOneType; internal static ConfigEntry<bool> dropFromTerrain; internal static ConfigEntry<bool> dropEverywhere; internal static uint PASkillLevel; internal static ConfigEntry<bool> dropFromSkillLevel; public static ManualLogSource logger = Logger.CreateLogSource("Zorz Mod"); private readonly Harmony harmony = new Harmony("Zorz.MoreOre"); private void Awake() { dropOneType = ((BaseUnityPlugin)this).Config.Bind<bool>("_General", "DropOneType", false, "If true, within one hit only drops one type of ore. Default is false"); dropFromTerrain = ((BaseUnityPlugin)this).Config.Bind<bool>("_General", "DropFromTerrain", false, "If true, drop a resource from a terrain. Default is false"); dropEverywhere = ((BaseUnityPlugin)this).Config.Bind<bool>("_General", "DropEverywhere", true, "If true, allows all ores to drop in any biome based on axe used, otherwise rocks will only drop ore in their origin biome. Default is true"); dropFromSkillLevel = ((BaseUnityPlugin)this).Config.Bind<bool>("_General", "DropFromSkill", true, "Uses pickaxe skill to determine drop chance otherwise uses manual chance set below. Default is True"); tinDropEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("TinDrop", "Enabled", true, "Determines whether or not the tin Drop is enabled."); tinChance = ((BaseUnityPlugin)this).Config.Bind<uint>("TinDrop", "Chance", 50u, "Determines a drop chance of tin in %. From 0 to 100. Default is 50%"); tinMaxAmount = ((BaseUnityPlugin)this).Config.Bind<uint>("TinDrop", "MaxAmount", 1u, "Determines max amount of dropped tin. Default is 1"); copperDropEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("CopperDrop", "Enabled", true, "Determines whether or not the Copper Drop is enabled."); copperChance = ((BaseUnityPlugin)this).Config.Bind<uint>("CopperDrop", "Chance", 45u, "Determines a drop chance of copper in %. From 0 to 100. Default is 45%"); copperMaxAmount = ((BaseUnityPlugin)this).Config.Bind<uint>("CopperDrop", "MaxAmount", 1u, "Determines max amount of dropped copper. Default is 1"); ironDropEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("IronDrop", "Enabled", true, "Determines whether or not the iron Drop is enabled."); ironChance = ((BaseUnityPlugin)this).Config.Bind<uint>("IronDrop", "Chance", 40u, "Determines a drop chance of iron in %. From 0 to 100. Default is 40%"); ironMaxAmount = ((BaseUnityPlugin)this).Config.Bind<uint>("IronDrop", "MaxAmount", 1u, "Determines max amount of dropped iron. Default is 1"); silverDropEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("SilverDrop", "Enabled", true, "Determines whether or not the silver Drop is enabled."); silverChance = ((BaseUnityPlugin)this).Config.Bind<uint>("SilverDrop", "Chance", 35u, "Determines a drop chance of silver in %. From 0 to 100. Default is 35%"); silverMaxAmount = ((BaseUnityPlugin)this).Config.Bind<uint>("SilverDrop", "MaxAmount", 1u, "Determines max amount of dropped silver. Default is 1"); blackmetalDropEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("BlackMetalDrop", "Enabled", true, "Determines whether or not the blackmetal Drop is enabled."); blackmetalChance = ((BaseUnityPlugin)this).Config.Bind<uint>("BlackMetalDrop", "Chance", 30u, "Determines a drop chance of blackmetal in %. From 0 to 100. Default is 30"); blackmetalMaxAmount = ((BaseUnityPlugin)this).Config.Bind<uint>("BlackMetalDrop", "MaxAmount", 1u, "Determines max amount of dropped blackmetal. Default is 1"); coalDropEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("xtra items - CoalDrop", "Enabled", false, "Determines whether or not the coal Drop is enabled."); coalChance = ((BaseUnityPlugin)this).Config.Bind<uint>("xtra items - CoalDrop", "Chance", 20u, "Determines a drop chance of coal in %. From 0 to 100. Default is 20%"); coalMaxAmount = ((BaseUnityPlugin)this).Config.Bind<uint>("xtra items - CoalDrop", "MaxAmount", 2u, "Determines max amount of dropped coal. Default is 2"); obsidianDropEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("xtra items - ObsidianDrop", "Enabled", false, "Determines whether or not the Obsidian Drop is enabled."); obsidianChance = ((BaseUnityPlugin)this).Config.Bind<uint>("xtra items - ObsidianDrop", "Chance", 20u, "Determines a drop chance of Obsidian in %. From 0 to 100. Default is 20%"); obsidianMaxAmount = ((BaseUnityPlugin)this).Config.Bind<uint>("xtra items - ObsidianDrop", "MaxAmount", 2u, "Determines max amount of dropped Obsidian. Default is 2"); harmony.PatchAll(); logger.LogInfo((object)"loaded."); PrefabManager.OnVanillaPrefabsAvailable += AddClonedItems; PrefabManager.OnPrefabsRegistered += delegate { GameObject prefab = PrefabManager.Instance.GetPrefab("PickaxeSilver"); if ((Object)(object)prefab != (Object)null) { prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_damages.m_pickaxe = 40f; prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_damages.m_pierce = 40f; prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 12f; prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxDurability = 175f; prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality = 4; prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_deflectionForce = 20f; prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_damagesPerLevel.m_pickaxe = 5f; prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_damagesPerLevel.m_pierce = 5f; prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_deflectionForcePerLevel = 5f; } }; } private void AddClonedItems() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown ItemConfig val = new ItemConfig(); val.Name = "Silver pickaxe"; val.Description = "Has a chance mine Silver from Rocks"; val.CraftingStation = "forge"; val.AddRequirement(new RequirementConfig("Silver", 20, 10, false)); val.AddRequirement(new RequirementConfig("FineWood", 5, 2, false)); CustomItem val2 = new CustomItem("PickaxeSilver", "PickaxeStone", val); ItemManager.Instance.AddItem(val2); PrefabManager.OnVanillaPrefabsAvailable -= AddClonedItems; } } }