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 OPJosMod.Patches;
using Unity.Netcode;
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("OPJosMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OPJosMod")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("70095872-b952-4e27-bbc4-3d70d0238f39")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace OPJosMod.SaferJeptack
{
[BepInPlugin("OpJosMod.SaferJetpack", "SaferJetpack", "1.0.0.0")]
public class OpJosMod : BaseUnityPlugin
{
private const string modGUID = "OpJosMod.SaferJetpack";
private const string modName = "SaferJetpack";
private const string modVersion = "1.0.0.0";
private readonly Harmony harmony = new Harmony("OpJosMod.SaferJetpack");
private static OpJosMod Instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("OpJosMod.SaferJetpack");
mls.LogInfo((object)"SaferJetpack mod has started");
harmony.PatchAll(typeof(OpJosMod));
JetpackItemPatch.SetLogSource(mls);
harmony.PatchAll(typeof(JetpackItemPatch));
}
}
}
namespace OPJosMod.Patches
{
[HarmonyPatch(typeof(JetpackItem))]
internal class JetpackItemPatch
{
private static ManualLogSource mls;
public static void SetLogSource(ManualLogSource logSource)
{
mls = logSource;
}
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void Update(JetpackItem __instance)
{
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: 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)
//IL_01b1: 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_01c2: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null || !((NetworkBehaviour)__instance).IsOwner || (Object)(object)((GrabbableObject)__instance).playerHeldBy != (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
return;
}
if ((Object)(object)__instance != (Object)null)
{
FieldInfo field = typeof(JetpackItem).GetField("rayHit", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeof(JetpackItem).GetField("forces", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field3 = typeof(JetpackItem).GetField("jetpackPower", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field4 = typeof(JetpackItem).GetField("jetpackActivated", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null && field2 != null && field3 != null && field4 != null)
{
RaycastHit val = (RaycastHit)field.GetValue(__instance);
Vector3 val2 = (Vector3)field2.GetValue(__instance);
float num = (float)field3.GetValue(__instance);
bool flag = (bool)field4.GetValue(__instance);
((GrabbableObject)__instance).playerHeldBy.takingFallDamage = false;
((GrabbableObject)__instance).playerHeldBy.averageVelocity = 0f;
((GrabbableObject)__instance).itemProperties.requiresBattery = false;
if (flag)
{
num = Mathf.Clamp(num + Time.deltaTime * 10f, 0f, 500f);
}
else
{
num = Mathf.Clamp(num - Time.deltaTime * 75f, 0f, 1000f);
if (((GrabbableObject)__instance).playerHeldBy.thisController.isGrounded)
{
num = 0f;
}
}
val2 = Vector3.Lerp(val2, Vector3.ClampMagnitude(((Component)((GrabbableObject)__instance).playerHeldBy).transform.up * num, 400f), Time.deltaTime);
if (!((GrabbableObject)__instance).playerHeldBy.isPlayerDead && Physics.Raycast(((Component)((GrabbableObject)__instance).playerHeldBy).transform.position, val2, ref val, 25f, StartOfRound.Instance.allPlayersCollideWithMask) && ((Vector3)(ref val2)).magnitude - ((RaycastHit)(ref val)).distance > 50f && ((RaycastHit)(ref val)).distance < 4f)
{
PlayerControllerB playerHeldBy = ((GrabbableObject)__instance).playerHeldBy;
playerHeldBy.externalForces += val2;
throw new Exception("SaferJetpack: Cancelling original Update method");
}
}
else if (mls != null)
{
mls.LogInfo((object)"SaferJetpack(error): couldn't find a private field");
}
}
else if (mls != null)
{
mls.LogInfo((object)"SaferJetpack(error): __instance == null");
}
}
}
}