using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; 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("MoyaGzLimitedSpawns")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MoyaGzLimitedSpawns")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("3f076f84-0324-4380-925d-9e11e2deb2cd")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace MoyaGzLimitedSpawns; [BepInPlugin("com.MoyaGz.repo.limitedspawns", "Limited Spawns Mod", "1.0.0")] public class LimitedSpawnsPlugin : BaseUnityPlugin { public static ConfigEntry ModEnabled; public static ConfigEntry MaxSpawns; public static ConfigEntry DespawnTimer; public static Dictionary EnemySpawnCounts { get; } = new Dictionary(); private void Awake() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) ModEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enable Mod", true, "Enables or disables the spawn limit."); MaxSpawns = ((BaseUnityPlugin)this).Config.Bind("Enemy Settings", "Spawn Limit", 3, new ConfigDescription("Maximum number of times an enemy can spawn.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 10), Array.Empty())); DespawnTimer = ((BaseUnityPlugin)this).Config.Bind("Enemy Settings", "Despawn Timer", 36000f, new ConfigDescription("Timer applied when the spawn limit is reached (in seconds).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 36000f), Array.Empty())); new Harmony("com.MoyaGz.repo.limitedspawns").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Limited Spawns Mod loaded with config!"); } } [HarmonyPatch(typeof(EnemyParent), "Spawn")] public class EnemySpawnPatch { private static bool Prefix(EnemyParent __instance) { if (!LimitedSpawnsPlugin.ModEnabled.Value) { return true; } string key = (string.IsNullOrEmpty(__instance.enemyName) ? "Unknown" : __instance.enemyName); if (!LimitedSpawnsPlugin.EnemySpawnCounts.TryGetValue(key, out var value)) { value = 0; } if (value >= LimitedSpawnsPlugin.MaxSpawns.Value) { __instance.DespawnedTimer = LimitedSpawnsPlugin.DespawnTimer.Value; return false; } return true; } private static void Postfix(EnemyParent __instance) { if (LimitedSpawnsPlugin.ModEnabled.Value) { string key = (string.IsNullOrEmpty(__instance.enemyName) ? "Unknown" : __instance.enemyName); if (!LimitedSpawnsPlugin.EnemySpawnCounts.ContainsKey(key)) { LimitedSpawnsPlugin.EnemySpawnCounts[key] = 0; } LimitedSpawnsPlugin.EnemySpawnCounts[key]++; } } } [HarmonyPatch(typeof(RoundDirector), "Awake")] public class RoundStartPatch { private static void Postfix() { LimitedSpawnsPlugin.EnemySpawnCounts.Clear(); Debug.Log((object)"[LimitedSpawns] Counters reset for the new round."); } }