Decompiled source of BuckinghamPalaceJester v1.0.0

BuckinghamPalaceJester.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BuckinghamPalaceJester")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Mod to change the Jester sounds to be like the Duke of Edinburgh BBC radio meme")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BuckinghamPalaceJester")]
[assembly: AssemblyTitle("BuckinghamPalaceJester")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 BuckinghamPalaceJester
{
	[HarmonyPatch(typeof(JesterAI))]
	public static class JesterAiPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void BuckinghamPalaceJesterPatch(ref AudioClip ___popGoesTheWeaselTheme, ref AudioClip ___screamingSFX, ref AudioSource ___farAudio, ref AudioSource ___creatureVoice)
		{
			___popGoesTheWeaselTheme = BuckinghamPalaceJesterCore.Instance.Windup;
			___screamingSFX = BuckinghamPalaceJesterCore.Instance.Scream;
			___farAudio.volume = (float)BuckinghamPalaceJesterCore.Instance.JesterVolume.Value / 100f;
			___creatureVoice.volume = (float)BuckinghamPalaceJesterCore.Instance.JesterVolume.Value / 100f;
		}
	}
	[BepInPlugin("Vae.BuckinghamPalaceJester", "Buckingham Palace Jester", "1.0.0")]
	public class BuckinghamPalaceJesterCore : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("Vae.BuckinghamPalaceJester");

		public static BuckinghamPalaceJesterCore Instance { get; private set; }

		public AudioClip Windup { get; private set; }

		public AudioClip Scream { get; private set; }

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

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin BuckinghamPalaceJester is loaded!");
			if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.Log((LogLevel)8, (object)"BPJester Instance is currently running already");
				return;
			}
			Instance = this;
			ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Mod", "EnableMod", true, "Enables the mod");
			JesterVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "JesterVolume", 50, "Volume for the Jester");
			if (!val.Value)
			{
				((BaseUnityPlugin)this).Logger.Log((LogLevel)8, (object)"BPJester is disabled");
				return;
			}
			((BaseUnityPlugin)this).Logger.Log((LogLevel)8, (object)"BPJester is starting up!");
			Windup = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "windup.wav");
			Scream = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "scream.wav");
			_harmony.PatchAll(typeof(JesterAiPatch));
			_harmony.PatchAll(typeof(BuckinghamPalaceJesterCore));
			((BaseUnityPlugin)this).Logger.Log((LogLevel)8, (object)"BPJester sounds have been loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BuckinghamPalaceJester";

		public const string PLUGIN_NAME = "BuckinghamPalaceJester";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}