Decompiled source of JesterStompShake v1.0.8

JesterStompShake.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using JesterStompShake.Patches;
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("RadiationIsCool")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RadiationIsCool")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8ee335db-0cbe-470c-8fbc-69263f01b35a")]
[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 JesterStompShake
{
	[BepInPlugin("Piggy.JesterStompShake", "JesterStompShake", "1.0.0")]
	public class JesterStompShakeModBase : BaseUnityPlugin
	{
		private const string modGUID = "Piggy.JesterStompShake";

		private const string modName = "JesterStompShake";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Piggy.JesterStompShake");

		private static JesterStompShakeModBase Instance;

		internal ManualLogSource mls;

		public static int ShakeIntensity;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Piggy.JesterStompShake");
			ShakeIntensity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Shake Intensity", 2, "Camera shake intensity (1-3)").Value;
			mls.LogInfo((object)"Jester Stomp Shake is loaded");
			PlayerControllerBPatch.shakeIntensity = ShakeIntensity;
			harmony.PatchAll(typeof(JesterStompShakeModBase));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(PlayAudioAnimationEventPatch));
			harmony.PatchAll(typeof(JesterStompCheck));
		}
	}
}
namespace JesterStompShake.Patches
{
	[HarmonyPatch(typeof(PlayAudioAnimationEvent))]
	internal class PlayAudioAnimationEventPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("PlayAudio2RandomClip")]
		private static void PlayAudio2RandomClip_Patch()
		{
			JesterStompCheck.jesterStomped = true;
		}
	}
	public static class JesterStompCheck
	{
		public static bool jesterStomped;
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		public static int shakeIntensity;

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Update_Postfix(ref Transform ___thisPlayerBody, ref bool ___isCameraDisabled)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (___isCameraDisabled)
			{
				return;
			}
			JesterAI[] array = Object.FindObjectsOfType<JesterAI>();
			JesterAI[] array2 = array;
			foreach (JesterAI val in array2)
			{
				float num = Vector3.Distance(___thisPlayerBody.position, ((Component)val).gameObject.transform.position);
				if (num > 0f && num < 2f && JesterStompCheck.jesterStomped && ((EnemyAI)val).currentBehaviourStateIndex == 2)
				{
					if (shakeIntensity == 1)
					{
						HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
					}
					else if (shakeIntensity == 2)
					{
						HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
					}
					else if (shakeIntensity == 3)
					{
						HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
					}
					JesterStompCheck.jesterStomped = false;
				}
				else if (num > 2f && num < 4f && JesterStompCheck.jesterStomped && ((EnemyAI)val).currentBehaviourStateIndex == 2)
				{
					if (shakeIntensity == 1)
					{
						HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
					}
					else if (shakeIntensity == 2)
					{
						HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
					}
					else if (shakeIntensity == 3)
					{
						HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
					}
					JesterStompCheck.jesterStomped = false;
				}
				else if (num > 4f && num < 35f && JesterStompCheck.jesterStomped && ((EnemyAI)val).currentBehaviourStateIndex == 2)
				{
					if (shakeIntensity == 2)
					{
						HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
					}
					else if (shakeIntensity == 3)
					{
						HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
					}
					JesterStompCheck.jesterStomped = false;
				}
			}
		}
	}
}