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("Kraut-VanillaDeathHeadHopper-v1.0.0", "VanillaDeathHeadHopper", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public const string modGUID = "Kraut-VanillaDeathHeadHopper-v1.0.0";
public const string modName = "VanillaDeathHeadHopper";
public const string modVersion = "1.0.0";
public static Plugin PluginInstance;
public static ManualLogSource LoggerInstance;
private readonly Harmony harmony = new Harmony("Kraut-VanillaDeathHeadHopper-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 = 1f;
[HarmonyPrefix]
[HarmonyPatch("Update")]
private static void PreFixUpdate(PlayerDeathHead __instance, PhysGrabObject ___physGrabObject)
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: 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_014d: 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_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: 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_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: 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_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: 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;
}
else if (Input.GetKey((KeyCode)32))
{
jumpTimer = 1f;
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;
}
val3 += Vector3.up;
val3 = ((Vector3)(ref val3)).normalized;
val3 *= 4.8f;
___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);
}
}
public static bool CanSpectate()
{
return true;
}
}
[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();
}
}
}