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.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("DeathHeadHopper Vanilla Compatible Controls Add-on")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DeathHeadHopper Vanilla Compatible Controls Add-on")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("49f88b43-8b07-4398-9bd7-2a3cd261c7ac")]
[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 Root
{
[BepInPlugin("MrNull-Devz", "FunDeathHopper", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string modGUID = "MrNull-Devz-FunDeathHopper-v1.0.0";
public const string modName = "FunDeathHopper";
public const string modVersion = "1.0.0";
public static Plugin PluginInstance;
public static ManualLogSource LoggerInstance;
private readonly Harmony harmony = new Harmony("MrNull-Devz-FunDeathHopper-v1.0.0");
public void Awake()
{
if ((Object)(object)PluginInstance == (Object)null)
{
PluginInstance = this;
}
LoggerInstance = ((BaseUnityPlugin)PluginInstance).Logger;
harmony.PatchAll();
}
}
}
namespace Patches
{
[HarmonyPatch(typeof(PlayerDeathHead))]
internal class PlayerDeathHeadPatch
{
private static float jumpTimer;
private static float Speed;
[HarmonyPrefix]
[HarmonyPatch("Update")]
private static void PreFixUpdate(PlayerDeathHead __instance, PhysGrabObject ___physGrabObject)
{
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null || (Object)(object)___physGrabObject == (Object)null || (Object)(object)__instance.playerAvatar == (Object)null || (Object)(object)__instance.playerAvatar.photonView == (Object)null || !__instance.playerAvatar.photonView.IsMine || !(bool)AccessTools.Field(typeof(PlayerDeathHead), "triggered").GetValue(__instance))
{
return;
}
((Component)__instance.playerAvatar).transform.position = ((Component)___physGrabObject).transform.position;
if (SemiFunc.InputMovementX() != 0f || SemiFunc.InputMovementY() != 0f)
{
AccessTools.Field(typeof(SpectateCamera), "player").SetValue(SpectateCamera.instance, __instance.playerAvatar);
}
if (jumpTimer > 0f)
{
jumpTimer -= Time.deltaTime;
return;
}
if (Input.GetKey((KeyCode)32))
{
jumpTimer = 0.05f;
Vector3 val = Vector3.ProjectOnPlane(((Component)Camera.main).transform.forward, Vector3.up);
Vector3 normalized = ((Vector3)(ref val)).normalized;
Vector3 val2 = Vector3.Cross(Vector3.up, normalized);
Vector3 val3 = Vector3.zero;
float num = SemiFunc.InputMovementX();
float num2 = SemiFunc.InputMovementY();
if (num2 > 0f)
{
val3 += normalized;
}
if (num2 < 0f)
{
val3 -= normalized;
}
if (num < 0f)
{
val3 -= val2;
}
if (num > 0f)
{
val3 += val2;
}
if (Input.GetKey((KeyCode)114))
{
val = val3 + Vector3.up * 5f;
val3 = ((Vector3)(ref val)).normalized;
}
val3 = ((Vector3)(ref val3)).normalized;
val3 *= Speed;
___physGrabObject.GrabLink(__instance.playerAvatar.photonView.ViewID, 0, __instance.playerAvatar.physGrabber.physGrabPointPullerPosition - val3, Vector3.zero, Vector3.zero);
___physGrabObject.GrabStarted(__instance.playerAvatar.physGrabber);
___physGrabObject.GrabEnded(__instance.playerAvatar.physGrabber);
}
if (Input.GetKeyDown((KeyCode)101))
{
Speed = Mathf.Clamp(Speed + 0.5f, 1.5f, 6.5f);
Debug.Log((object)("Speed Increased: " + Speed));
}
if (Input.GetKeyDown((KeyCode)113))
{
Speed = Mathf.Clamp(Speed - 0.5f, 1.5f, 6.5f);
Debug.Log((object)("Speed Decreased: " + Speed));
}
}
public static bool CanSpectate()
{
return true;
}
static PlayerDeathHeadPatch()
{
Speed = 1.5f;
}
}
[HarmonyPatch(typeof(SpectateCamera))]
internal class SpectateCameraPatch
{
private static readonly FieldInfo f_isDisabled = AccessTools.Field(typeof(PlayerAvatar), "isDisabled");
private static readonly MethodInfo m_inputDown = AccessTools.Method(typeof(SemiFunc), "InputDown", (Type[])null, (Type[])null);
private static readonly MethodInfo m_playerSwitch = AccessTools.Method(typeof(SpectateCamera), "PlayerSwitch", (Type[])null, (Type[])null);
[HarmonyPatch("StateNormal")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> StateNormal_Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = instructions.ToList();
int num = list.FindIndex((CodeInstruction ci) => CodeInstructionExtensions.Calls(ci, m_inputDown)) - 1;
if (num <= 0 || list[num].opcode != OpCodes.Ldc_I4_1)
{
return instructions;
}
int num2 = list.FindIndex(num, (CodeInstruction ci) => CodeInstructionExtensions.Calls(ci, m_playerSwitch));
if (num2 == -1)
{
return instructions;
}
list[num].opcode = OpCodes.Nop;
list.RemoveRange(num + 1, num2 - num);
return list.AsEnumerable();
}
}
}