using 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 EnemyDisplayNames = new Dictionary { { "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>> EnemyRarities = new Dictionary>>(); public static Dictionary> WeedEnemyRarities = new Dictionary>(); public static ConfigEntry DisableVainShrouds = null; public static ConfigEntry 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("VainShrouds", "DisableVainShrouds", false, "True = prevent Vain Shrouds and Kidnapper Fox from spawning."); DisableButlerBees = ((BaseUnityPlugin)this).Config.Bind("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>(); } List list = new List(); 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 value2 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind(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 value2 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind("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> value)) { Plugin.Log.LogWarning((object)("Moon " + planetName + " not found in config!")); return; } List list = new List(); 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 value3)) { weedEnemy.rarity = value3.Value; } } } } } }