Decompiled source of SpawnOnlyMimicsMod v1.0.0

SpawnOnlyMimics.dll

Decompiled 9 months ago
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.Logging;
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("SpawnOnlyMimics")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SpawnOnlyMimics")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("691946e9-2d0c-4a0e-8e27-23a26a80b2d2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SpawnOnlyMimicsMod;

[BepInPlugin("Triada.SpawnOnlyMimicsMod", "Spawn Only Mimics Mod", "1.0.0")]
public class SpawnOnlyMimicsMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Terminal))]
	private class GetMaskedMan
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void SaveMaskedManForUse(ref SelectableLevel[] ___moonsCatalogueList)
		{
			SelectableLevel[] array = ___moonsCatalogueList;
			SelectableLevel[] array2 = array;
			foreach (SelectableLevel val in array2)
			{
				foreach (SpawnableEnemyWithRarity enemy in val.Enemies)
				{
					if (enemy.enemyType.enemyName == "Masked")
					{
						mls.LogInfo((object)"Found Masked!");
						jesterRef = enemy;
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(RoundManager))]
	internal class MaskedSpawnSettings
	{
		[HarmonyPatch("BeginEnemySpawning")]
		[HarmonyPrefix]
		private static void UpdateSpawnRates(ref SelectableLevel ___currentLevel)
		{
			mls.LogInfo((object)"Trying to spawn a mimic");
			___currentLevel.Enemies.Add(jesterRef);
		}
	}

	private const string modGUID = "Triada.SpawnOnlyMimicsMod";

	private const string modName = "Spawn Only Mimics Mod";

	private const string modVersion = "1.0.0";

	private readonly Harmony harmony = new Harmony("Triada.SpawnOnlyMimicsMod");

	private static SpawnOnlyMimicsMod Instance;

	private static RoundManager currentRound;

	public static Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>> levelEnemySpawns;

	public static SpawnableEnemyWithRarity jesterRef;

	public static ManualLogSource mls;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("Triada.SpawnOnlyMimicsMod");
		levelEnemySpawns = new Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>>();
		mls = ((BaseUnityPlugin)this).Logger;
		mls.LogInfo((object)"The MIMICS ONLY MOD HAS AWAKEN");
		mls.LogInfo((object)"Vika, Kriska and Melancholia SASATb :^)))))");
		harmony.PatchAll(typeof(SpawnOnlyMimicsMod));
		harmony.PatchAll(typeof(GetMaskedMan));
	}

	[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
	[HarmonyPrefix]
	private static bool ModifyLevelOldTry(ref SelectableLevel newLevel)
	{
		bool flag = false;
		foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
		{
			enemy.rarity = 0;
			if (enemy.enemyType.enemyName.ToLower().Contains("jester"))
			{
				mls.LogInfo((object)"Found a jester, yoinking that reference");
				mls.LogInfo((object)"Found a jester, trying to increse rarity by 999");
				enemy.rarity = 999;
				flag = true;
				jesterRef = enemy;
			}
		}
		if (!flag)
		{
			if (jesterRef != null)
			{
				mls.LogInfo((object)"Didn't find a jester, but we can use the ref");
				newLevel.Enemies.Add(jesterRef);
			}
			else
			{
				mls.LogInfo((object)"We couldn't add a jester to this level");
			}
		}
		foreach (SpawnableEnemyWithRarity outsideEnemy in newLevel.OutsideEnemies)
		{
			outsideEnemy.rarity = 0;
		}
		return true;
	}
}