Decompiled source of DarudeJester v1.0.1

DarudeJester.dll

Decompiled 6 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 LCSoundTool;
using Microsoft.CodeAnalysis;
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("DarudeJester")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DarudeJester")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("E5A9D456-B06D-4FBC-A40E-190441538DF6")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DarudeJester
{
	[HarmonyPatch(typeof(JesterAI))]
	public static class JesterAiPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void JesterFreePatch(ref AudioClip ___popGoesTheWeaselTheme, ref AudioClip ___screamingSFX, ref AudioSource ___farAudio, ref AudioSource ___creatureVoice)
		{
			if (JesterFreeBase.Instance.IntroEnabled.Value)
			{
				___popGoesTheWeaselTheme = JesterFreeBase.Instance.Intro;
				___farAudio.volume = (float)JesterFreeBase.Instance.IntroVolume.Value / 100f;
			}
			if (JesterFreeBase.Instance.SoloEnabled.Value)
			{
				___screamingSFX = JesterFreeBase.Instance.Solo;
				___creatureVoice.volume = (float)JesterFreeBase.Instance.SoloVolume.Value / 100f;
			}
		}
	}
	[BepInPlugin("Longee.DarudeJester", "Darude Jester", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class JesterFreeBase : BaseUnityPlugin
	{
		private const string ModGuid = "Longee.DarudeJester";

		private readonly Harmony _harmony = new Harmony("Longee.DarudeJester");

		public static JesterFreeBase Instance { get; private set; }

		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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"Darude Jester instance already running");
				return;
			}
			Instance = this;
			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 Free Bird 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 Free Bird solo");
			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)"Darude Jester disabled in config");
				return;
			}
			((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"Starting Darude Jester");
			Intro = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "intro.wav");
			Solo = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "solo.wav");
			_harmony.PatchAll(typeof(JesterAiPatch));
			_harmony.PatchAll(typeof(JesterFreeBase));
			((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"Darude Jester is loaded");
		}
	}
}