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 EnemyRarityConfig v1.0.1
LCEnemyConfig.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LCEnemyConfig")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LCEnemyConfig")] [assembly: AssemblyTitle("LCEnemyConfig")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 LCEnemyConfig { [BepInPlugin("local.enemyconfigmod", "Enemy Config Mod", "1.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("local.enemyconfigmod"); public static readonly Dictionary<string, string> EnemyDisplayNames = new Dictionary<string, string> { { "Puffer", "Spore Lizard" }, { "Stingray", "Backwater Gunkfish" }, { "Flowerman", "Bracken" }, { "Spring", "Coil-Head" }, { "Blob", "Hygrodere" }, { "Girl", "Ghost Girl" }, { "Crawler", "Thumper" }, { "MouthDog", "Eyeless Dog" }, { "ForestGiant", "Forest Keeper" }, { "RadMech", "Old Bird" }, { "Lasso", "Lasso Man" }, { "Bush Wolf", "Kidnapper Fox" }, { "GiantKiwi", "Giant Sapsucker" }, { "Clay Surgeon", "Barber" } }; public static Dictionary<string, Dictionary<string, ConfigEntry<int>>> EnemyRarities = new Dictionary<string, Dictionary<string, ConfigEntry<int>>>(); public static Dictionary<string, ConfigEntry<int>> WeedEnemyRarities = new Dictionary<string, ConfigEntry<int>>(); public static ConfigEntry<bool> DisableVainShrouds = null; public static ConfigEntry<bool> DisableButlerBees = null; public static Plugin Instance { get; private set; } = null; public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger; private void Awake() { Instance = this; DisableVainShrouds = ((BaseUnityPlugin)this).Config.Bind<bool>("VainShrouds", "DisableVainShrouds", false, "True = prevent Vain Shrouds and Kidnapper Fox from spawning."); DisableButlerBees = ((BaseUnityPlugin)this).Config.Bind<bool>("ButlerBees", "DisableButlerBees", false, "True = prevent Mask Hornets from spawning after Butler dies."); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"EnemyConfigMod loaded!"); } } [HarmonyPatch(typeof(RoundManager), "SpawnEnemyGameObject")] public class SpawnEnemyGameObjectPatch { private static bool Prefix(Vector3 spawnPosition, float yRot, int enemyNumber, EnemyType enemyType) { if (Plugin.DisableButlerBees.Value && (Object)(object)enemyType != (Object)null && enemyType.enemyName == "Butler Bees") { Plugin.Log.LogInfo((object)"Mask Hornets (Butler Bees) spawn removed by config."); return false; } return true; } } [HarmonyPatch(typeof(MoldSpreadManager), "GenerateMold")] public class MoldSpreadManagerPatch { private static bool Prefix() { if (Plugin.DisableVainShrouds.Value) { Plugin.Log.LogInfo((object)"Vain Shroud generation removed by config."); return false; } return true; } } [HarmonyPatch(typeof(StartOfRound), "Start")] public class StartOfRoundPatch { private static void Postfix(StartOfRound __instance) { int num = 0; SelectableLevel[] levels = __instance.levels; foreach (SelectableLevel val in levels) { if ((Object)(object)val == (Object)null) { continue; } string planetName = val.PlanetName; if (!Plugin.EnemyRarities.ContainsKey(planetName)) { Plugin.EnemyRarities[planetName] = new Dictionary<string, ConfigEntry<int>>(); } List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>(); list.AddRange(val.Enemies); list.AddRange(val.OutsideEnemies); list.AddRange(val.DaytimeEnemies); foreach (SpawnableEnemyWithRarity item in list) { if (item?.enemyType?.enemyName != null) { string enemyName = item.enemyType.enemyName; if (!Plugin.EnemyRarities[planetName].ContainsKey(enemyName)) { string value; string text = (Plugin.EnemyDisplayNames.TryGetValue(enemyName, out value) ? value : enemyName); ConfigEntry<int> value2 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<int>(planetName, enemyName, item.rarity, $"Rarity for {text} ({enemyName}) on {planetName}. 0 = never spawn. Vanilla default: {item.rarity}"); Plugin.EnemyRarities[planetName][enemyName] = value2; num++; } } } } Plugin.Log.LogInfo((object)$"EnemyConfigMod: found {num} entries across all moons."); } } [HarmonyPatch(typeof(RoundManager), "Start")] public class RoundManagerStartPatch { private static void Postfix(RoundManager __instance) { foreach (SpawnableEnemyWithRarity weedEnemy in __instance.WeedEnemies) { if (weedEnemy?.enemyType?.enemyName != null) { string enemyName = weedEnemy.enemyType.enemyName; if (!Plugin.WeedEnemyRarities.ContainsKey(enemyName)) { string value; string arg = (Plugin.EnemyDisplayNames.TryGetValue(enemyName, out value) ? value : enemyName); ConfigEntry<int> value2 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<int>("WeedEnemies", enemyName, weedEnemy.rarity, $"Rarity for {arg} ({enemyName}). 0 = never spawn. Vanilla default: {weedEnemy.rarity}"); Plugin.WeedEnemyRarities[enemyName] = value2; Plugin.Log.LogInfo((object)("Found weed enemy: " + enemyName)); } } } } } [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] public class RoundManagerPatch { private static void Prefix(int randomSeed, SelectableLevel newLevel) { string planetName = newLevel.PlanetName; if (!Plugin.EnemyRarities.TryGetValue(planetName, out Dictionary<string, ConfigEntry<int>> value)) { Plugin.Log.LogWarning((object)("Moon " + planetName + " not found in config!")); return; } List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>(); list.AddRange(newLevel.Enemies); list.AddRange(newLevel.OutsideEnemies); list.AddRange(newLevel.DaytimeEnemies); foreach (SpawnableEnemyWithRarity item in list) { if (item?.enemyType?.enemyName != null) { string enemyName = item.enemyType.enemyName; if (value.TryGetValue(enemyName, out var value2)) { item.rarity = value2.Value; } } } foreach (SpawnableEnemyWithRarity weedEnemy in RoundManager.Instance.WeedEnemies) { if (weedEnemy?.enemyType?.enemyName != null) { string enemyName2 = weedEnemy.enemyType.enemyName; if (Plugin.WeedEnemyRarities.TryGetValue(enemyName2, out ConfigEntry<int> value3)) { weedEnemy.rarity = value3.Value; } } } } } }