Decompiled source of MikuJester v1.0.1

LCMiku.dll

Decompiled 5 months ago
using System;
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 LCMikuJester.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("LCMiku")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LCMiku")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4e8ee8ee-2b15-4288-81ce-0325e1595eb5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LCMikuJester
{
	[BepInPlugin("schlues.LCMikuJester", "Hatsune Miku Jester Mod", "1.0.0.0")]
	public class MikuJesterBase : BaseUnityPlugin
	{
		private const string modGUID = "schlues.LCMikuJester";

		private const string modName = "Hatsune Miku Jester Mod";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony _harmony = new Harmony("schlues.LCMikuJester");

		public static MikuJesterBase Instance;

		internal ManualLogSource mls;

		public AudioClip Intro { get; private set; }

		public AudioClip Solo { get; private set; }

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

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

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

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

		private void Awake()
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			mls = Logger.CreateLogSource("schlues.LCMikuJester");
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			else
			{
				mls.LogInfo((object)"MikuJester instance already running");
			}
			ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Mod", "EnableMod", true, "Enables the mod, otherwise doesn't load it");
			IntroEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "EnableCrankingIntro", true, "Enables the cranking to be replaced by Ievan Polkka intro");
			IntroVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "IntroVolume", 50, new ConfigDescription("Sets the volume of the cranking intro (in %)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			SoloEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "EnableScreamSolo", true, "Enables the scream to be replaced by Hatsune Miku's Ievan Polkka");
			SoloVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "SoloVolume", 100, new ConfigDescription("Sets the volume of the screaming solo (in %)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			if (!val.Value)
			{
				((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"MikuJester is disabled in config");
				return;
			}
			Intro = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "intro.wav");
			Solo = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "main.wav");
			_harmony.PatchAll(typeof(MikuJesterBase));
			_harmony.PatchAll(typeof(JesterAiPatch));
			mls.LogInfo((object)"Hatsune Miku Jester has awakened :3");
		}
	}
}
namespace LCMikuJester.Patches
{
	[HarmonyPatch(typeof(JesterAI))]
	public static class JesterAiPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void MikuJesterPatch(ref AudioClip ___popGoesTheWeaselTheme, ref AudioClip ___screamingSFX, ref AudioSource ___farAudio, ref AudioSource ___creatureVoice)
		{
			if (MikuJesterBase.Instance.IntroEnabled.Value)
			{
				___popGoesTheWeaselTheme = MikuJesterBase.Instance.Intro;
				___farAudio.volume = (float)MikuJesterBase.Instance.IntroVolume.Value / 100f;
			}
			if (MikuJesterBase.Instance.SoloEnabled.Value)
			{
				___screamingSFX = MikuJesterBase.Instance.Solo;
				___creatureVoice.volume = (float)MikuJesterBase.Instance.SoloVolume.Value / 100f;
			}
		}
	}
}