Decompiled source of EnhanceDeadHead v1.0.1

EnhanceDeadHead.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
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("EnhanceDeadHead")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EnhanceDeadHead")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("353430f6-63e9-4c60-9b86-be9630758a77")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EnhanceDeadHead;

[BepInPlugin("com.repo.kr.EnhanceDeadHead", "EnhanceDeadHead", "1.0.0")]
public class ModBehaviour : BaseUnityPlugin
{
	[HarmonyPatch(typeof(SpectateCamera))]
	public class SpectateCamera_path
	{
		[HarmonyPatch("HeadEnergyLogic")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> HeadEnergyLogic_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldfld && list[i].operand is FieldInfo fieldInfo && fieldInfo.Name == "headEnergy" && list[i + 4].opcode == OpCodes.Add)
				{
					Debug.Log((object)"find headEnergy");
					list.Insert(i + 2, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(SpectateCamera_path), "setheadEnergy", (Type[])null, (Type[])null)));
					break;
				}
			}
			return list;
		}

		private static float setheadEnergy(float dataOriginal)
		{
			return dataOriginal * (float)headEnergyMultiplier.Value;
		}
	}

	[HarmonyPatch(typeof(PlayerDeathHead))]
	public class PlayerDeathHead_path
	{
		[HarmonyPatch("Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].operand is FieldInfo fieldInfo)
				{
					if (list[i].opcode == OpCodes.Stfld && fieldInfo.Name == "spectatedJumpForce")
					{
						Debug.Log((object)"find spectatedJumpForce");
						list.Insert(i, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerDeathHead_path), "setJumpForce", (Type[])null, (Type[])null)));
						break;
					}
					if (list[i].opcode == OpCodes.Ldfld && fieldInfo.Name == "spectatedJumpGrounded")
					{
						Debug.Log((object)"find spectatedJumpGrounded,spectatedJumpCooldown and spectatedJumpChargeAmount");
						list.Insert(i + 10, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerDeathHead_path), "setJumpChargeAmount", (Type[])null, (Type[])null)));
						list.Insert(i + 4, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerDeathHead_path), "setJumpCooldown", (Type[])null, (Type[])null)));
						list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerDeathHead_path), "setJumpGrounded", (Type[])null, (Type[])null)));
						i += 3;
					}
				}
			}
			return list;
		}

		private static float setJumpForce(float dataOriginal)
		{
			return dataOriginal * (float)headJumpForceMultiplier.Value;
		}

		private static float setJumpChargeAmount(float dataOriginal)
		{
			return dataOriginal * (float)headJumpChargeMultiplier.Value;
		}

		private static bool setJumpGrounded(bool dataOriginal)
		{
			if (headJumpNoCooldown.Value)
			{
				dataOriginal = true;
			}
			return dataOriginal;
		}

		private static float setJumpCooldown(float dataOriginal)
		{
			if (headJumpNoCooldown.Value)
			{
				dataOriginal = 0f;
			}
			return dataOriginal;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Update_Postfix(PlayerDeathHead __instance)
		{
			if (RebornInExtraction.Value)
			{
				__instance.Revive();
			}
		}
	}

	private Harmony harmony;

	private static ManualLogSource Log;

	private static ConfigEntry<bool> RebornInExtraction;

	private static ConfigEntry<bool> headJumpNoCooldown;

	private static ConfigEntry<int> headEnergyMultiplier;

	private static ConfigEntry<int> headJumpChargeMultiplier;

	private static ConfigEntry<int> headJumpForceMultiplier;

	private void Awake()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Expected O, but got Unknown
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Expected O, but got Unknown
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Expected O, but got Unknown
		harmony = new Harmony("com.repo.kr.EnhanceDeadHead");
		harmony.PatchAll();
		RebornInExtraction = ((BaseUnityPlugin)this).Config.Bind<bool>("Host Client Options", "RebornInExtraction", true, "Dead Head Reborn In Extraction Point");
		headJumpNoCooldown = ((BaseUnityPlugin)this).Config.Bind<bool>("Host Client Options", "headJumpNoCooldown", true, "Dead Head Jump No Need Cooldown");
		headEnergyMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("Client Options", "headEnergyMultiplier", 10, new ConfigDescription("Dead Head Energy Recovery Speed", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), Array.Empty<object>()));
		headJumpChargeMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("Host Client Options", "headJumpChargeMultiplier", 0, new ConfigDescription("Dead Head Jump Charge Speed Multiplier", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), Array.Empty<object>()));
		headJumpForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("Host Client Options", "headJumpForceMultiplier", 3, new ConfigDescription("Dead Head Jump Force Multiplier", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), Array.Empty<object>()));
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"EnhanceDeadHead enble");
	}
}