Decompiled source of Jester096SoundReplacement v1.0.0

Jester096.dll

Decompiled 10 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 Jester096.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("Jester096")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Jester096")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f0629adf-5e2e-449b-b043-0968e88258cd")]
[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 Jester096
{
	[BepInPlugin("Mythical.Jester096", "Jester SCP-096", "1.0.0.0")]
	public class J096ModBase : BaseUnityPlugin
	{
		private const string modGUID = "Mythical.Jester096";

		private const string modName = "Jester SCP-096";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Mythical.Jester096");

		private static J096ModBase Instance;

		internal static ManualLogSource jmls;

		internal static List<AudioClip> SoundFX;

		internal static AssetBundle Bundle;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			jmls = Logger.CreateLogSource("Mythical.Jester096");
			jmls.LogInfo((object)"J096 is active!");
			harmony.PatchAll(typeof(J096ModBase));
			harmony.PatchAll(typeof(Jester096Patch));
			jmls = ((BaseUnityPlugin)this).Logger;
			SoundFX = new List<AudioClip>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("Jester096.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(location + "jester096");
			if ((Object)(object)Bundle != (Object)null)
			{
				jmls.LogInfo((object)"jester096 bundle loaded!");
				SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				jmls.LogError((object)"Failed to load jester096 asset bundle!");
			}
		}
	}
}
namespace Jester096.Patches
{
	[HarmonyPatch(typeof(JesterAI))]
	internal class Jester096Patch
	{
		internal static AudioClip idleSFX;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void OverrideAudio(JesterAI __instance)
		{
			__instance.killPlayerSFX = J096ModBase.SoundFX[0];
			__instance.popGoesTheWeaselTheme = J096ModBase.SoundFX[2];
			__instance.popUpSFX = J096ModBase.SoundFX[3];
			__instance.screamingSFX = J096ModBase.SoundFX[4];
			if (__instance.beginCrankingTimer > 0f)
			{
				idleSFX = J096ModBase.SoundFX[1];
				if (!__instance.farAudio.isPlaying)
				{
					__instance.farAudio.clip = idleSFX;
					__instance.farAudio.Play();
				}
			}
		}
	}
}