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 OPJosMod.Patches;
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.3.0")]
public class OpJosMod : BaseUnityPlugin
{
private const string modGUID = "OpJosMod.SaferJetpack";
private const string modName = "SaferJetpack";
private const string modVersion = "1.3.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 bool Update(JetpackItem __instance)
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null)
{
return true;
}
if ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
((GrabbableObject)__instance).playerHeldBy.takingFallDamage = false;
((GrabbableObject)__instance).playerHeldBy.averageVelocity = 0f;
((GrabbableObject)__instance).itemProperties.requiresBattery = false;
__instance.jetpackBeepsAudio.volume = 0f;
}
FieldInfo field = typeof(JetpackItem).GetField("rayHit", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeof(JetpackItem).GetField("forces", BindingFlags.Instance | BindingFlags.NonPublic);
RaycastHit val = (RaycastHit)field.GetValue(__instance);
Vector3 val2 = (Vector3)field2.GetValue(__instance);
if (!((GrabbableObject)__instance).playerHeldBy.isPlayerDead && Physics.Raycast(((Component)((GrabbableObject)__instance).playerHeldBy).transform.position, val2, ref val, 25f, StartOfRound.Instance.allPlayersCollideWithMask, (QueryTriggerInteraction)1) && ((Vector3)(ref val2)).magnitude - ((RaycastHit)(ref val)).distance > 50f && ((RaycastHit)(ref val)).distance < 4f)
{
return false;
}
return true;
}
}
}