using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dungeonator;
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("RandomEnemies")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RandomEnemies")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3384046e-0a30-4d9f-aac1-44984c055a06")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RandomEnemies;
[BepInPlugin("you.etg.randomenemies", "Random Enemies", "1.3.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RandomEnemiesPlugin : BaseUnityPlugin
{
public static ConfigEntry<bool> IncludeBosses;
public static ConfigEntry<bool> DebugLogging;
public static ConfigEntry<bool> DumpPool;
public static ConfigEntry<string> ExtraBlacklist;
public static ConfigEntry<bool> EnableMultiplier;
public static ConfigEntry<int> MultKeep;
public static ConfigEntry<int> MultProper;
public static ConfigEntry<int> MultMines;
public static ConfigEntry<int> MultHollow;
public static ConfigEntry<int> MultForge;
public static ConfigEntry<int> MultHell;
public static ManualLogSource Log;
private void Awake()
{
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Expected O, but got Unknown
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"[RE] Awake called, plugin is loading");
IncludeBosses = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "IncludeBosses", false, "If true, real bosses can appear as random replacements (mini-bosses never do).");
ExtraBlacklist = ((BaseUnityPlugin)this).Config.Bind<string>("Filter", "ExtraBlacklist", "", "Comma-separated enemy names or GUIDs that are never randomised or used as replacements.");
EnableMultiplier = ((BaseUnityPlugin)this).Config.Bind<bool>("Multiplier", "Enable", true, "Spawn extra random enemies depending on the floor.");
MultKeep = ((BaseUnityPlugin)this).Config.Bind<int>("Multiplier", "KeepOfTheLeadLord", 1, "Total enemies per enemy (1 = no extras).");
MultProper = ((BaseUnityPlugin)this).Config.Bind<int>("Multiplier", "GungeonProper", 2, "Total enemies per enemy.");
MultMines = ((BaseUnityPlugin)this).Config.Bind<int>("Multiplier", "BlackPowderMine", 3, "Total enemies per enemy.");
MultHollow = ((BaseUnityPlugin)this).Config.Bind<int>("Multiplier", "Hollow", 4, "Total enemies per enemy.");
MultForge = ((BaseUnityPlugin)this).Config.Bind<int>("Multiplier", "Forge", 5, "Total enemies per enemy.");
MultHell = ((BaseUnityPlugin)this).Config.Bind<int>("Multiplier", "BulletHell", 10, "Total enemies per enemy.");
DebugLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DebugLogging", true, "Log every swap and the first skipped lookups. Turn off when everything works.");
DumpPool = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DumpPool", false, "On first spawn, log every excluded enemy with the reason (causes a short freeze once).");
IncludeBosses.SettingChanged += delegate
{
GuidLookupPatch.ResetList();
};
ExtraBlacklist.SettingChanged += delegate
{
GuidLookupPatch.ResetList();
};
try
{
Harmony val = new Harmony("you.etg.randomenemies");
val.PatchAll();
try
{
MethodInfo methodInfo = AccessTools.Method(typeof(AIActor), "Start", (Type[])null, (Type[])null);
if ((object)methodInfo == null)
{
Log.LogError((object)"[RE] AIActor.Start not found, multiplier disabled");
}
else
{
val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(MultiplierPatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
catch (Exception ex)
{
Log.LogError((object)("[RE] Multiplier patch FAILED: " + ex));
}
int num = 0;
foreach (MethodBase patchedMethod in val.GetPatchedMethods())
{
num++;
Log.LogInfo((object)("[RE] Patched: " + patchedMethod.DeclaringType.Name + "." + patchedMethod.Name));
}
if (num == 0)
{
Log.LogError((object)"[RE] NOTHING was patched!");
}
}
catch (Exception ex2)
{
Log.LogError((object)("[RE] Patching FAILED: " + ex2));
}
Log.LogInfo((object)("[RE] Awake finished. IncludeBosses=" + IncludeBosses.Value));
}
private void Update()
{
if (!Input.GetKeyDown((KeyCode)289) && !Input.GetKeyDown((KeyCode)290))
{
return;
}
try
{
PlayerController primaryPlayer = GameManager.Instance.PrimaryPlayer;
RoomHandler val = (((Object)(object)primaryPlayer != (Object)null) ? primaryPlayer.CurrentRoom : null);
if (val == null)
{
Log.LogInfo((object)"[RE] No current room");
return;
}
List<AIActor> activeEnemies = val.GetActiveEnemies((ActiveEnemyType)0);
if (activeEnemies == null)
{
return;
}
bool keyDown = Input.GetKeyDown((KeyCode)290);
Log.LogInfo((object)("[RE] --- Enemies in room: " + activeEnemies.Count + " ---"));
AIActor[] array = activeEnemies.ToArray();
foreach (AIActor val2 in array)
{
if (!((Object)(object)val2 == (Object)null))
{
Renderer componentInChildren = ((Component)val2).GetComponentInChildren<Renderer>();
bool flag = (Object)(object)componentInChildren != (Object)null && componentInChildren.enabled;
float num = (((Object)(object)((BraveBehaviour)val2).healthHaver != (Object)null) ? ((BraveBehaviour)val2).healthHaver.GetCurrentHealth() : (-1f));
bool flag2 = (Object)(object)((BraveBehaviour)val2).healthHaver == (Object)null || ((BraveBehaviour)val2).healthHaver.IsVulnerable;
Log.LogInfo((object)("[RE] name='" + ((Object)val2).name + "' guid=" + val2.EnemyGuid + " hp=" + num + " visible=" + flag + " vulnerable=" + flag2));
if (keyDown && (!flag || !flag2) && (!((Object)(object)((BraveBehaviour)val2).healthHaver != (Object)null) || !((BraveBehaviour)val2).healthHaver.IsBoss))
{
Log.LogWarning((object)("[RE] Force-removing " + ((Object)val2).name));
val.DeregisterEnemy(val2, true);
Object.Destroy((Object)(object)((Component)val2).gameObject);
}
}
}
}
catch (Exception ex)
{
Log.LogError((object)("[RE] Debug key exception: " + ex));
}
}
}
public class ExtraMarker : MonoBehaviour
{
}
public static class EnemyFilter
{
[HarmonyPatch]
public static class HardBanPatch
{
private static readonly string[] Banned = new string[24]
{
"lordofthejammed", "lord_of_the_jammed", "jammedlord", "lord of the jammed", "jammed_lord", "dummy", "test", "lord_of_the_jammed", "gatling_gull_ally", "metal_cube_guy",
"portable_turret", "dr_wolf", "gatlinggullally", "metalcubeguy", "portableturret", "drwolf", "killithid", "grip_master", "gripmaster", "fakery",
"ally", "BulletML_Mule_For_Dave", "BulletMLMuleForDave", "bulletmlmulefordave"
};
private static MethodBase TargetMethod()
{
return AccessTools.Method(typeof(AIActor), "Start", (Type[])null, (Type[])null);
}
private static bool IsBanned(AIActor a)
{
List<string> list = new List<string>();
list.Add(((Object)a).name);
try
{
list.Add(a.GetActorName());
}
catch
{
}
try
{
list.Add(a.EnemyGuid);
}
catch
{
}
foreach (string item in list)
{
if (string.IsNullOrEmpty(item))
{
continue;
}
string text = item.ToLowerInvariant();
string[] banned = Banned;
foreach (string value in banned)
{
if (text.Contains(value))
{
return true;
}
}
}
return false;
}
private static void Postfix(AIActor __instance)
{
try
{
if ((Object)(object)__instance == (Object)null)
{
return;
}
string text = ((Object)__instance).name.ToLowerInvariant();
if (text.Contains("lord") || text.Contains("jam"))
{
RandomEnemiesPlugin.Log.LogInfo((object)("[RE] Saw enemy: name='" + ((Object)__instance).name + "' guid=" + __instance.EnemyGuid));
}
if (IsBanned(__instance))
{
RandomEnemiesPlugin.Log.LogWarning((object)("[RE] Removing banned enemy: " + ((Object)__instance).name));
RoomHandler parentRoom = __instance.ParentRoom;
if (parentRoom != null)
{
parentRoom.DeregisterEnemy(__instance, true);
}
Object.Destroy((Object)(object)((Component)__instance).gameObject);
}
}
catch (Exception ex)
{
RandomEnemiesPlugin.Log.LogError((object)("[RE] HardBan exception: " + ex));
}
}
}
private static readonly Dictionary<string, string> verdicts = new Dictionary<string, string>();
private static readonly string[] BlacklistedNames = new string[32]
{
"lordofthejammed", "lord_of_the_jammed", "jammedlord", "lord of the jammed", "jammed_lord", "dummy", "test", "lord_of_the_jammed", "gatling_gull_ally", "metal_cube_guy",
"portable_turret", "dr_wolf", "knife_advanced", "gatlinggullally", "metalcubeguy", "portableturret", "drwolf", "knifeadvanced", "knife_advanced", "dr",
"killithid", "grip_master", "gripmaster", "gatlinggullally", "gatlinggull_ally", "fakery", "BulletML_Mule_For_Dave", "BulletMLMuleForDave", "bulletmlmulefordave", "summon",
"GatlingGull_Summon", "gatlinggull_summon"
};
private static readonly string[] BlacklistedGuids = new string[0];
public static void ResetCache()
{
verdicts.Clear();
}
public static string GetReason(string guid, AIActor a)
{
if (guid != null && verdicts.TryGetValue(guid, out var value))
{
return value;
}
string text = Compute(guid, a);
if (guid != null)
{
verdicts[guid] = text;
}
return text;
}
private static string Compute(string guid, AIActor a)
{
if ((Object)(object)a == (Object)null)
{
return "null prefab";
}
HealthHaver healthHaver = ((BraveBehaviour)a).healthHaver;
if ((Object)(object)healthHaver != (Object)null && healthHaver.IsSubboss)
{
return "mini-boss";
}
if ((Object)(object)healthHaver != (Object)null && healthHaver.IsBoss && !RandomEnemiesPlugin.IncludeBosses.Value)
{
return "boss";
}
if ((Object)(object)((Component)a).GetComponentInChildren<CompanionController>(true) != (Object)null)
{
return "companion";
}
if ((Object)(object)((Component)a).GetComponentInChildren<TalkDoerLite>(true) != (Object)null)
{
return "npc";
}
if (a.IsHarmlessEnemy)
{
return "harmless";
}
if ((Object)(object)((BraveBehaviour)a).behaviorSpeculator == (Object)null)
{
return "no AI";
}
if ((Object)(object)healthHaver != (Object)null && healthHaver.GetMaxHealth() >= 10000f)
{
return "dummy health";
}
string text = FriendlyBehavior(((BraveBehaviour)a).behaviorSpeculator);
if (text != null)
{
return "friendly behavior: " + text;
}
if (IsBlacklisted(guid, a))
{
return "config blacklist";
}
return null;
}
private static string FriendlyBehavior(BehaviorSpeculator bs)
{
FieldInfo[] fields = typeof(BehaviorSpeculator).GetFields(BindingFlags.Instance | BindingFlags.Public);
foreach (FieldInfo fieldInfo in fields)
{
if ((object)fieldInfo.FieldType == typeof(string) || !typeof(IEnumerable).IsAssignableFrom(fieldInfo.FieldType) || !(fieldInfo.GetValue(bs) is IEnumerable enumerable))
{
continue;
}
foreach (object item in enumerable)
{
if (item != null)
{
string name = item.GetType().Name;
if (name.StartsWith("ShieldPlayer") || name.Contains("Companion"))
{
return name;
}
}
}
}
return null;
}
private static bool IsBlacklisted(string guid, AIActor a)
{
if (guid != null)
{
string[] blacklistedGuids = BlacklistedGuids;
foreach (string value in blacklistedGuids)
{
if (guid.Equals(value, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
}
if ((Object)(object)a != (Object)null)
{
string[] blacklistedNames = BlacklistedNames;
foreach (string value2 in blacklistedNames)
{
if (((Object)a).name.IndexOf(value2, StringComparison.OrdinalIgnoreCase) >= 0)
{
return true;
}
}
}
string value3 = RandomEnemiesPlugin.ExtraBlacklist.Value;
if (string.IsNullOrEmpty(value3))
{
return false;
}
string[] array = value3.Split(new char[1] { ',' });
foreach (string text in array)
{
string text2 = text.Trim();
if (text2.Length != 0)
{
if (guid != null && guid.Equals(text2, StringComparison.OrdinalIgnoreCase))
{
return true;
}
if ((Object)(object)a != (Object)null && ((Object)a).name.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0)
{
return true;
}
}
}
return false;
}
}
[HarmonyPatch]
public static class NoMultiplyPatch
{
private static IEnumerable<MethodBase> TargetMethods()
{
List<MethodBase> list = new List<MethodBase>();
MethodInfo[] methods = typeof(AIActor).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (!(methodInfo.Name != "Spawn"))
{
ParameterInfo[] parameters = methodInfo.GetParameters();
if (parameters.Length != 0 && (object)parameters[0].ParameterType == typeof(AIActor))
{
list.Add(methodInfo);
}
}
}
return list;
}
private static void Postfix(AIActor __result)
{
if ((Object)(object)__result != (Object)null && (Object)(object)((Component)__result).GetComponent<ExtraMarker>() == (Object)null)
{
((Component)__result).gameObject.AddComponent<ExtraMarker>();
}
}
}
[HarmonyPatch(typeof(EnemyDatabase), "GetOrLoadByGuid", new Type[] { typeof(string) })]
public static class GuidLookupPatch
{
private static List<string> allGuids;
private static bool busy;
private static int count;
private static int skipLogged;
public static void ResetList()
{
allGuids = null;
EnemyFilter.ResetCache();
}
private static void LogSkip(string msg)
{
if (skipLogged++ < 40)
{
RandomEnemiesPlugin.Log.LogInfo((object)("[RE] Skip: " + msg));
}
}
private static bool FromFriendlyCode()
{
StackFrame[] frames = new StackTrace(fNeedFileInfo: false).GetFrames();
if (frames == null)
{
return false;
}
int num = Math.Min(frames.Length, 12);
for (int i = 0; i < num; i++)
{
MethodBase method = frames[i].GetMethod();
if ((object)method != null && (object)method.DeclaringType != null)
{
string name = method.DeclaringType.Name;
if (name.Contains("Companion") || name.Contains("TalkDoer") || name.Contains("Shop"))
{
LogSkip("lookup from friendly code: " + name + "." + method.Name);
return true;
}
}
}
return false;
}
private static void BuildPool()
{
allGuids = new List<string>();
bool value = RandomEnemiesPlugin.IncludeBosses.Value;
bool value2 = RandomEnemiesPlugin.DumpPool.Value;
List<string> list = new List<string>();
if ((Object)(object)EnemyDatabase.Instance == (Object)null)
{
RandomEnemiesPlugin.Log.LogError((object)"[RE] EnemyDatabase.Instance is NULL");
return;
}
foreach (EnemyDatabaseEntry entry in ((AssetBundleDatabase<AIActor, EnemyDatabaseEntry>)(object)EnemyDatabase.Instance).Entries)
{
if (entry == null || string.IsNullOrEmpty(((AssetBundleDatabaseEntry)entry).myGuid) || (!value && entry.isInBossTab))
{
continue;
}
if (value2)
{
AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(((AssetBundleDatabaseEntry)entry).myGuid);
string reason = EnemyFilter.GetReason(((AssetBundleDatabaseEntry)entry).myGuid, orLoadByGuid);
if (reason != null)
{
RandomEnemiesPlugin.Log.LogInfo((object)("[RE] Excluded: " + (((Object)(object)orLoadByGuid != (Object)null) ? ((Object)orLoadByGuid).name : "null") + " (" + ((AssetBundleDatabaseEntry)entry).myGuid + ") -> " + reason));
}
else
{
list.Add(((Object)orLoadByGuid).name);
}
}
allGuids.Add(((AssetBundleDatabaseEntry)entry).myGuid);
}
RandomEnemiesPlugin.Log.LogInfo((object)("[RE] Candidate guids: " + allGuids.Count));
if (value2)
{
RandomEnemiesPlugin.Log.LogInfo((object)("[RE] Allowed (" + list.Count + "): " + string.Join(", ", list.ToArray())));
}
}
public static AIActor PickRandomPrefab(out string pickedGuid)
{
pickedGuid = null;
if (allGuids == null)
{
BuildPool();
}
if (allGuids == null || allGuids.Count == 0)
{
return null;
}
for (int i = 0; i < 30; i++)
{
string text = allGuids[Random.Range(0, allGuids.Count)];
AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(text);
if (!((Object)(object)orLoadByGuid == (Object)null) && EnemyFilter.GetReason(text, orLoadByGuid) == null)
{
pickedGuid = text;
return orLoadByGuid;
}
}
return null;
}
public static AIActor PickRandomPrefabSafe()
{
bool flag = busy;
busy = true;
try
{
string pickedGuid;
return PickRandomPrefab(out pickedGuid);
}
finally
{
busy = flag;
}
}
private static void Postfix(string guid, ref AIActor __result)
{
if (busy)
{
return;
}
busy = true;
try
{
string reason = EnemyFilter.GetReason(guid, __result);
if (reason != null)
{
LogSkip((((Object)(object)__result != (Object)null) ? ((Object)__result).name : "null") + " -> source excluded: " + reason);
}
else
{
if (FromFriendlyCode())
{
return;
}
string pickedGuid;
AIActor val = PickRandomPrefab(out pickedGuid);
if ((Object)(object)val == (Object)null)
{
LogSkip("no valid replacement found");
return;
}
count++;
if (RandomEnemiesPlugin.DebugLogging.Value)
{
RandomEnemiesPlugin.Log.LogInfo((object)("[RE] Lookup #" + count + ": " + (((Object)(object)__result != (Object)null) ? ((Object)__result).name : "null") + " -> " + ((Object)val).name));
}
__result = val;
}
}
catch (Exception ex)
{
RandomEnemiesPlugin.Log.LogError((object)("[RE] GuidLookup exception: " + ex));
}
finally
{
busy = false;
}
}
}
public static class MultiplierPatch
{
private const int MaxEnemiesInRoom = 200;
private static bool spawning;
private static int logged;
private unsafe static int GetMultiplier()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
try
{
ValidTilesets tilesetId = GameManager.Instance.Dungeon.tileIndices.tilesetId;
switch (((object)(*(ValidTilesets*)(&tilesetId))/*cast due to .constrained prefix*/).ToString())
{
case "CASTLEGEON":
return RandomEnemiesPlugin.MultKeep.Value;
case "GUNGEON":
return RandomEnemiesPlugin.MultProper.Value;
case "MINEGEON":
return RandomEnemiesPlugin.MultMines.Value;
case "CATACOMBGEON":
return RandomEnemiesPlugin.MultHollow.Value;
case "FORGEGEON":
return RandomEnemiesPlugin.MultForge.Value;
case "HELLGEON":
return RandomEnemiesPlugin.MultHell.Value;
default:
if (logged++ < 3)
{
RandomEnemiesPlugin.Log.LogInfo((object)("[RE] Floor '" + ((object)(*(ValidTilesets*)(&tilesetId))/*cast due to .constrained prefix*/).ToString() + "' has no multiplier (x1)"));
}
break;
}
}
catch (Exception ex)
{
if (logged++ < 3)
{
RandomEnemiesPlugin.Log.LogWarning((object)("[RE] Could not detect floor: " + ex.Message));
}
}
return 1;
}
private static bool PurgeIfTooMany(RoomHandler room)
{
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
List<AIActor> activeEnemies = room.GetActiveEnemies((ActiveEnemyType)0);
if (activeEnemies == null)
{
return false;
}
List<AIActor> list = new List<AIActor>();
foreach (AIActor item in activeEnemies)
{
if (!((Object)(object)item == (Object)null) && !((Object)(object)((BraveBehaviour)item).healthHaver == (Object)null) && EnemyFilter.GetReason(null, item) == null)
{
list.Add(item);
}
}
if (list.Count <= 200)
{
return false;
}
RandomEnemiesPlugin.Log.LogWarning((object)("[RE] Room has " + list.Count + " enemies (limit " + 200 + ") - killing them all"));
foreach (AIActor item2 in list)
{
try
{
((BraveBehaviour)item2).healthHaver.ApplyDamage(100000f, Vector2.zero, "RandomEnemies", (CoreDamageTypes)0, (DamageCategory)5, true, (PixelCollider)null, false);
}
catch (Exception ex)
{
RandomEnemiesPlugin.Log.LogError((object)("[RE] Failed to kill " + ((Object)item2).name + ": " + ex.Message));
}
}
return true;
}
public static void Postfix(AIActor __instance)
{
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
if (spawning || (Object)(object)__instance == (Object)null || !RandomEnemiesPlugin.EnableMultiplier.Value || (Object)(object)((Component)__instance).GetComponent<ExtraMarker>() != (Object)null)
{
return;
}
spawning = true;
try
{
if (EnemyFilter.GetReason(null, __instance) != null)
{
return;
}
RoomHandler parentRoom = __instance.ParentRoom;
if (parentRoom == null || PurgeIfTooMany(parentRoom))
{
return;
}
int num = GetMultiplier() - 1;
if (num <= 0)
{
return;
}
Vector2 val = Vector2.op_Implicit(((BraveBehaviour)__instance).transform.position);
int num2 = 0;
for (int i = 0; i < num; i++)
{
AIActor val2 = GuidLookupPatch.PickRandomPrefabSafe();
if ((Object)(object)val2 == (Object)null)
{
break;
}
Vector2 val3 = val + Random.insideUnitCircle * 2f;
AIActor val4 = AIActor.Spawn(val2, val3, parentRoom, true, (AwakenAnimationType)0, true);
if ((Object)(object)val4 != (Object)null)
{
num2++;
}
}
if (RandomEnemiesPlugin.DebugLogging.Value && num2 > 0)
{
RandomEnemiesPlugin.Log.LogInfo((object)("[RE] Multiplier: " + ((Object)__instance).name + " got " + num2 + " extra enem" + ((num2 == 1) ? "y" : "ies")));
}
PurgeIfTooMany(parentRoom);
}
catch (Exception ex)
{
RandomEnemiesPlugin.Log.LogError((object)("[RE] Multiplier exception: " + ex));
}
finally
{
spawning = false;
}
}
}