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[19]
{
"FreeBird_Start.mp3", "FreeBird_End01.mp3", "FreeBird_End02.mp3", "ChipiChipi_Start.mp3", "ChipiChipi_End.mp3", "INeedAHero_Start.mp3", "INeedAHero_End.mp3", "MyWay_Start.mp3", "MyWay_End.mp3", "Rats_Start.mp3",
"Rats_End.mp3", "Toothless_Start.mp3", "Toothless_End.mp3", "GirlsClub_Start.mp3", "GirlsClub_End.mp3", "Ricky.mp3", "WeAreNumberOne_Start.mp3", "WeAreNumberOne_End01.mp3", "WeAreNumberOne_End02.mp3"
};
public ConfigEntry<bool> Toggle { get; private set; }
public ConfigEntry<int> Volume { get; private set; }
private void Awake()
{
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Expected O, but got Unknown
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: 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)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:
case 2:
___popUpTimer = 62.5f;
mls.LogInfo((object)$"JukeInTheBox will load with FreeBird and a popUpTimer of {___popUpTimer}");
break;
case 3:
___popUpTimer = 40.03f;
mls.LogInfo((object)$"JukeInTheBox will load with ChipChipiChapaChapa and a popUpTimer of {___popUpTimer}");
break;
case 4:
___popUpTimer = 31.58f;
mls.LogInfo((object)$"JukeInTheBox will load with I need a hero and a popUpTimer of {___popUpTimer}");
break;
case 5:
___popUpTimer = 50.47f;
mls.LogInfo((object)$"JukeInTheBox will load with My Way and a popUpTimer of {___popUpTimer}");
break;
case 6:
___popUpTimer = 37.13f;
mls.LogInfo((object)$"JukeInTheBox will load with We are the rats and a popUpTimer of {___popUpTimer}");
break;
case 7:
___popUpTimer = 25.58f;
mls.LogInfo((object)$"JukeInTheBox will load with Toothless and a popUpTimer of {___popUpTimer}");
break;
case 8:
___popUpTimer = 35.26f;
mls.LogInfo((object)$"JukeInTheBox will load with Girls Club and a popUpTimer of {___popUpTimer}");
break;
case 9:
case 10:
___popUpTimer = 26.95f;
mls.LogInfo((object)$"JukeInTheBox will load with We are Number one and a popUpTimer of {___popUpTimer}");
break;
}
}
[HarmonyPatch("Start")]
[HarmonyPrefix]
public static void MusicPicker(ref AudioClip ___popGoesTheWeaselTheme, ref AudioClip ___screamingSFX, ref AudioSource ___creatureVoice, ref AudioSource ___popUpSFX, ref AudioSource ___farAudio)
{
if (JukeboxJesterBase.Instance.Toggle.Value)
{
Random random = new Random(Environment.TickCount);
randomNumber = random.Next(1, 11);
rickyChance = random.Next(1, 101);
___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["FreeBird_Start"];
___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["FreeBird_End01"];
break;
case 2:
___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["FreeBird_Start"];
___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["FreeBird_End02"];
break;
case 3:
___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["ChipiChipi_Start"];
___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["ChipiChipi_End"];
break;
case 4:
___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["INeedAHero_Start"];
___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["INeedAHero_End"];
break;
case 5:
___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["MyWay_Start"];
___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["MyWay_End"];
break;
case 6:
___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["Rats_Start"];
___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["Rats_End"];
break;
case 7:
___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["Toothless_Start"];
___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["Toothless_End"];
break;
case 8:
___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["GirlsClub_Start"];
___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["GirlsClub_End"];
break;
case 9:
___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["WeAreNumberOne_Start"];
___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["WeAreNumberOne_End01"];
break;
case 10:
___popGoesTheWeaselTheme = JukeboxJesterBase.Instance.AudioFiles["WeAreNumberOne_Start"];
___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["WeAreNumberOne_End02"];
break;
}
if (rickyChance <= 1)
{
___screamingSFX = JukeboxJesterBase.Instance.AudioFiles["Ricky"];
}
}
}
}
}