Decompiled source of JassterClap v1.1.0

JassterClap.dll

Decompiled 9 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.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("JassterClap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JassterClap")]
[assembly: AssemblyTitle("JassterClap")]
[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 JassterClap
{
	[BepInPlugin("JassterClap", "JassterClap", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class JassterClap : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "JassterClap";

		private readonly Harmony _harmony = new Harmony("JassterClap");

		public static JassterClap Instance { get; private set; }

		public AudioClip CrankSFX { get; private set; }

		public AudioClip ScreamSFX { get; private set; }

		public AudioClip KillPlayerSFX { get; private set; }

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

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

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

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

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

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

		private void Awake()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"JassterClap instance already running");
				return;
			}
			Instance = this;
			ConfigEntry<bool> obj = ((BaseUnityPlugin)this).Config.Bind<bool>("Mod", "EnableMod", true, "Enables the mod");
			CrankSFXEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "EnableCrank", true, "Enables the cranking SFX to be replaced by Assclap");
			CrankSFXVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "CrankVolume", 100, new ConfigDescription("Sets the volume of the cranking SFX phase (in %)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			ScreamSFXEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "EnableScream", true, "Enables the scream SFX to be replaced by Assclap");
			ScreamSFXVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "ScreamVolume", 100, new ConfigDescription("Sets the volume of the scream SFX phase (in %)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			KillPlayerSFXEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "EnableScream", true, "Enables the kill player SFX to be replaced by Assclap");
			KillPlayerSFXVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "ScreamVolume", 100, new ConfigDescription("Sets the volume of the kill player SFX phase (in %)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			if (!obj.Value)
			{
				((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"JassterClap is disabled in config!");
				return;
			}
			((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"JassterClap is starting!");
			CrankSFX = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "getyourassbackhere.wav");
			ScreamSFX = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "aniki.wav");
			KillPlayerSFX = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "youmakemecome.wav");
			_harmony.PatchAll(typeof(JesterAiPatch));
			_harmony.PatchAll(typeof(JassterClap));
			((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"JassterClap is loaded.");
		}
	}
	[HarmonyPatch(typeof(JesterAI))]
	public static class JesterAiPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void JassterClapPatch(ref AudioClip ___popGoesTheWeaselTheme, ref AudioClip ___screamingSFX, ref AudioClip ___killPlayerSFX, ref AudioSource ___farAudio, ref AudioSource ___creatureVoice)
		{
			if (JassterClap.Instance.CrankSFXEnabled.Value)
			{
				___popGoesTheWeaselTheme = JassterClap.Instance.CrankSFX;
				___farAudio.volume = (float)JassterClap.Instance.CrankSFXVolume.Value / 100f;
			}
			if (JassterClap.Instance.ScreamSFXEnabled.Value)
			{
				___screamingSFX = JassterClap.Instance.ScreamSFX;
				___creatureVoice.volume = (float)JassterClap.Instance.ScreamSFXVolume.Value / 100f;
			}
			if (JassterClap.Instance.KillPlayerSFXEnabled.Value)
			{
				___killPlayerSFX = JassterClap.Instance.KillPlayerSFX;
				___creatureVoice.volume = (float)JassterClap.Instance.KillPlayerSFXVolume.Value / 100f;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "JassterClap";

		public const string PLUGIN_NAME = "JassterClap";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}