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 JSB ValheimSpawnCustomizer v1.1.0
JSB ValheimSpawnCustomizer.dll
Decompiled 16 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("JSB ValheimSpawnCustomizer")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("JSB ValheimSpawnCustomizer")] [assembly: AssemblyTitle("JSB ValheimSpawnCustomizer")] [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 ValheimSpawnCustomizer { [HarmonyPatch(typeof(SpawnSystem), "Awake")] public static class SpawnSystem_Awake_Patch { public static void Postfix(SpawnSystem __instance) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) List<SpawnSystemList> spawnLists = __instance.m_spawnLists; if (spawnLists == null) { return; } foreach (SpawnSystemList item in spawnLists) { if ((Object)(object)item == (Object)null || item.m_spawners == null) { continue; } foreach (SpawnData spawner in item.m_spawners) { if (spawner != null && !((Object)(object)spawner.m_prefab == (Object)null)) { string name = ((Object)spawner.m_prefab).name; string d = "Both"; if (spawner.m_spawnAtDay && !spawner.m_spawnAtNight) { d = "Day"; } if (!spawner.m_spawnAtDay && spawner.m_spawnAtNight) { d = "Night"; } string biomeString = GetBiomeString(spawner.m_biome); if (!SpawnCustomizerMod.SpawnChanceConfigs.ContainsKey(name)) { SpawnCustomizerMod.SpawnChanceConfigs[name] = TomlTypeBinders.BindSpawnChance(name, spawner.m_spawnChance); SpawnCustomizerMod.MaxSpawnedConfigs[name] = TomlTypeBinders.BindMaxSpawned(name, spawner.m_maxSpawned); SpawnCustomizerMod.GroupSizeMinConfigs[name] = TomlTypeBinders.BindGroupSizeMin(name, spawner.m_groupSizeMin); SpawnCustomizerMod.GroupSizeMaxConfigs[name] = TomlTypeBinders.BindGroupSizeMax(name, spawner.m_groupSizeMax); SpawnCustomizerMod.LevelUpChanceConfigs[name] = TomlTypeBinders.BindLevelUpChance(name, 10f); SpawnCustomizerMod.SpawnTimeConfigs[name] = TomlTypeBinders.BindSpawnTime(name, d); SpawnCustomizerMod.SpawnBiomesConfigs[name] = TomlTypeBinders.BindSpawnBiomes(name, biomeString); } spawner.m_spawnChance = SpawnCustomizerMod.SpawnChanceConfigs[name].Value; spawner.m_maxSpawned = SpawnCustomizerMod.MaxSpawnedConfigs[name].Value; spawner.m_groupSizeMin = SpawnCustomizerMod.GroupSizeMinConfigs[name].Value; spawner.m_groupSizeMax = SpawnCustomizerMod.GroupSizeMaxConfigs[name].Value; string a = SpawnCustomizerMod.SpawnTimeConfigs[name].Value.Trim(); if (string.Equals(a, "Day", StringComparison.OrdinalIgnoreCase)) { spawner.m_spawnAtDay = true; spawner.m_spawnAtNight = false; } else if (string.Equals(a, "Night", StringComparison.OrdinalIgnoreCase)) { spawner.m_spawnAtDay = false; spawner.m_spawnAtNight = true; } else { spawner.m_spawnAtDay = true; spawner.m_spawnAtNight = true; } spawner.m_biome = ParseBiomeString(SpawnCustomizerMod.SpawnBiomesConfigs[name].Value); } } } } private static string GetBiomeString(Biome biomeMask) { //IL_0000: 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_0031: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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) if ((int)biomeMask == 0) { return "None"; } List<string> list = new List<string>(); foreach (Biome value in Enum.GetValues(typeof(Biome))) { if ((int)value != 0 && (int)value != 895 && (biomeMask & value) != 0) { list.Add(((object)value/*cast due to .constrained prefix*/).ToString()); } } if (list.Count <= 0) { return "Meadows"; } return string.Join(", ", list); } private static Biome ParseBiomeString(string input) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Biome val = (Biome)0; string[] array = input.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { if (Enum.TryParse<Biome>(array[i].Trim(), ignoreCase: true, out Biome result)) { val |= result; } } return val; } } [HarmonyPatch(typeof(Character), "Awake")] public static class Character_Awake_Patch { public static void Postfix(Character __instance) { if (__instance.IsPlayer() || __instance.IsTamed()) { return; } string key = ((Object)((Component)__instance).gameObject).name.Replace("(Clone)", "").Trim(); if (!SpawnCustomizerMod.LevelUpChanceConfigs.TryGetValue(key, out var value)) { return; } float value2 = value.Value; if (Random.Range(0f, 100f) < value2) { int level = 2; if (Random.Range(0f, 100f) < value2) { level = 3; } __instance.SetLevel(level); } } } public static class TomlTypeBinders { public static ConfigEntry<float> BindSpawnChance(string c, float d) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown return SpawnCustomizerMod.CustomConfig.Bind<float>("Creature - " + c, "SpawnChance", d, new ConfigDescription("Spawn chance % for " + c + ".", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); } public static ConfigEntry<int> BindMaxSpawned(string c, int d) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown return SpawnCustomizerMod.CustomConfig.Bind<int>("Creature - " + c, "MaxSpawned", d, new ConfigDescription("Max counts of " + c + " allowed.", (AcceptableValueBase)null, Array.Empty<object>())); } public static ConfigEntry<float> BindLevelUpChance(string c, float d) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown return SpawnCustomizerMod.CustomConfig.Bind<float>("Creature - " + c, "LevelUpChance", d, new ConfigDescription("Star upgrade percentage for " + c + ".", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())); } public static ConfigEntry<int> BindGroupSizeMin(string c, int d) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown return SpawnCustomizerMod.CustomConfig.Bind<int>("Creature - " + c, "GroupSizeMin", d, new ConfigDescription("Minimum group cluster size for " + c + ".", (AcceptableValueBase)null, Array.Empty<object>())); } public static ConfigEntry<int> BindGroupSizeMax(string c, int d) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown return SpawnCustomizerMod.CustomConfig.Bind<int>("Creature - " + c, "GroupSizeMax", d, new ConfigDescription("Maximum group cluster size for " + c + ".", (AcceptableValueBase)null, Array.Empty<object>())); } public static ConfigEntry<string> BindSpawnTime(string c, string d) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown return SpawnCustomizerMod.CustomConfig.Bind<string>("Creature - " + c, "SpawnTime", d, new ConfigDescription("Time allowed to spawn.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Day", "Night", "Both" }), Array.Empty<object>())); } public static ConfigEntry<string> BindSpawnBiomes(string c, string d) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown return SpawnCustomizerMod.CustomConfig.Bind<string>("Creature - " + c, "SpawnBiomes", d, new ConfigDescription("Comma-separated biomes. Choices: Meadows, BlackForest, Swamp, Mountain, Plains, Ocean, AshLands, DeepNorth, Mistlands", (AcceptableValueBase)null, Array.Empty<object>())); } } [BepInPlugin("com.jacob.valheimspawncustomizer", "ValheimSpawnCustomizer", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class SpawnCustomizerMod : BaseUnityPlugin { public const string ModGUID = "com.jacob.valheimspawncustomizer"; public const string ModName = "ValheimSpawnCustomizer"; public const string ModVersion = "1.0.0"; private static Harmony harmony; public static ConfigFile CustomConfig; public static readonly Dictionary<string, ConfigEntry<float>> SpawnChanceConfigs = new Dictionary<string, ConfigEntry<float>>(); public static readonly Dictionary<string, ConfigEntry<int>> MaxSpawnedConfigs = new Dictionary<string, ConfigEntry<int>>(); public static readonly Dictionary<string, ConfigEntry<float>> LevelUpChanceConfigs = new Dictionary<string, ConfigEntry<float>>(); public static readonly Dictionary<string, ConfigEntry<int>> GroupSizeMinConfigs = new Dictionary<string, ConfigEntry<int>>(); public static readonly Dictionary<string, ConfigEntry<int>> GroupSizeMaxConfigs = new Dictionary<string, ConfigEntry<int>>(); public static readonly Dictionary<string, ConfigEntry<string>> SpawnTimeConfigs = new Dictionary<string, ConfigEntry<string>>(); public static readonly Dictionary<string, ConfigEntry<string>> SpawnBiomesConfigs = new Dictionary<string, ConfigEntry<string>>(); private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown CustomConfig = ((BaseUnityPlugin)this).Config; harmony = new Harmony("com.jacob.valheimspawncustomizer"); harmony.PatchAll(); Logger.LogInfo((object)"ValheimSpawnCustomizer v1.0.0 loaded successfully."); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } }