Decompiled source of LiLNuisance v1.0.1

LiLNuisance.dll

Decompiled 6 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LiLNuisance.Patches;
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("LiLNuisance")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LiLNuisance")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("df4c251f-c890-4d7a-b2b5-12560d760827")]
[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 LiLNuisance
{
	[BepInPlugin("LiLNuisance", "LiLNuisance", "1.0.0.0")]
	public class LiLNuisanceBase : BaseUnityPlugin
	{
		private const string modGUID = "LiLNuisance";

		private const string modName = "LiLNuisance";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmany = new Harmony("LiLNuisance");

		internal ManualLogSource mls;

		internal static Dictionary<string, List<AudioClip>> SoundFXByBundle;

		internal static List<AssetBundle> Bundles;

		public static LiLNuisanceBase Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("LiLNuisance");
			mls.LogInfo((object)"The mod has awakened");
			harmany.PatchAll(typeof(LiLNuisanceBase));
			harmany.PatchAll(typeof(StartOfRoundPatch));
			harmany.PatchAll(typeof(FlowerManAIPatch));
			harmany.PatchAll(typeof(HoarderBugAIPatch));
			harmany.PatchAll(typeof(CrawlerAIPatch));
			harmany.PatchAll(typeof(CentipedeAIPatch));
			harmany.PatchAll(typeof(NutcrackerEnemyAIPatch));
			mls = ((BaseUnityPlugin)this).Logger;
			SoundFXByBundle = new Dictionary<string, List<AudioClip>>();
			Bundles = new List<AssetBundle>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("LiLNuisance.dll".ToCharArray());
			string[] array = new string[7] { "intercom", "cellingbug", "fastdog", "bsnap", "lootbug", "mimic", "nutcraker" };
			string[] array2 = array;
			foreach (string text in array2)
			{
				AssetBundle val = AssetBundle.LoadFromFile(location + text);
				if ((Object)(object)val != (Object)null)
				{
					mls.LogInfo((object)("Successfully loaded asset bundle: " + text));
					List<AudioClip> value = val.LoadAllAssets<AudioClip>().ToList();
					SoundFXByBundle[text] = value;
					Bundles.Add(val);
				}
				else
				{
					mls.LogError((object)("Failed to load asset bundle: " + text));
				}
			}
		}
	}
}
namespace LiLNuisance.Patches
{
	[HarmonyPatch(typeof(CentipedeAI))]
	internal class CentipedeAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(CentipedeAI __instance)
		{
			if (LiLNuisanceBase.SoundFXByBundle.TryGetValue("cellingbug", out var value) && value.Count > 0)
			{
				__instance.fallShriek = value[0];
			}
			else
			{
				LiLNuisanceBase.Instance.mls.LogError((object)"Failed to find audio clip in bundle: intercom");
			}
		}
	}
	[HarmonyPatch(typeof(NutcrackerEnemyAI))]
	internal class NutcrackerEnemyAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(NutcrackerEnemyAI __instance)
		{
			if (LiLNuisanceBase.SoundFXByBundle.TryGetValue("nutcraker", out var value) && value.Count > 0)
			{
				__instance.torsoFinishTurningClips = (AudioClip[])(object)new AudioClip[1] { value[0] };
			}
			else
			{
				LiLNuisanceBase.Instance.mls.LogError((object)"Failed to find audio clip in bundle: intercom");
			}
		}
	}
	[HarmonyPatch(typeof(CrawlerAI))]
	internal class CrawlerAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(CrawlerAI __instance)
		{
			if (LiLNuisanceBase.SoundFXByBundle.TryGetValue("fastdog", out var value) && value.Count > 0)
			{
				__instance.longRoarSFX = (AudioClip[])(object)new AudioClip[1] { value[0] };
			}
			else
			{
				LiLNuisanceBase.Instance.mls.LogError((object)"Failed to find audio clip in bundle: bsnap");
			}
		}
	}
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class HoarderBugAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(HoarderBugAI __instance)
		{
			if (LiLNuisanceBase.SoundFXByBundle.TryGetValue("lootbug", out var value) && value.Count > 0)
			{
				__instance.chitterSFX = (AudioClip[])(object)new AudioClip[1] { value[0] };
			}
			else
			{
				LiLNuisanceBase.Instance.mls.LogError((object)"Failed to find audio clip in bundle: lootbug");
			}
		}
	}
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class FlowerManAIPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(FlowermanAI __instance)
		{
			if (LiLNuisanceBase.SoundFXByBundle.TryGetValue("bsnap", out var value) && value.Count > 0)
			{
				__instance.crackNeckSFX = value[0];
			}
			else
			{
				LiLNuisanceBase.Instance.mls.LogError((object)"Failed to find audio clip in bundle: bsnap");
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OverrideAudio(StartOfRound __instance)
		{
			if (LiLNuisanceBase.SoundFXByBundle.TryGetValue("intercom", out var value) && value.Count > 0)
			{
				__instance.shipIntroSpeechSFX = value[0];
			}
			else
			{
				LiLNuisanceBase.Instance.mls.LogError((object)"Failed to find audio clip in bundle: intercom");
			}
		}
	}
}