Decompiled source of LethalCitadelle v1.1.0

EbenStream.LethalCitadelle.dll

Decompiled 4 months 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 LethalCitadelle.Patches;
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("EbenStream.LethalCitadelle")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("LethalCitadelle")]
[assembly: AssemblyTitle("EbenStream.LethalCitadelle")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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.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 LethalCitadelle
{
	[BepInPlugin("EbenStream.LethalCitadelle", "LethalCitadelle", "1.1.0")]
	public class LethalCitadelle : BaseUnityPlugin
	{
		internal static List<AudioClip> MelucheVoicesAngry;

		internal static List<AudioClip> MelucheVoicesCalm;

		internal static List<AudioClip> PoutouVoices;

		internal static List<AudioClip> GuiraudScream;

		internal static List<AudioClip> GuiraudWall;

		internal static List<AudioClip> Gluanksman;

		internal static AssetBundle BundleMelucheAngry;

		internal static AssetBundle BundleMelucheCalm;

		internal static AssetBundle BundlePoutou;

		internal static AssetBundle BundleGuiraudScream;

		internal static AssetBundle BundleGuiraudWall;

		internal static AssetBundle BundleGluanksman;

		public static LethalCitadelle Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)"EbenStream.LethalCitadelle v1.1.0 has loaded!");
			MelucheVoicesAngry = new List<AudioClip>();
			MelucheVoicesCalm = new List<AudioClip>();
			PoutouVoices = new List<AudioClip>();
			GuiraudScream = new List<AudioClip>();
			GuiraudWall = new List<AudioClip>();
			Gluanksman = new List<AudioClip>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("EbenStream.LethalCitadelle.dll".ToCharArray());
			BundleMelucheAngry = AssetBundle.LoadFromFile(location + "melucheangry");
			BundleMelucheCalm = AssetBundle.LoadFromFile(location + "meluchecalm");
			BundlePoutou = AssetBundle.LoadFromFile(location + "poutou");
			BundleGuiraudWall = AssetBundle.LoadFromFile(location + "guiraudwall");
			BundleGuiraudScream = AssetBundle.LoadFromFile(location + "guiraudscream");
			BundleGluanksman = AssetBundle.LoadFromFile(location + "gluanksman");
			if (Object.op_Implicit((Object)(object)BundleMelucheAngry) && Object.op_Implicit((Object)(object)BundlePoutou) && Object.op_Implicit((Object)(object)BundleMelucheCalm))
			{
				MelucheVoicesAngry = BundleMelucheAngry.LoadAllAssets<AudioClip>().ToList();
				MelucheVoicesCalm = BundleMelucheCalm.LoadAllAssets<AudioClip>().ToList();
				PoutouVoices = BundlePoutou.LoadAllAssets<AudioClip>().ToList();
				GuiraudScream = BundleGuiraudScream.LoadAllAssets<AudioClip>().ToList();
				GuiraudWall = BundleGuiraudWall.LoadAllAssets<AudioClip>().ToList();
				Gluanksman = BundleGluanksman.LoadAllAssets<AudioClip>().ToList();
				Logger.LogError((object)"Successfully loaded asset bundle");
			}
			else
			{
				Logger.LogError((object)"Failed to load asset bundle");
			}
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("EbenStream.LethalCitadelle");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Harmony.PatchAll(typeof(HoarderBugAIPatch));
			Harmony.PatchAll(typeof(FlowerSnakeEnemyPatch));
			Harmony.PatchAll(typeof(CrawlerAIPatch));
			Harmony.PatchAll(typeof(PufferAIPatch));
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "EbenStream.LethalCitadelle";

		public const string PLUGIN_NAME = "LethalCitadelle";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace LethalCitadelle.Patches
{
	[HarmonyPatch(typeof(CrawlerAI))]
	internal class CrawlerAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(CrawlerAI __instance)
		{
			__instance.longRoarSFX = LethalCitadelle.GuiraudScream.ToArray();
			__instance.hitWallSFX = LethalCitadelle.GuiraudWall.ToArray();
		}
	}
	[HarmonyPatch(typeof(FlowerSnakeEnemy))]
	internal class FlowerSnakeEnemyPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(FlowerSnakeEnemy __instance)
		{
			((EnemyAI)__instance).enemyType.audioClips = LethalCitadelle.PoutouVoices.ToArray();
			((EnemyAI)__instance).enemyType.audioClips[4] = null;
			__instance.flappingAudio.clip = null;
		}
	}
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class HoarderBugAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(HoarderBugAI __instance)
		{
			__instance.chitterSFX = LethalCitadelle.MelucheVoicesCalm.ToArray();
			__instance.angryScreechSFX = LethalCitadelle.MelucheVoicesAngry.ToArray();
			__instance.bugFlySFX = null;
			__instance.hitPlayerSFX = null;
		}
	}
	[HarmonyPatch(typeof(PufferAI))]
	internal class PufferAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(PufferAI __instance)
		{
			AudioClip[] frightenSFX = (AudioClip[])(object)new AudioClip[1] { LethalCitadelle.Gluanksman[1] };
			__instance.frightenSFX = frightenSFX;
			__instance.puff = LethalCitadelle.Gluanksman[2];
			__instance.angry = LethalCitadelle.Gluanksman[0];
		}
	}
}