Decompiled source of ChillGuyJester v1.0.4

JesterFree.dll

Decompiled 5 hours 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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("JesterFree")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JesterFree")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("E5A9D456-B06D-4FBC-A40E-190441538DF6")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("2.0.0.0")]
namespace JesterFree;

[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("AriDev.JesterFree", "Jester Free", "2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class JesterFreeBase : BaseUnityPlugin
{
	private const string ModGuid = "AriDev.JesterFree";

	private readonly Harmony _harmony = new Harmony("AriDev.JesterFree");

	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_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Expected O, but got Unknown
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Expected O, but got Unknown
		if ((Object)(object)Instance != (Object)null)
		{
			((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"Jester Free instance already running");
			return;
		}
		Instance = this;
		ConfigEntry<bool> obj = ((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 (!obj.Value)
		{
			((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"Jester Free disabled in config");
			return;
		}
		((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"Starting Jester Free");
		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)"Jester Free is loaded");
	}
}