Decompiled source of RescueHookCustomizer v0.7.110

RescueHookCustomizer v0.7.110.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Photon.Pun;
using Unity.Profiling;
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("TestMode")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestMode")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d2645733-f963-4c1f-8730-d00109b9cf6f")]
[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 RescueHookCustomizer
{
	[BepInPlugin("Extern.RescueHookCustomizer", "RescueHookCustomizer", "0.7.110")]
	[ContentWarningPlugin("RescueHookCustomizer", "0.7.110", true)]
	public class Plugin : BaseUnityPlugin
	{
		private bool menu;

		private const float menuWidth = 300f;

		private const float menuHeight = 600f;

		private Rect menuRT;

		private KeyCode activationKey = (KeyCode)289;

		public static float range = 30f;

		private float sliderRange = 30f;

		public static float launchForce = 10f;

		private float sliderLaunchForce = 10f;

		public static float spring = 120f;

		private float sliderSpring = 120f;

		public static float forceOnSwingStop = 50f;

		private static float sliderForceOnSwingStop = 50f;

		public static float dragForce = 100f;

		private float sliderDragForce = 100f;

		public static float maxDistanceMultiplier = 0.65f;

		public static float minDistanceMultiplier = 0f;

		public static bool infinityCharges = false;

		public static bool spiderManMode = false;

		public static bool alternativeSpidermanMode = false;

		public static bool activeRagdollOnUse = true;

		public static bool useGravity = false;

		public static bool ragdollAndImpulseOnStopUse = false;

		public static bool movingInAir = false;

		public static bool dragForceOnOwner = true;

		private void Awake()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			LoadConfig();
			menuRT = new Rect((float)Screen.width - 300f, 0f, 300f, 600f);
			Harmony val = new Harmony("Extern.RescueHookCustomizer");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TestMode (by Extern) is loaded!");
		}

		private void Update()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(activationKey))
			{
				menu = !menu;
			}
		}

		private void OnGUI()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (menu)
			{
				menuRT = GUILayout.Window(1, menuRT, new WindowFunction(UserMenu), "Rescue hook customizer (by Extern) v0.7.110", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
		}

		public static void DestroyObj(Object obj)
		{
			Object.Destroy(obj);
		}

		private void LoadConfig()
		{
			if (PlayerPrefs.GetInt("haveSave") == 1)
			{
				infinityCharges = PlayerPrefs.GetInt("infinityCharges") == 1;
				spiderManMode = PlayerPrefs.GetInt("spiderManMode") == 1;
				activeRagdollOnUse = PlayerPrefs.GetInt("activeRagdollOnUse") == 1;
				useGravity = PlayerPrefs.GetInt("useGravity") == 1;
				ragdollAndImpulseOnStopUse = PlayerPrefs.GetInt("ragdollAndImpulseOnStopUse") == 1;
				movingInAir = PlayerPrefs.GetInt("movingInAir") == 1;
				alternativeSpidermanMode = PlayerPrefs.GetInt("alternativeSpidermanMode") == 1;
				dragForceOnOwner = PlayerPrefs.GetInt("dragForceOnOwner") == 1;
				range = PlayerPrefs.GetFloat("range");
				launchForce = PlayerPrefs.GetFloat("launchForce");
				spring = PlayerPrefs.GetFloat("spring");
				maxDistanceMultiplier = PlayerPrefs.GetFloat("maxDistanceMultiplier");
				minDistanceMultiplier = PlayerPrefs.GetFloat("minDistanceMultiplier");
				sliderRange = PlayerPrefs.GetFloat("sliderRange");
				sliderLaunchForce = PlayerPrefs.GetFloat("sliderLaunchForce");
				forceOnSwingStop = PlayerPrefs.GetFloat("forceOnSwingStop");
				dragForce = PlayerPrefs.GetFloat("dragForce");
			}
			else
			{
				PlayerPrefs.SetInt("haveSave", 1);
				SaveConfig();
			}
		}

		private void SaveConfig()
		{
			PlayerPrefs.SetInt("infinityCharges", infinityCharges ? 1 : 0);
			PlayerPrefs.SetInt("spiderManMode", spiderManMode ? 1 : 0);
			PlayerPrefs.SetInt("activeRagdollOnUse", activeRagdollOnUse ? 1 : 0);
			PlayerPrefs.SetInt("useGravity", useGravity ? 1 : 0);
			PlayerPrefs.SetInt("ragdollAndImpulseOnStopUse", ragdollAndImpulseOnStopUse ? 1 : 0);
			PlayerPrefs.SetInt("movingInAir", movingInAir ? 1 : 0);
			PlayerPrefs.SetInt("alternativeSpidermanMode", alternativeSpidermanMode ? 1 : 0);
			PlayerPrefs.SetInt("dragForceOnOwner", dragForceOnOwner ? 1 : 0);
			PlayerPrefs.SetFloat("range", range);
			PlayerPrefs.SetFloat("launchForce", launchForce);
			PlayerPrefs.SetFloat("spring", spring);
			PlayerPrefs.SetFloat("maxDistanceMultiplier", maxDistanceMultiplier);
			PlayerPrefs.SetFloat("minDistanceMultiplier", minDistanceMultiplier);
			PlayerPrefs.SetFloat("sliderRange", sliderRange);
			PlayerPrefs.SetFloat("sliderLaunchForce", sliderLaunchForce);
			PlayerPrefs.SetFloat("forceOnSwingStop", forceOnSwingStop);
			PlayerPrefs.SetFloat("dragForce", dragForce);
		}

		private void ResetProperties()
		{
			range = 30f;
			launchForce = 10f;
			infinityCharges = false;
			spiderManMode = false;
			activeRagdollOnUse = true;
			useGravity = false;
			ragdollAndImpulseOnStopUse = false;
			movingInAir = false;
			alternativeSpidermanMode = false;
			spring = 120f;
			maxDistanceMultiplier = 0.65f;
			minDistanceMultiplier = 0f;
			sliderRange = 30f;
			sliderLaunchForce = 10f;
			forceOnSwingStop = 50f;
			dragForceOnOwner = true;
		}

		private void UserMenu(int id)
		{
			infinityCharges = GUILayout.Toggle(infinityCharges, "Infinity charges", Array.Empty<GUILayoutOption>());
			spiderManMode = GUILayout.Toggle(spiderManMode, "Spiderman mode", Array.Empty<GUILayoutOption>());
			alternativeSpidermanMode = GUILayout.Toggle(alternativeSpidermanMode, "Alternative spiderman mode", Array.Empty<GUILayoutOption>());
			activeRagdollOnUse = GUILayout.Toggle(activeRagdollOnUse, "Active ragdoll on use", Array.Empty<GUILayoutOption>());
			useGravity = GUILayout.Toggle(useGravity, "Use gravity on fire", Array.Empty<GUILayoutOption>());
			ragdollAndImpulseOnStopUse = GUILayout.Toggle(ragdollAndImpulseOnStopUse, "Ragdoll and impulse on stop use", Array.Empty<GUILayoutOption>());
			movingInAir = GUILayout.Toggle(movingInAir, "Moving in air", Array.Empty<GUILayoutOption>());
			dragForceOnOwner = GUILayout.Toggle(dragForceOnOwner, "Drag force on owner", Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Range: {range} (default: {30f})", Array.Empty<GUILayoutOption>());
			sliderRange = GUILayout.HorizontalSlider(sliderRange, 1f, 1000f, Array.Empty<GUILayoutOption>());
			range = (int)sliderRange;
			GUILayout.Label($"Launch force: {launchForce} (default: {10f})", Array.Empty<GUILayoutOption>());
			sliderLaunchForce = GUILayout.HorizontalSlider(sliderLaunchForce, 1f, 500f, Array.Empty<GUILayoutOption>());
			launchForce = (int)sliderLaunchForce;
			GUILayout.Label($"Drag force: {dragForce} (default: {100f})", Array.Empty<GUILayoutOption>());
			sliderDragForce = GUILayout.HorizontalSlider(sliderDragForce, 1f, 10000f, Array.Empty<GUILayoutOption>());
			dragForce = (int)sliderDragForce;
			GUILayout.Label($"Spring: {spring} (default: {120f})", Array.Empty<GUILayoutOption>());
			sliderSpring = GUILayout.HorizontalSlider(sliderSpring, 1f, 1000f, Array.Empty<GUILayoutOption>());
			spring = (int)sliderSpring;
			GUILayout.Label($"Force on swing stop: {forceOnSwingStop} (default: {50f})", Array.Empty<GUILayoutOption>());
			sliderForceOnSwingStop = GUILayout.HorizontalSlider(sliderForceOnSwingStop, 1f, 5000f, Array.Empty<GUILayoutOption>());
			forceOnSwingStop = (int)sliderForceOnSwingStop;
			GUILayout.Label($"Max spring distance multiplier: {maxDistanceMultiplier} (default: {0.65f})", Array.Empty<GUILayoutOption>());
			maxDistanceMultiplier = GUILayout.HorizontalSlider(maxDistanceMultiplier, 0f, 2f, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Min spring distance multiplier: {minDistanceMultiplier} (default: {0f})", Array.Empty<GUILayoutOption>());
			minDistanceMultiplier = GUILayout.HorizontalSlider(minDistanceMultiplier, 0f, 2f, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Reset (no save)", (GUILayoutOption[])(object)new GUILayoutOption[0]))
			{
				ResetProperties();
			}
			if (GUILayout.Button("Save config", (GUILayoutOption[])(object)new GUILayoutOption[0]))
			{
				SaveConfig();
			}
			if (GUILayout.Button("Load config", (GUILayoutOption[])(object)new GUILayoutOption[0]))
			{
				LoadConfig();
			}
			GUI.DragWindow();
		}
	}
	public static class PluginConfig
	{
		public const float defaultRange = 30f;

		public const float leftRange = 1f;

		public const float rightRange = 1000f;

		public const float defaultLaunchForce = 10f;

		public const float leftLaunchForce = 1f;

		public const float rightLaunchForce = 500f;

		public const float springDefault = 120f;

		public const float springLeft = 1f;

		public const float springRight = 1000f;

		public const float damper = 60f;

		public const float massScale = 46f;

		public const float dragForceDefault = 100f;

		public const float dragForceLeft = 1f;

		public const float dragForceRight = 10000f;

		public const float distanceMultiplierLeft = 0f;

		public const float distanceMultiplierRight = 2f;

		public const float maxDistanceMultiplierDefault = 0.65f;

		public const float minDistanceMultiplierDefault = 0f;

		public const float forceOnSwingStopDefault = 50f;

		public const float leftForceOnSwingStop = 1f;

		public const float rightForceOnSwingStop = 5000f;

		public const bool infinityChargesDefault = false;

		public const bool spiderManModeDefault = false;

		public const bool alternativeSpidermanModeDefault = false;

		public const bool activeRagdollOnUseDefault = true;

		public const bool useGravityDefault = false;

		public const bool ragdollAndImpulseOnStopUseDefault = false;

		public const bool movingInAirDefault = false;

		public const bool dragForceOnOwnerDefault = true;
	}
	public class PluginInfo : BaseUnityPlugin
	{
		public const string pluginGuid = "Extern.RescueHookCustomizer";

		public const string pluginName = "RescueHookCustomizer";

		public const string pluginVersion = "0.7.110";
	}
}
namespace RescueHookCustomizer.Patch
{
	[HarmonyPatch(typeof(PlayerRagdoll))]
	public class PlayerRagdollPatch
	{
		public static FieldInfo playerField = typeof(PlayerRagdoll).GetField("player", BindingFlags.Instance | BindingFlags.NonPublic);

		public static FieldInfo rigListField = typeof(PlayerRagdoll).GetField("rigList", BindingFlags.Instance | BindingFlags.NonPublic);

		public static FieldInfo simplifiedFollowAnimMarkerField = typeof(PlayerRagdoll).GetField("simplifiedFollowAnimMarker", BindingFlags.Instance | BindingFlags.NonPublic);

		public static FieldInfo groundRaycastMarkerField = typeof(PlayerRagdoll).GetField("groundRaycastMarker", BindingFlags.Instance | BindingFlags.NonPublic);

		public static FieldInfo handleCollisionsMarkerField = typeof(PlayerRagdoll).GetField("handleCollisionsMarker", BindingFlags.Instance | BindingFlags.NonPublic);

		public static FieldInfo clearSavedCollisionsMarkerField = typeof(PlayerRagdoll).GetField("clearSavedCollisionsMarker", BindingFlags.Instance | BindingFlags.NonPublic);

		public static FieldInfo followAnimMarkerField = typeof(PlayerRagdoll).GetField("followAnimMarker", BindingFlags.Instance | BindingFlags.NonPublic);

		public static FieldInfo dragMarkerField = typeof(PlayerRagdoll).GetField("dragMarker", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo ragdollMethodInfo = typeof(Player).GetMethod("Ragdoll", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo toggleGravityMethodInfo = typeof(PlayerRagdoll).GetMethod("ToggleGravity", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo followAnimSimplifiedMethodInfo = typeof(PlayerRagdoll).GetMethod("FollowAnimSimplified", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo handleCollisionsMethodInfo = typeof(PlayerRagdoll).GetMethod("HandleCollisions", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo clearSavedCollisionsMethodInfo = typeof(PlayerRagdoll).GetMethod("ClearSavedCollisions", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo followAnimMethodInfo = typeof(PlayerRagdoll).GetMethod("FollowAnim", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo dragMethodInfo = typeof(PlayerRagdoll).GetMethod("Drag", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPatch("FixedUpdateHandled")]
		[HarmonyPrefix]
		public static bool FixedUpdateHandledPatch(PlayerRagdoll __instance)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_01b4: 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_01eb: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			Player val = (Player)playerField.GetValue(__instance);
			List<Rigidbody> list = (List<Rigidbody>)rigListField.GetValue(__instance);
			if ((bool)ragdollMethodInfo.Invoke(val, null) || (RescueHookPatch.swing && Plugin.useGravity))
			{
				if (!list[0].useGravity)
				{
					toggleGravityMethodInfo.Invoke(__instance, new object[1] { true });
				}
				return false;
			}
			if (list[0].useGravity)
			{
				toggleGravityMethodInfo.Invoke(__instance, new object[1] { false });
			}
			ProfilerMarker val2;
			if (val.data.simplifiedRagdoll)
			{
				val2 = (ProfilerMarker)simplifiedFollowAnimMarkerField.GetValue(__instance);
				AutoScope val3 = ((ProfilerMarker)(ref val2)).Auto();
				try
				{
					followAnimSimplifiedMethodInfo.Invoke(__instance, null);
					return false;
				}
				finally
				{
					((IDisposable)(AutoScope)(ref val3)).Dispose();
				}
			}
			val.data.groundBelow = false;
			val.data.groundBelow = val.data.isGrounded;
			val2 = (ProfilerMarker)groundRaycastMarkerField.GetValue(__instance);
			AutoScope val4 = ((ProfilerMarker)(ref val2)).Auto();
			try
			{
				if (val.refs.controller.alwaysGroundRaycast || (val.data.sinceGrounded < 0.1f && val.data.sinceJump > 0.25f && val.refs.controller.groundRaycast && ((Vector3)(ref val.data.movementVector)).magnitude > 0.1f))
				{
					__instance.GroundRaycast(false, false, false);
				}
				else
				{
					__instance.GroundRaycast(true, false, false);
				}
			}
			finally
			{
				((IDisposable)(AutoScope)(ref val4)).Dispose();
			}
			val2 = (ProfilerMarker)handleCollisionsMarkerField.GetValue(__instance);
			AutoScope val5 = ((ProfilerMarker)(ref val2)).Auto();
			try
			{
				handleCollisionsMethodInfo.Invoke(__instance, null);
			}
			finally
			{
				((IDisposable)(AutoScope)(ref val5)).Dispose();
			}
			val2 = (ProfilerMarker)clearSavedCollisionsMarkerField.GetValue(__instance);
			AutoScope val6 = ((ProfilerMarker)(ref val2)).Auto();
			try
			{
				clearSavedCollisionsMethodInfo.Invoke(__instance, null);
			}
			finally
			{
				((IDisposable)(AutoScope)(ref val6)).Dispose();
			}
			val2 = (ProfilerMarker)followAnimMarkerField.GetValue(__instance);
			AutoScope val7 = ((ProfilerMarker)(ref val2)).Auto();
			try
			{
				followAnimMethodInfo.Invoke(__instance, null);
			}
			finally
			{
				((IDisposable)(AutoScope)(ref val7)).Dispose();
			}
			val2 = (ProfilerMarker)dragMarkerField.GetValue(__instance);
			AutoScope val8 = ((ProfilerMarker)(ref val2)).Auto();
			try
			{
				dragMethodInfo.Invoke(__instance, null);
			}
			finally
			{
				((IDisposable)(AutoScope)(ref val8)).Dispose();
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(RescueHook))]
	public class RescueHookPatch
	{
		public const float gravity = 9.80665f;

		public static float startDistance;

		public static bool fireActive = false;

		public static bool swing = false;

		public static Vector3 lastPlayerPos;

		public static Vector3 _hit;

		public static SpringJoint joint;

		public static MethodInfo GetBodypart_PR = typeof(PlayerRagdoll).GetMethod("GetBodypart", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo AddForce_PR = typeof(PlayerRagdoll).GetMethod("AddForce", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[2]
		{
			typeof(Vector3),
			typeof(ForceMode)
		}, null);

		public static MethodInfo Fall_PR = typeof(PlayerRagdoll).GetMethod("Fall", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo Center_Player = typeof(Player).GetMethod("Center", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo LetGo = typeof(RescueHook).GetMethod("LetGo", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo toggleGravity = typeof(PlayerRagdoll).GetMethod("ToggleGravity", BindingFlags.Instance | BindingFlags.NonPublic);

		public static FieldInfo rigField = typeof(Bodypart).GetField("rig", BindingFlags.Instance | BindingFlags.NonPublic);

		public static FieldInfo rigListField = typeof(PlayerRagdoll).GetField("rigList", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPatch("Fire")]
		[HarmonyPrefix]
		private static bool FirePatch(RescueHook __instance, ref BatteryEntry ___m_batteryEntry, ref float ___sinceFire, ref Player ___playerHoldingItem)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.infinityCharges)
			{
				BatteryEntry obj = ___m_batteryEntry;
				obj.m_charge -= ___m_batteryEntry.m_maxCharge / (float)__instance.maxCharges;
			}
			((ItemDataEntry)___m_batteryEntry).SetDirty();
			___sinceFire = 0f;
			RaycastHit val = HelperFunctions.LineCheck(__instance.firePoint.position, __instance.firePoint.position + __instance.firePoint.forward * Plugin.range, (LayerType)5, 0f);
			MethodInfo method = typeof(RescueHook).GetMethod("RescueNothing", BindingFlags.Instance | BindingFlags.NonPublic);
			if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).transform))
			{
				method.Invoke(__instance, new object[1] { __instance.firePoint.position + __instance.firePoint.forward * Plugin.range });
				return false;
			}
			Player componentInParent = ((Component)((RaycastHit)(ref val)).transform).GetComponentInParent<Player>();
			if (Object.op_Implicit((Object)(object)componentInParent))
			{
				MethodInfo method2 = typeof(RescueHook).GetMethod("RescueRagdollCharacter", BindingFlags.Instance | BindingFlags.NonPublic);
				method2.Invoke(__instance, new object[2] { componentInParent, val });
				return false;
			}
			if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).rigidbody))
			{
				MethodInfo method3 = typeof(RescueHook).GetMethod("RescueWall", BindingFlags.Instance | BindingFlags.NonPublic);
				method3.Invoke(__instance, new object[1] { val });
				if (Plugin.spiderManMode || Plugin.alternativeSpidermanMode)
				{
					StartSwing(___playerHoldingItem, ((RaycastHit)(ref val)).point);
				}
				return false;
			}
			method.Invoke(__instance, new object[1] { ((RaycastHit)(ref val)).point });
			return false;
		}

		[HarmonyPatch("FixedUpdate")]
		[HarmonyPrefix]
		private static bool FixedUpdatePatch(RescueHook __instance, ref float ___sinceFire, ref Player ___targetPlayer, ref Vector3 ___targetPos, Rigidbody ___targetRig, ref Player ___playerHoldingItem, ref float ___massFactor, ref LineRenderer ___line)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_01b8: 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_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: 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_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_060f: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Expected O, but got Unknown
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Expected O, but got Unknown
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			___sinceFire += Time.fixedDeltaTime;
			Vector3 val2;
			if (swing && Plugin.alternativeSpidermanMode && (Object)(object)___playerHoldingItem.refs.ragdoll != (Object)null)
			{
				PlayerRagdoll ragdoll = ___playerHoldingItem.refs.ragdoll;
				Vector3 val = (Vector3)Center_Player.Invoke(___playerHoldingItem, null);
				val2 = _hit - val;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				float num = Vector3.Distance(val, _hit);
				Vector3 val3 = normalized * 9.80665f * (num / startDistance) * Plugin.spring * 10f;
				AddForce_PR.Invoke(ragdoll, new object[2]
				{
					val3,
					(object)(ForceMode)0
				});
			}
			if (__instance.isPulling && fireActive)
			{
				if (Object.op_Implicit((Object)(object)___targetPlayer))
				{
					___targetPos = ___targetRig.position;
				}
				if (___sinceFire > 0.25f)
				{
					PlayerRagdoll ragdoll2 = ___playerHoldingItem.refs.ragdoll;
					Bodypart obj = (Bodypart)GetBodypart_PR.Invoke(ragdoll2, new object[1] { (object)(BodypartType)17 });
					Rigidbody val4 = (Rigidbody)rigField.GetValue(obj);
					if (Object.op_Implicit((Object)(object)___targetPlayer))
					{
						PlayerRagdoll ragdoll3 = ___targetPlayer.refs.ragdoll;
						val2 = ((Component)__instance).transform.position - (Vector3)Center_Player.Invoke(___targetPlayer, null);
						Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
						AddForce_PR.Invoke(ragdoll3, new object[2]
						{
							normalized2 * (Plugin.dragForce / ___massFactor),
							(object)(ForceMode)5
						});
						___targetPlayer.data.sinceRescueDragged = 0f;
						___targetPlayer.data.sinceGrounded = Mathf.Clamp(___targetPlayer.data.sinceGrounded, 0f, 1f);
						if (Plugin.dragForceOnOwner)
						{
							AddForce_PR.Invoke(ragdoll2, new object[2]
							{
								-normalized2 * Plugin.dragForce * Mathf.Clamp(___massFactor, 0f, 10f) * 0.1f,
								(object)(ForceMode)5
							});
							val2 = ___targetRig.position - val4.position;
							val4.AddForce(((Vector3)(ref val2)).normalized * Plugin.dragForce * 0.3f, (ForceMode)5);
						}
						val2 = ((Component)__instance).transform.position - ___targetRig.position;
						___targetRig.AddForce(((Vector3)(ref val2)).normalized * Plugin.dragForce, (ForceMode)5);
						if (Vector3.Distance(__instance.dragPoint.position, ___targetRig.position) < 2f || ___sinceFire > 2f)
						{
							LetGo.Invoke(__instance, null);
						}
						else if (((ItemInstanceBehaviour)__instance).isHeldByMe && Player.localPlayer.input.clickWasPressed)
						{
							MethodInfo method = typeof(RescueHook).GetMethod("CallLetGo", BindingFlags.Instance | BindingFlags.NonPublic);
							method.Invoke(__instance, null);
						}
					}
					else
					{
						if (___playerHoldingItem.data.fallTime <= 0f && !__instance.hitNothing)
						{
							val2 = ___targetPos - (Vector3)Center_Player.Invoke(___playerHoldingItem, null);
							Vector3 normalized3 = ((Vector3)(ref val2)).normalized;
							__instance.fly = true;
							if (Plugin.activeRagdollOnUse)
							{
								Fall_PR.Invoke(ragdoll2, new object[1] { 2f });
							}
							if (Plugin.useGravity)
							{
								toggleGravity.Invoke(ragdoll2, new object[1] { true });
							}
							if (!Plugin.spiderManMode && !Plugin.alternativeSpidermanMode)
							{
								AddForce_PR.Invoke(ragdoll2, new object[2]
								{
									normalized3 * Plugin.launchForce,
									(object)(ForceMode)2
								});
								Bodypart obj2 = (Bodypart)GetBodypart_PR.Invoke(ragdoll2, new object[1] { (object)(BodypartType)17 });
								((Rigidbody)rigField.GetValue(obj2)).AddForce(normalized3 * Plugin.launchForce * 1f, (ForceMode)2);
								Bodypart obj3 = (Bodypart)GetBodypart_PR.Invoke(ragdoll2, new object[1] { (object)(BodypartType)2 });
								((Rigidbody)rigField.GetValue(obj3)).AddForce(normalized3 * Plugin.launchForce * 1f, (ForceMode)2);
							}
						}
						if (___sinceFire > 0.5f)
						{
							LetGo.Invoke(__instance, null);
						}
					}
				}
				__instance.ropeRender.DisplayRope(__instance.dragPoint.position, ___targetPos, ___sinceFire, ___line);
				__instance.currentDistance = Vector3.Distance(__instance.dragPoint.position, ___targetPos);
				return false;
			}
			__instance.fly = false;
			if (!Plugin.spiderManMode && !Plugin.alternativeSpidermanMode)
			{
				MethodInfo method2 = typeof(RescueHook).GetMethod("StopDisplayRope", BindingFlags.Instance | BindingFlags.NonPublic);
				method2.Invoke(__instance, null);
			}
			if ((Plugin.spiderManMode || Plugin.alternativeSpidermanMode) && fireActive && ((ItemInstanceBehaviour)__instance).isHeldByMe)
			{
				__instance.ropeRender.DisplayRope(__instance.dragPoint.position, ___targetPos, ___sinceFire, ___line);
				__instance.currentDistance = Vector3.Distance(__instance.dragPoint.position, ___targetPos);
			}
			return false;
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static bool UpdatePatch(RescueHook __instance, ref Player ___playerHoldingItem, ref BatteryEntry ___m_batteryEntry, ref float ___sinceFire)
		{
			bool flag = false;
			if (Object.op_Implicit((Object)(object)___playerHoldingItem))
			{
				if (___playerHoldingItem.input.aimIsPressed)
				{
					if (!__instance.lightObject.activeSelf)
					{
						__instance.lightObject.SetActive(true);
						__instance.darkObject.SetActive(false);
					}
				}
				else if (__instance.lightObject.activeSelf)
				{
					__instance.lightObject.SetActive(false);
					__instance.darkObject.SetActive(true);
				}
			}
			if (___m_batteryEntry.m_charge <= 0f)
			{
				flag = true;
			}
			if (((ItemInstanceBehaviour)__instance).isHeldByMe && Player.localPlayer.input.clickWasPressed && !Player.localPlayer.HasLockedInput() && ___sinceFire > 0.25f && !fireActive && !flag)
			{
				fireActive = true;
				MethodInfo method = typeof(RescueHook).GetMethod("Fire", BindingFlags.Instance | BindingFlags.NonPublic);
				method.Invoke(__instance, null);
			}
			else if (((ItemInstanceBehaviour)__instance).isHeldByMe && Player.localPlayer.input.clickWasReleased && fireActive)
			{
				fireActive = false;
				if (Plugin.spiderManMode || Plugin.alternativeSpidermanMode)
				{
					MethodInfo method2 = typeof(RescueHook).GetMethod("StopDisplayRope", BindingFlags.Instance | BindingFlags.NonPublic);
					method2.Invoke(__instance, null);
					StopSwing(___playerHoldingItem);
				}
			}
			OnUpdateReturn(___playerHoldingItem);
			return false;
		}

		private static void StartSwing(Player playerHoldingItem, Vector3 hit)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			if (!swing)
			{
				swing = true;
				_hit = hit;
				Bodypart obj = (Bodypart)GetBodypart_PR.Invoke(playerHoldingItem.refs.ragdoll, new object[1] { (object)(BodypartType)2 });
				joint = ((Component)(Rigidbody)rigField.GetValue(obj)).gameObject.AddComponent<SpringJoint>();
				((Joint)joint).autoConfigureConnectedAnchor = false;
				((Joint)joint).connectedAnchor = hit;
				Vector3 val = (Vector3)Center_Player.Invoke(playerHoldingItem, null);
				float num = Vector3.Distance(hit, val);
				joint.maxDistance = num * Plugin.maxDistanceMultiplier;
				joint.minDistance = num * Plugin.minDistanceMultiplier;
				joint.spring = Plugin.spring;
				joint.damper = 60f;
				((Joint)joint).massScale = 46f;
				lastPlayerPos = val;
				if (Plugin.alternativeSpidermanMode)
				{
					startDistance = Vector3.Distance(val, hit);
				}
			}
		}

		private static void StopSwing(Player playerHoldingItem)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if (swing)
			{
				swing = false;
				playerHoldingItem.data.sinceGrounded = 0f;
				Plugin.DestroyObj((Object)(object)joint);
				Vector3 val = (Vector3)Center_Player.Invoke(playerHoldingItem, null) - lastPlayerPos;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				Console.WriteLine(normalized);
				if (Plugin.ragdollAndImpulseOnStopUse)
				{
					Fall_PR.Invoke(playerHoldingItem.refs.ragdoll, new object[1] { 2f });
					AddForce_PR.Invoke(playerHoldingItem.refs.ragdoll, new object[2]
					{
						normalized * Plugin.forceOnSwingStop,
						(object)(ForceMode)1
					});
				}
			}
		}

		private static void OnUpdateReturn(Player playerHoldingItem)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (swing)
			{
				lastPlayerPos = (Vector3)Center_Player.Invoke(playerHoldingItem, null);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerController))]
	public class PlayerControllerPatch
	{
		public static MethodInfo ragdollMethodInfo = typeof(Player).GetMethod("Ragdoll", BindingFlags.Instance | BindingFlags.NonPublic);

		public static FieldInfo playerField = typeof(PlayerController).GetField("player", BindingFlags.Instance | BindingFlags.NonPublic);

		public static FieldInfo jumpForceTimeField = typeof(PlayerController).GetField("jumpForceTime", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo simpleMovementMethodInfo = typeof(PlayerController).GetMethod("SimpleMovement", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo constantGravityMethodInfo = typeof(PlayerController).GetMethod("ConstantGravity", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo gravityMethodInfo = typeof(PlayerController).GetMethod("Gravity", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo standingMethodInfo = typeof(PlayerController).GetMethod("Standing", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo movementMethodInfo = typeof(PlayerController).GetMethod("Movement", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo bodyRotationMethodInfo = typeof(PlayerController).GetMethod("BodyRotation", BindingFlags.Instance | BindingFlags.NonPublic);

		public static MethodInfo applyJumpForceMethodInfo = typeof(PlayerController).GetMethod("ApplyJumpForce", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPatch("FixedUpdate")]
		[HarmonyPrefix]
		private static bool FixedUpdatePatch(PlayerController __instance)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Player val = (Player)playerField.GetValue(__instance);
			if ((bool)ragdollMethodInfo.Invoke(val, null) || (!Plugin.movingInAir && RescueHookPatch.swing))
			{
				return false;
			}
			if (!val.data.physicsAreReady)
			{
				return false;
			}
			if (val.data.simplifiedRagdoll && val.refs.view.IsMine)
			{
				simpleMovementMethodInfo.Invoke(__instance, null);
				return false;
			}
			if (!val.data.carried)
			{
				if (!RescueHookPatch.swing)
				{
					constantGravityMethodInfo.Invoke(__instance, null);
				}
				else
				{
					val.data.sinceGrounded = 0f;
				}
				if (!val.data.isGrounded)
				{
					if (!RescueHookPatch.swing)
					{
						gravityMethodInfo.Invoke(__instance, null);
					}
				}
				else
				{
					standingMethodInfo.Invoke(__instance, null);
				}
			}
			movementMethodInfo.Invoke(__instance, null);
			bodyRotationMethodInfo.Invoke(__instance, null);
			if ((float)jumpForceTimeField.GetValue(__instance) > 0f)
			{
				applyJumpForceMethodInfo.Invoke(__instance, null);
			}
			return false;
		}

		[HarmonyPatch("TryJump")]
		[HarmonyPrefix]
		public static bool TryJumpPatch(PlayerController __instance)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			Player val = (Player)playerField.GetValue(__instance);
			if (val.data.sinceGrounded < 0.5f && val.data.sinceJump > 0.6f && ((!RescueHookPatch.swing && !Plugin.movingInAir) || Plugin.movingInAir))
			{
				val.refs.view.RPC("RPCA_Jump", (RpcTarget)0, Array.Empty<object>());
				val.data.isCrouching = false;
			}
			return false;
		}
	}
}