Decompiled source of Insane Jester v1.0.1

Insane Jester.dll

Decompiled 4 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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Insane Jester")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Insane Jester")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("88cda8d5-5241-4bc8-9fc6-28328701528d")]
[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 Insane_Jester;

[HarmonyPatch(typeof(VehicleController))]
internal class CruiserPatch
{
	[HarmonyPatch("SwitchRadio")]
	[HarmonyPrefix]
	private static void AddCruiserRadioSong(ref AudioClip[] ___radioClips)
	{
		List<AudioClip> list = new List<AudioClip>();
		list = ___radioClips.ToList();
		if (!list.Contains(SFX.Benz))
		{
			list.Add(SFX.Benz);
		}
		else
		{
			IJ.Instance.mls.LogDebug((object)"Benz Sound already added!");
		}
		___radioClips = list.ToArray();
	}
}
[BepInPlugin("Charell.InsaneJester", "Insane Jester", "1.0.0")]
public class IJ : BaseUnityPlugin
{
	private const string modGUID = "Charell.InsaneJester";

	private const string modName = "Insane Jester";

	private const string modVersion = "1.0.0";

	private readonly Harmony harmony = new Harmony("Charell.InsaneJester");

	internal ManualLogSource mls;

	public static IJ Instance;

	internal static List<AudioClip> SoundFX = new List<AudioClip>();

	internal static AssetBundle Bundle;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("Charell.InsaneJester");
		harmony.PatchAll(typeof(IJ));
		harmony.PatchAll(typeof(JesterPatch));
		harmony.PatchAll(typeof(CruiserPatch));
		string pluginPath = Paths.PluginPath;
		mls.LogDebug((object)("Folder location: " + pluginPath));
		Bundle = AssetBundle.LoadFromFile(pluginPath + "\\Charell-Insane_Jester\\sounds");
		if ((Object)(object)Bundle != (Object)null)
		{
			SoundFX = Bundle.LoadAllAssets<AudioClip>().ToList();
			mls.LogDebug((object)"Successfully loaded all AudioClips from Asset!");
			{
				foreach (AudioClip item in SoundFX)
				{
					if (((Object)item).name.ToLower() == "voice")
					{
						int index = SoundFX.IndexOf(item);
						SFX.IntroVoice = SoundFX[index];
					}
					if (((Object)item).name.ToLower() == "moan")
					{
						int index2 = SoundFX.IndexOf(item);
						SFX.Moan = SoundFX[index2];
					}
					if (((Object)item).name.ToLower() == "insane1")
					{
						int index3 = SoundFX.IndexOf(item);
						SFX.InsanePart1 = SoundFX[index3];
					}
					if (((Object)item).name.ToLower() == "insane2")
					{
						int index4 = SoundFX.IndexOf(item);
						SFX.InsanePart2 = SoundFX[index4];
					}
					if (((Object)item).name.ToLower() == "benz")
					{
						int index5 = SoundFX.IndexOf(item);
						SFX.Benz = SoundFX[index5];
					}
				}
				return;
			}
		}
		mls.LogDebug((object)"moan file not found!");
	}
}
[HarmonyPatch(typeof(JesterAI))]
internal class JesterPatch
{
	[HarmonyPatch("Start")]
	[HarmonyPrefix]
	private static void FixJesterWindUp(ref AudioClip ___popGoesTheWeaselTheme)
	{
		___popGoesTheWeaselTheme = SFX.InsanePart1;
	}

	[HarmonyPatch("Start")]
	[HarmonyPrefix]
	public static void FixJesterScream(ref AudioClip ___screamingSFX)
	{
		___screamingSFX = SFX.InsanePart2;
	}

	[HarmonyPatch("SetJesterInitialValues")]
	[HarmonyPostfix]
	public static void JestAIInitialPatch(ref float ___popUpTimer)
	{
		___popUpTimer = 48f;
	}
}
public static class SFX
{
	public static AudioClip IntroVoice;

	public static AudioClip Moan;

	public static AudioClip InsanePart1;

	public static AudioClip InsanePart2;

	public static AudioClip Benz;
}