Decompiled source of RemoveMouthEnemy v1.0.0

com.github.zehsteam.RemoveMouthEnemy.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using com.github.zehsteam.RemoveMouthEnemy.Helpers;
using com.github.zehsteam.RemoveMouthEnemy.Patches;

[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("Zehs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025 Zehs")]
[assembly: AssemblyDescription("Removes the Slow Mouth (Spewer) enemy.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+03b04fa281bb22a8ca72456c7f248a1f0d50660c")]
[assembly: AssemblyProduct("RemoveMouthEnemy")]
[assembly: AssemblyTitle("com.github.zehsteam.RemoveMouthEnemy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace com.github.zehsteam.RemoveMouthEnemy
{
	[BepInPlugin("com.github.zehsteam.RemoveMouthEnemy", "RemoveMouthEnemy", "1.0.0")]
	internal class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.github.zehsteam.RemoveMouthEnemy");

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Logger = Logger.CreateLogSource("com.github.zehsteam.RemoveMouthEnemy");
			Logger.LogInfo((object)"RemoveMouthEnemy has awoken!");
			_harmony.PatchAll(typeof(EnemyDirectorPatch));
			_harmony.PatchAll(typeof(LevelGeneratorPatch));
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.RemoveMouthEnemy";

		public const string PLUGIN_NAME = "RemoveMouthEnemy";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace com.github.zehsteam.RemoveMouthEnemy.Patches
{
	[HarmonyPatch(typeof(EnemyDirector))]
	internal static class EnemyDirectorPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			EnemyHelper.RemoveMouthEnemyFromList(ref EnemyDirector.instance.enemiesDifficulty1);
			EnemyHelper.RemoveMouthEnemyFromList(ref EnemyDirector.instance.enemiesDifficulty2);
			EnemyHelper.RemoveMouthEnemyFromList(ref EnemyDirector.instance.enemiesDifficulty3);
		}
	}
	[HarmonyPatch(typeof(LevelGenerator))]
	internal static class LevelGeneratorPatch
	{
		[HarmonyPatch("EnemySpawn")]
		[HarmonyPrefix]
		private static bool EnemySpawnPatch(ref EnemySetup enemySetup)
		{
			if (EnemyHelper.IsMouthEnemy(enemySetup))
			{
				Plugin.Logger.LogInfo((object)"Prevented mouth enemy from spawning.");
				return false;
			}
			return true;
		}
	}
}
namespace com.github.zehsteam.RemoveMouthEnemy.Helpers
{
	internal static class EnemyHelper
	{
		public static bool IsMouthEnemy(EnemySetup enemySetup)
		{
			if ((Object)(object)enemySetup == (Object)null)
			{
				return false;
			}
			if (((Object)enemySetup).name.Contains("Slow Mouth", StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (TryGetEnemyName(enemySetup, out var enemyName) && enemyName.Equals("Spewer", StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			return false;
		}

		public static bool IsMouthEnemy(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return false;
			}
			if (TryGetEnemyName(gameObject, out var enemyName) && enemyName.Equals("Spewer", StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			return false;
		}

		public static bool TryGetEnemyName(EnemySetup enemySetup, out string enemyName)
		{
			enemyName = string.Empty;
			if ((Object)(object)enemySetup == (Object)null || enemySetup.spawnObjects == null)
			{
				return false;
			}
			foreach (GameObject spawnObject in enemySetup.spawnObjects)
			{
				if (TryGetEnemyName(spawnObject, out enemyName))
				{
					return true;
				}
			}
			return false;
		}

		public static bool TryGetEnemyName(GameObject gameObject, out string enemyName)
		{
			enemyName = string.Empty;
			if ((Object)(object)gameObject == (Object)null)
			{
				return false;
			}
			EnemyParent val = default(EnemyParent);
			if (gameObject.TryGetComponent<EnemyParent>(ref val))
			{
				enemyName = val.enemyName;
				return true;
			}
			return false;
		}

		public static void RemoveMouthEnemyFromList(ref List<EnemySetup> list)
		{
			list = list.Where((EnemySetup enemySetup) => !IsMouthEnemy(enemySetup)).ToList();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}