Decompiled source of JukeboxJesterAnotherMusicPack v1.0.6

BepInEx/plugins/JukeboxJesterMod.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JukeboxJesterMod.Patches;
using LCSoundTool;
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("JukeboxJesterMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JukeboxJesterMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("262f21cc-be7b-436f-b1c7-39aab0efe6d2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace JukeboxJesterMod
{
	[BepInPlugin("overlayFox.JukeboxJesterGuid", "Jukebox Jester", "1.1.0")]
	public class JukeboxJesterBase : BaseUnityPlugin
	{
		private const string modGuid = "overlayFox.JukeboxJesterGuid";

		private const string modName = "Jukebox Jester";

		private const string modVersion = "1.1.0";

		public readonly Harmony harmony = new Harmony("overlayFox.JukeboxJesterGuid");

		public static JukeboxJesterBase Instance;

		internal ManualLogSource mls;

		public string Location;

		public Dictionary<string, AudioClip> AudioFiles = new Dictionary<string, AudioClip>();

		private string[] AudioStrings = new string[26]
		{
			"DarkSouls_Start.mp3", "DarkSouls_End.mp3", "DarkSouls_Death.mp3", "ChipiChipi_Start.mp3", "ChipiChipi_End.mp3", "BuryLight_Start.mp3", "BuryLight_End.mp3", "MetalGearRising_Start.mp3", "MetalGearRising_End.mp3", "Dr.Livesey_Start.mp3",
			"Dr.Livesey_End.mp3", "MadeInHeaven_Start.mp3", "MadeInHeaven_End.mp3", "FreeBird_Start.mp3", "FreeBird_End.mp3", "HideAway_Start.mp3", "HideAway_End.mp3", "PizzaTower_Start.mp3", "PizzaTower_End.mp3", "PizzaTower_Death.mp3",
			"MobPsycho100_Start.mp3", "MobPsycho100_End.mp3", "NecoArc_Start.mp3", "NecoArc_End.mp3", "WhisleBaby_Start.mp3", "WhisleBaby_End.mp3"
		};

		public ConfigEntry<bool> Toggle { get; private set; }

		public ConfigEntry<int> Volume { get; private set; }

		private void Awake()
		{
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Expected O, but got Unknown
			mls = Logger.CreateLogSource("overlayFox.JukeboxJesterGuid");
			if ((Object)(object)Instance == (Object)null)
			{
				mls.LogInfo((object)"Starting Instance of Jukebox Jester");
				Instance = this;
			}
			mls.LogInfo((object)"Getting Music directory");
			Location = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "music");
			if (!Directory.Exists(Location))
			{
				mls.LogError((object)"Music folder doesn't exist. Can't load mod");
				return;
			}
			mls.LogInfo((object)("Music directory found under '" + Location + "'"));
			mls.LogInfo((object)"Loading Music....");
			string[] audioStrings = AudioStrings;
			foreach (string text in audioStrings)
			{
				string text2 = Path.Combine(Location, text);
				if (!File.Exists(text2))
				{
					mls.LogWarning((object)(text2 + " does not exists and can thus not be loaded"));
				}
				else
				{
					AudioFiles[text.Substring(0, text.Length - 4)] = SoundTool.GetAudioClip(Location, text);
				}
			}
			mls.LogInfo((object)"Loaded all songs");
			((BaseUnityPlugin)this).Config.Bind<bool>("Mod", "EnableMod", true, "Enables the Mod");
			Toggle = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "EnableJukeboxJester", true, "Enables the Jukebox Jester");
			Volume = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "VolumeControl", 50, new ConfigDescription("Changes the Volume of the Jukebox Jester", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			harmony.PatchAll(typeof(JesterAiPatch));
			harmony.PatchAll(typeof(JukeboxJesterBase));
			mls.LogInfo((object)"Jukebox Jester initialized");
		}
	}
}
namespace JukeboxJesterMod.Patches
{
	[HarmonyPatch(typeof(JesterAI))]
	public static class JesterAiPatch
	{
		public static int randomNumber;

		public static int rickyChance;

		internal static ManualLogSource mls;

		[HarmonyPatch("SetJesterInitialValues")]
		[HarmonyPostfix]
		public static void SetSong(ref float ___popUpTimer)
		{
			mls = JukeboxJesterBase.Instance.mls;
			switch (randomNumber)
			{
			case 1:
				___popUpTimer = 31.01f;
				mls.LogInfo((object)$"JukeInTheBox will load with MetalGearRising_Start and a popUpTimer of {___popUpTimer}");
				break;
			case 2:
				___popUpTimer = 40.03f;
				mls.LogInfo((object)$"JukeInTheBox will load with ChipChipiChapaChapa and a popUpTimer of {___popUpTimer}");
				break;
			case 3:
				___popUpTimer = 31.1f;
				mls.LogInfo((object)$"JukeInTheBox will load with DarkSouls_Start and a popUpTimer of {___popUpTimer}");
				break;
			case 4:
				___popUpTimer = 36.1f;
				mls.LogInfo((object)$"JukeInTheBox will load with BuryLight_Start and a popUpTimer of {___popUpTimer}");
				break;
			case 5:
				___popUpTimer = 39.6f;
				mls.LogInfo((object)$"JukeInTheBox will load with Dr.Livesey_Start and a popUpTimer of {___popUpTimer}");
				break;
			case 6:
				___popUpTimer = 43.17f;
				mls.LogInfo((object)$"JukeInTheBox will load with MadeInHeaven_Start and a popUpTimer of {___popUpTimer}");
				break;
			case 7:
				___popUpTimer = 44.8f;
				mls.LogInfo((object)$"JukeInTheBox will load with FreeBird_Start and a popUpTimer of {___popUpTimer}");
				break;
			case 8:
				___popUpTimer = 39.96f;
				mls.LogInfo((object)$"JukeInTheBox will load with HideAway_Start and a popUpTimer of {___popUpTimer}");
				break;
			case 9:
				___popUpTimer = 39.11f;
				mls.LogInfo((object)$"JukeInTheBox will load with PizzaTower_Start and a popUpTimer of {___popUpTimer}");
				break;
			case 10:
				___popUpTimer = 42.1f;
				mls.LogInfo((object)$"JukeInTheBox will load with MobPsycho100_Start and a popUpTimer of {___popUpTimer}");
				break;
			case 11:
				___popUpTimer = 39.46f;
				mls.LogInfo((object)$"JukeInTheBox will load with NecoArc_Start and a popUpTimer of {___popUpTimer}");
				break;
			case 12:
				___popUpTimer = 27.38f;
				mls.LogInfo((object)$"JukeInTheBox will load with WhisleBaby_Start and a popUpTimer of {___popUpTimer}");
				break;
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void MusicPicker(ref AudioClip ___popGoesTheWeaselTheme, ref AudioClip ___screamingSFX, ref AudioClip ___killPlayerSFX, ref AudioSource ___creatureVoice, ref AudioSource ___popUpSFX, ref AudioSource ___farAudio)
		{
			if (JukeboxJesterBase.Instance.Toggle.Value)
			{
				Random random = new Random(Environment.TickCount);
				randomNumber = random.Next(1, 13);
				___popUpSFX = null;
				___farAudio.volume = (float)JukeboxJesterBase.Instance.Volume.Value / 10f;
				___creatureVoice.volume = (float)JukeboxJesterBase.Instance.Volume.Value / 10f;
				switch (randomNumber)
				{
				case 1:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["MetalGearRising_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["MetalGearRising_End"];
					break;
				case 2:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["ChipiChipi_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["ChipiChipi_End"];
					break;
				case 3:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["DarkSouls_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["DarkSouls_End"];
					___killPlayerSFX = JukeboxJesterBase.Instance.AudioFiles["DarkSouls_Death"];
					break;
				case 4:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["BuryLight_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["BuryLight_End"];
					break;
				case 5:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["Dr.Livesey_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["Dr.Livesey_End"];
					break;
				case 6:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["MadeInHeaven_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["MadeInHeaven_End"];
					break;
				case 7:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["FreeBird_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["FreeBird_End"];
					break;
				case 8:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["HideAway_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["HideAway_End"];
					break;
				case 9:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["PizzaTower_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["PizzaTower_End"];
					___killPlayerSFX = JukeboxJesterBase.Instance.AudioFiles["PizzaTower_Death"];
					break;
				case 10:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["MobPsycho100_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["MobPsycho100_End"];
					break;
				case 11:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["NecoArc_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["NecoArc_End"];
					break;
				case 12:
					___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["WhisleBaby_Start"];
					___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["WhisleBaby_End"];
					break;
				}
			}
		}
	}
}