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 MoreAltBiomes v1.0.0
MoreAltBiomes.dll
Decompiled 4 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("MoreAltBiomes")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Valheim mod to increase Alt Biome generation chances")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+495f870464a14ed16c436422dcad8a43907b7efc")] [assembly: AssemblyProduct("MoreAltBiomes")] [assembly: AssemblyTitle("MoreAltBiomes")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 MoreAltBiomes { [HarmonyPatch] public class Patches { public static Dictionary<string, ConfigEntry<float>> GranularChanceMultipliers = new Dictionary<string, ConfigEntry<float>>(); public static Dictionary<string, ConfigEntry<float>> GranularMaxAmountMultipliers = new Dictionary<string, ConfigEntry<float>>(); private static Dictionary<string, float> BackupChances = new Dictionary<string, float>(); private static Dictionary<string, int> BackupMaxAmounts = new Dictionary<string, int>(); public static void BindGranularConfigs(ConfigFile config, string biomeName) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown if (!GranularChanceMultipliers.ContainsKey(biomeName)) { GranularChanceMultipliers[biomeName] = config.Bind<float>("2 - Granular Chances", biomeName + " Chance Multiplier", 1f, new ConfigDescription("Multiplier specific to " + biomeName, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); GranularMaxAmountMultipliers[biomeName] = config.Bind<float>("3 - Granular Max Amounts", biomeName + " Max Amount Multiplier", 1f, new ConfigDescription("Max Amount multiplier specific to " + biomeName, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); } } [HarmonyPatch(typeof(AltBiomeList), "Awake")] [HarmonyPostfix] public static void AltBiomeList_Awake_Postfix() { if (AltBiomeList.m_altBiomes == null) { return; } foreach (AltBiome altBiome in AltBiomeList.m_altBiomes) { if (altBiome != null && !string.IsNullOrEmpty(altBiome.m_name)) { Plugin.Instance.BindDynamicConfig(altBiome.m_name); } } } [HarmonyPatch(typeof(FejdStartup), "Start")] [HarmonyPostfix] public static void FejdStartup_Start_Postfix() { ZoneSystem[] array = Resources.FindObjectsOfTypeAll<ZoneSystem>(); if (array == null) { return; } ZoneSystem[] array2 = array; foreach (ZoneSystem val in array2) { if (val.m_altBiomeLists == null) { continue; } foreach (AltBiomeList altBiomeList in val.m_altBiomeLists) { if (altBiomeList.m_alts == null) { continue; } foreach (AltBiome alt in altBiomeList.m_alts) { if (alt != null && !string.IsNullOrEmpty(alt.m_name)) { Plugin.Instance.BindDynamicConfig(alt.m_name); } } } } } [HarmonyPatch(typeof(AltBiomeWorldData), "GenerateAltBiomes")] [HarmonyPrefix] public static void AltBiomeWorldData_GenerateAltBiomes_Prefix() { BackupChances.Clear(); BackupMaxAmounts.Clear(); if (AltBiomeList.m_altBiomes == null) { return; } float value = Plugin.GlobalChanceMultiplier.Value; float value2 = Plugin.GlobalMaxAmountMultiplier.Value; foreach (AltBiome altBiome in AltBiomeList.m_altBiomes) { if (altBiome != null && !string.IsNullOrEmpty(altBiome.m_name)) { Plugin.Instance.BindDynamicConfig(altBiome.m_name); string name = altBiome.m_name; BackupChances[name] = altBiome.m_chance; BackupMaxAmounts[name] = altBiome.m_maxAmountSpawned; float num = (GranularChanceMultipliers.ContainsKey(name) ? GranularChanceMultipliers[name].Value : 1f); float num2 = (GranularMaxAmountMultipliers.ContainsKey(name) ? GranularMaxAmountMultipliers[name].Value : 1f); altBiome.m_chance = altBiome.m_chance * value * num; float num3 = (float)altBiome.m_maxAmountSpawned * value2 * num2; altBiome.m_maxAmountSpawned = Mathf.RoundToInt(num3); Plugin.Log.LogInfo((object)$"[MoreAltBiomes] Scaled {name} -> Chance: {altBiome.m_chance} (was {BackupChances[name]}), MaxAmount: {altBiome.m_maxAmountSpawned} (was {BackupMaxAmounts[name]})"); } } } [HarmonyPatch(typeof(AltBiomeWorldData), "GenerateAltBiomes")] [HarmonyPostfix] public static void AltBiomeWorldData_GenerateAltBiomes_Postfix() { if (AltBiomeList.m_altBiomes == null) { return; } foreach (AltBiome altBiome in AltBiomeList.m_altBiomes) { if (altBiome != null && !string.IsNullOrEmpty(altBiome.m_name)) { string name = altBiome.m_name; if (altBiome.Sectors != null && altBiome.Sectors.Count > 0) { Plugin.Log.LogInfo((object)$"[MoreAltBiomes] SUCCESS: Placed {altBiome.Sectors.Count} zones of '{name}'!"); } if (BackupChances.ContainsKey(name)) { altBiome.m_chance = BackupChances[name]; } if (BackupMaxAmounts.ContainsKey(name)) { altBiome.m_maxAmountSpawned = BackupMaxAmounts[name]; } } } Plugin.Log.LogInfo((object)"[MoreAltBiomes] Restored original AltBiome parameters."); } } [BepInPlugin("com.loathe.MoreAltBiomes", "More Alt Biomes", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "com.loathe.MoreAltBiomes"; public const string PluginName = "More Alt Biomes"; public const string PluginVersion = "1.0.0"; private readonly Harmony _harmony = new Harmony("com.loathe.MoreAltBiomes"); public static Plugin Instance; public static ConfigEntry<float> GlobalChanceMultiplier; public static ConfigEntry<float> GlobalMaxAmountMultiplier; public static ManualLogSource Log; private void Awake() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; GlobalChanceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Global", "Global Chance Multiplier", 2f, new ConfigDescription("Multiplies the chance for ALL alt biomes to spawn.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); GlobalMaxAmountMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Global", "Global Max Amount Multiplier", 2f, new ConfigDescription("Multiplies the max allowed spawned instances for ALL alt biomes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); string[] array = new string[32] { "Mushroom", "Lantern", "Bones", "Menhir", "Dark Meadows", "Peaceful Meadows", "Dandelion Meadows", "Raspberry Meadows", "Smalltree Meadows", "Birch Meadows", "Troll Black Forest", "Root Black Forest", "Ruin Black Forest", "Rock Black Forest", "Pinetree Black Forest", "Blueberry Black Forest", "Hut Swamp", "Bog Swamp", "Bat Swamp", "Abomination Swamp", "Wolf Mountain", "Drake Mountain", "Fortress Mountain", "Lox Plains", "Goblin Plains", "Death Plains", "Kalhygge Black Forest", "Rockless Mistlands", "Trees Mistlands", "Swords Mistlands", "Hare Mistlands", "BroodSwarm Mistlands" }; string[] array2 = array; foreach (string biomeName in array2) { BindDynamicConfig(biomeName); } if (File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath)) { string[] array3 = File.ReadAllLines(((BaseUnityPlugin)this).Config.ConfigFilePath); string[] array4 = array3; foreach (string text in array4) { if (!text.Contains("Chance Multiplier =") || text.Contains("Global Chance Multiplier")) { continue; } int num = text.IndexOf('='); if (num <= 0) { continue; } string text2 = text.Substring(0, num).Trim(); if (text2.EndsWith("Chance Multiplier")) { string text3 = text2.Replace(" Chance Multiplier", "").Trim(); if (!string.IsNullOrEmpty(text3)) { BindDynamicConfig(text3); } } } } _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.loathe.MoreAltBiomes is loaded!"); } public void BindDynamicConfig(string biomeName) { Patches.BindGranularConfigs(((BaseUnityPlugin)this).Config, biomeName); } } public static class PluginInfo { public const string PLUGIN_GUID = "MoreAltBiomes"; public const string PLUGIN_NAME = "MoreAltBiomes"; public const string PLUGIN_VERSION = "1.0.0"; } }