Decompiled source of Jester Sounds v1.0.0

JesterSounds.dll

Decompiled a day 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 HarmonyLib;
using JesterSounds;
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("JesterSounds")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JesterSounds")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7321b7f8-d856-49cc-8d75-2e7b65ad53d5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("xk.JesterSounds", "JesterSounds", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private const string modGuid = "xk.JesterSounds";

	private const string modName = "JesterSounds";

	private const string modVersion = "1.0.0";

	private readonly Harmony _harmony = new Harmony("xk.JesterSounds");

	public static Plugin Instance { get; private set; }

	public AudioClip ReadyAudio { get; private set; }

	public AudioClip CheasingAudio { get; private set; }

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

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

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

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

	private void Awake()
	{
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Expected O, but got Unknown
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Expected O, but got Unknown
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Expected O, but got Unknown
		if (!((Object)(object)Instance != (Object)null))
		{
			Instance = this;
			ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Mod", "EnableMod", true, "是否启用mod");
			ReadyEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "盒子开始拉杆", true, "拉杆前替换音效");
			ReadyVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "拉杆音量", 50, new ConfigDescription("拉杆的音量 (in %)", (AcceptableValueBase)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			CheasingEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "盒子开始尖叫", true, "尖叫前替换音效");
			CheasingVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "尖叫音量", 100, new ConfigDescription("尖叫的音量 (in %)", (AcceptableValueBase)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			if (val.Value)
			{
				ReadyAudio = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "ready.mp3");
				CheasingAudio = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "cheasing.mp3");
				_harmony.PatchAll(typeof(JesterSoundsPatch));
				_harmony.PatchAll(typeof(Plugin));
			}
		}
	}
}
namespace JesterSounds;

[HarmonyPatch(typeof(JesterAI))]
public static class JesterSoundsPatch
{
	[HarmonyPatch("Start")]
	[HarmonyPostfix]
	private static void JesterSoundsPatche(ref AudioClip ___popGoesTheWeaselTheme, ref AudioClip ___screamingSFX, ref AudioSource ___farAudio, ref AudioSource ___creatureVoice)
	{
		if (Plugin.Instance.ReadyEnabled.Value)
		{
			___popGoesTheWeaselTheme = Plugin.Instance.ReadyAudio;
			___farAudio.volume = (float)Plugin.Instance.ReadyVolume.Value / 100f;
		}
		if (Plugin.Instance.CheasingEnabled.Value)
		{
			___screamingSFX = Plugin.Instance.CheasingAudio;
			___creatureVoice.volume = (float)Plugin.Instance.CheasingVolume.Value / 100f;
		}
	}
}