Decompiled source of JesterSacrifice v1.0.0

JesterSacrifice.dll

Decompiled 3 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using JesterSacrifice.Patches;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("JesterAcceptSacrifice")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JesterAcceptSacrifice")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("edeb15d9-234a-4ce0-b8c6-fab88dea8008")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace JesterSacrifice
{
	[BepInPlugin("Mayple.JesterSacrificeMod", "Jester Sacrifice Mod", "1.0.0")]
	public class JesterSacrificeBase : BaseUnityPlugin
	{
		private const string modGUID = "Mayple.JesterSacrificeMod";

		private const string modName = "Jester Sacrifice Mod";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Mayple.JesterSacrificeMod");

		private static JesterSacrificeBase Instance;

		public static ManualLogSource log;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			log = Logger.CreateLogSource("Mayple.JesterSacrificeMod");
			log.LogInfo((object)"Jester Sacrifice mod has awaken");
			harmony.PatchAll(typeof(JesterSacrificeBase));
			harmony.PatchAll(typeof(JesterAIPatch));
		}
	}
}
namespace JesterSacrifice.Patches
{
	[HarmonyPatch(typeof(JesterAI))]
	internal class JesterAIPatch
	{
		public static bool killedPlayer;

		[HarmonyPatch("SetJesterInitialValues")]
		[HarmonyPostfix]
		private static void JesterSacrificePatch()
		{
			killedPlayer = false;
		}

		[HarmonyPatch("OnCollideWithPlayer")]
		[HarmonyPostfix]
		private static void CollideWithPlayerPatch(ref bool ___inKillAnimation)
		{
			if (___inKillAnimation)
			{
				JesterSacrificeBase.log.LogInfo((object)"Jester killed enemy!");
				killedPlayer = true;
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void JesterDespawn(JesterAI __instance, ref int ___previousState)
		{
			if (___previousState == 2 && ((EnemyAI)__instance).currentBehaviourStateIndex == 0 && killedPlayer && ((NetworkBehaviour)__instance).IsServer && ((EnemyAI)__instance).thisNetworkObject.IsSpawned)
			{
				JesterSacrificeBase.log.LogInfo((object)"Jester sacrifice accepted!");
				((EnemyAI)__instance).thisNetworkObject.Despawn(true);
			}
		}
	}
}