Decompiled source of PFSJester v1.1.3

PFSJester.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("PFSJester")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PFSJester")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("30f6f9f8-0b7f-4c05-87d0-73985a87a330")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.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 PFSJester
{
	[HarmonyPatch(typeof(JesterAI))]
	public static class JesterAiPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void PFSJesterPatch(ref AudioClip ___popGoesTheWeaselTheme, ref AudioClip ___screamingSFX, ref AudioSource ___farAudio, ref AudioSource ___creatureVoice)
		{
			if (PFSJester.Instance.IntroEnabled.Value)
			{
				___popGoesTheWeaselTheme = PFSJester.Instance.Intro;
				___farAudio.volume = (float)PFSJester.Instance.IntroVolume.Value / 100f;
			}
			if (PFSJester.Instance.AfterSoundBegun.Value)
			{
				___screamingSFX = PFSJester.Instance.AfterPop;
				___creatureVoice.volume = (float)PFSJester.Instance.AfterSoundVolume.Value / 100f;
			}
		}
	}
	[BepInPlugin("pin.PFSJester", "Fitness Jester", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class PFSJester : BaseUnityPlugin
	{
		private const string ModGuid = "pin.PFSJester";

		private readonly Harmony _harmony = new Harmony("pin.PFSJester");

		public static PFSJester Instance { get; private set; }

		public AudioClip Intro { get; private set; }

		public AudioClip AfterPop { get; private set; }

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

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

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

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

		public ConfigEntry<int> SoundChoice { 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
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"PFSJester 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.");
			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>()));
			AfterSoundBegun = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "EnableAfterPop", true, "Enables the after pop noise to be replaced.");
			AfterSoundVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "AfterSoundVolume", 100, new ConfigDescription("Sets the volume of the after pop noise (in %)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			SoundChoice = ((BaseUnityPlugin)this).Config.Bind<int>("Sound", "SoundChoice", 0, new ConfigDescription("Sets sound based on the input (fitness = 0, freebird = 1, deviltrigger = 3, more to come)", (AcceptableValueBase)null, Array.Empty<object>()));
			if (!val.Value)
			{
				((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"PFSJester disabled in config");
				return;
			}
			((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"Starting PFSJester");
			if (SoundChoice.Value == 0)
			{
				Intro = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "fitnessintro.wav");
				AfterPop = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "fitnesspop.wav");
			}
			else if (SoundChoice.Value == 1)
			{
				Intro = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "freebirdintro.wav");
				AfterPop = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "freebirdpop.wav");
			}
			else if (SoundChoice.Value == 3)
			{
				Intro = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "deviltriggerintro.wav");
				AfterPop = SoundTool.GetAudioClip(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "deviltriggerpop.wav");
			}
			_harmony.PatchAll(typeof(JesterAiPatch));
			_harmony.PatchAll(typeof(PFSJester));
			((BaseUnityPlugin)this).Logger.Log((LogLevel)16, (object)"PFSJester is loaded");
		}
	}
}