Decompiled source of RopeSwingingMod v1.0.0

Rope Swing Mod.dll

Decompiled 5 days 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 BepInEx.Configuration;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
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("Rope Swing Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Rope Swing Mod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2ed9ebbe-f95c-429b-9ed7-975d295ad4f9")]
[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")]
[BepInPlugin("com.lamia.ropeswing", "RopeSwing", "1.0.0")]
public class RopeSwing : BaseUnityPlugin
{
	internal static ConfigEntry<float> Acceleration;

	internal static ConfigEntry<float> MaxSpeed;

	internal static ConfigEntry<float> PumpBoost;

	internal static ConfigEntry<float> CoastDamping;

	internal static ConfigEntry<float> SteeringDamping;

	internal static ConfigEntry<float> ClimberLoad;

	internal static ConfigEntry<float> JumpAirDrag;

	internal static ConfigEntry<KeyCode> Forward;

	internal static ConfigEntry<KeyCode> Back;

	internal static ConfigEntry<KeyCode> Left;

	internal static ConfigEntry<KeyCode> Right;

	private Harmony harmony;

	private void Awake()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Expected O, but got Unknown
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Expected O, but got Unknown
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Expected O, but got Unknown
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Expected O, but got Unknown
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Expected O, but got Unknown
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Expected O, but got Unknown
		Acceleration = ((BaseUnityPlugin)this).Config.Bind<float>("Swing Physics", "Acceleration", 12f, new ConfigDescription("Full swing acceleration in metres per second squared. Starts at half this value and builds over six seconds of active swinging.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 40f), Array.Empty<object>()));
		MaxSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Swing Physics", "DriveSpeed", 10f, new ConfigDescription("Short-rope speed where input stops adding energy. Longer reaches scale this up with leverage. Gravity and existing momentum remain free.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 20f), Array.Empty<object>()));
		PumpBoost = ((BaseUnityPlugin)this).Config.Bind<float>("Swing Physics", "PumpBoost", 0.2f, new ConfigDescription("Extra drive when pressing along the direction of travel. Reverse input brakes immediately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		CoastDamping = ((BaseUnityPlugin)this).Config.Bind<float>("Swing Physics", "CoastDamping", 0.12f, new ConfigDescription("Gentle tangential drag while occupied, in inverse seconds. Zero preserves all momentum.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.5f), Array.Empty<object>()));
		SteeringDamping = ((BaseUnityPlugin)this).Config.Bind<float>("Swing Physics", "SteeringDamping", 0.65f, new ConfigDescription("Extra drag perpendicular to the combined input. Reduces sideways wandering without resisting the requested direction.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
		ClimberLoad = ((BaseUnityPlugin)this).Config.Bind<float>("Swing Physics", "ClimberLoad", 0.75f, new ConfigDescription("Extra downward acceleration from a climber, spread across nearby segments. Does not change segment mass.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
		JumpAirDrag = ((BaseUnityPlugin)this).Config.Bind<float>("Swing Physics", "JumpAirDrag", 0.8f, new ConfigDescription("Initial air resistance after a rope jump, per second. Scales with rope speed and fades immediately back to native PEAK drag over 1.8 seconds. Never adds thrust.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
		Forward = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("RopeSwing", "FlyKey", (KeyCode)304, "Swing forward.");
		Back = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("RopeSwing", "SwingBackwards", (KeyCode)306, "Swing backward.");
		Left = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("RopeSwing", "SwingLeft", (KeyCode)97, "Swing left.");
		Right = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("RopeSwing", "SwingRight", (KeyCode)100, "Swing right.");
		harmony = new Harmony("com.lamia.ropeswing");
		harmony.PatchAll(typeof(RopeSwing).Assembly);
		Character[] array = Object.FindObjectsByType<Character>((FindObjectsSortMode)0);
		foreach (Character character in array)
		{
			Attach(character);
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)"RopeSwing 1.0.0 loaded. All clients need 1.0.0. Force-based climbing and cooperative swinging enabled.");
	}

	internal static void Attach(Character character)
	{
		if (!Object.op_Implicit((Object)(object)((Component)character).GetComponent<RopeSwingInput>()))
		{
			((Component)character).gameObject.AddComponent<RopeSwingInput>();
		}
	}

	private void OnDestroy()
	{
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchSelf();
		}
		RopeSwingInput[] array = Object.FindObjectsByType<RopeSwingInput>((FindObjectsSortMode)0);
		foreach (RopeSwingInput ropeSwingInput in array)
		{
			ropeSwingInput.ResetTracking();
		}
	}
}
[HarmonyPatch(typeof(Character), "Awake")]
internal static class AttachSwingInput
{
	private static void Postfix(Character __instance)
	{
		RopeSwing.Attach(__instance);
	}
}
[HarmonyPatch(typeof(CharacterRopeHandling), "Update")]
internal static class SwingClimbAngle
{
	private static void Prefix(CharacterRopeHandling __instance)
	{
		__instance.maxRopeAngle = 150f;
	}
}
[HarmonyPatch(typeof(RopeSyncer), "ShouldSendData")]
internal static class SyncOccupiedRope
{
	private static void Postfix(RopeSyncer __instance, ref bool __result, ref bool ___updateVisualizerManually)
	{
		Rope rope = __instance.rope;
		if (Object.op_Implicit((Object)(object)rope) && ((MonoBehaviourPun)rope).photonView.IsMine && !rope.creatorLeft && rope.isClimbable && rope.charactersClimbing.Count > 0 && rope.SegmentCount > 0)
		{
			___updateVisualizerManually = false;
			__result = true;
		}
	}
}
public class RopeSwingInput : MonoBehaviourPun
{
	private struct ClimbCollisionPair
	{
		internal Collider Body;

		internal Collider Other;

		internal ClimbCollisionPair(Collider body, Collider other)
		{
			Body = body;
			Other = other;
		}
	}

	private int velocityRopeId;

	private Vector3 ownerVelocity;

	private double ownerSampleTime = double.NegativeInfinity;

	private float ownerSampleReceived = float.NegativeInfinity;

	private float nextVelocitySend;

	private Player velocitySender;

	private Rope trackingRope;

	private Vector3 previousTarget;

	private Vector3 targetVelocity;

	private readonly List<ClimbCollisionPair> climbCollisionPairs = new List<ClimbCollisionPair>();

	private Rope collisionRope;

	private float nextCollisionRefresh;

	private bool launchAirActive;

	private float launchTime;

	private float launchStrength;

	private Rope rampRope;

	private float rampSeconds;

	private Rope followedRope;

	private Vector3 followedVelocity;

	private Character character;

	private Vector3 remoteInput;

	private Vector3 localInput;

	private Vector3 lastSentInput;

	private int remoteRopeId;

	private float remotePercent;

	private float lastReceived = float.NegativeInfinity;

	private float nextSend;

	private bool sentClimbing;

	private int lastSentRopeId;

	internal static bool IsFiniteVelocity(Vector3 value)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return Finite(value);
	}

	private static bool Finite(Vector3 value)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		return !float.IsNaN(value.x) && !float.IsInfinity(value.x) && !float.IsNaN(value.y) && !float.IsInfinity(value.y) && !float.IsNaN(value.z) && !float.IsInfinity(value.z);
	}

	[PunRPC]
	public void RopeSwingVelocityRpc(int ropeId, Vector3 velocity, double sampleTime, PhotonMessageInfo info)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: 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_0107: 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_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)character) || !character.IsLocal || !character.data.isRopeClimbing || !Finite(velocity) || double.IsNaN(sampleTime) || double.IsInfinity(sampleTime))
		{
			return;
		}
		Rope heldRope = character.data.heldRope;
		if (!Object.op_Implicit((Object)(object)heldRope) || !Object.op_Implicit((Object)(object)((MonoBehaviourPun)heldRope).photonView) || ((MonoBehaviourPun)heldRope).photonView.ViewID != ropeId)
		{
			return;
		}
		Player val = ((MonoBehaviourPun)heldRope).photonView.Owner ?? PhotonNetwork.MasterClient;
		if (info.Sender != null && info.Sender == val)
		{
			double num = PhotonNetwork.Time - sampleTime;
			if (!(num < -0.1) && !(num > 0.5) && (velocityRopeId != ropeId || velocitySender != info.Sender || !(sampleTime <= ownerSampleTime)))
			{
				velocityRopeId = ropeId;
				velocitySender = info.Sender;
				ownerVelocity = velocity;
				ownerSampleTime = sampleTime;
				ownerSampleReceived = Time.unscaledTime;
			}
		}
	}

	internal Vector3 GripVelocity(Rope rope, Vector3 fallback)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		Player val = ((MonoBehaviourPun)rope).photonView.Owner ?? PhotonNetwork.MasterClient;
		return (velocityRopeId == ((MonoBehaviourPun)rope).photonView.ViewID && velocitySender == val && Time.unscaledTime - ownerSampleReceived <= 0.25f && PhotonNetwork.Time - ownerSampleTime <= 0.35) ? ownerVelocity : fallback;
	}

	internal void SendRopeVelocity(Rope rope, float percent)
	{
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: 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)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
		if (!((MonoBehaviourPun)rope).photonView.IsMine || !PhotonNetwork.InRoom || !Object.op_Implicit((Object)(object)((MonoBehaviourPun)this).photonView) || ((MonoBehaviourPun)this).photonView.IsMine || ((MonoBehaviourPun)this).photonView.Owner == null || Time.unscaledTime < nextVelocitySend)
		{
			return;
		}
		Transform segmentFromPercent = rope.climbingAPI.GetSegmentFromPercent(percent);
		Rigidbody val = default(Rigidbody);
		if (Object.op_Implicit((Object)(object)segmentFromPercent) && ((Component)segmentFromPercent).TryGetComponent<Rigidbody>(ref val))
		{
			Vector3 val2 = rope.climbingAPI.GetPosition(percent) + character.data.ropeClimbNormal * 0.5f;
			Vector3 pointVelocity = val.GetPointVelocity(val2);
			if (Finite(pointVelocity))
			{
				((MonoBehaviourPun)this).photonView.RPC("RopeSwingVelocityRpc", ((MonoBehaviourPun)this).photonView.Owner, new object[3]
				{
					((MonoBehaviourPun)rope).photonView.ViewID,
					pointVelocity,
					PhotonNetwork.Time
				});
				nextVelocitySend = Time.unscaledTime + 0.05f;
			}
		}
	}

	internal Vector3 TrackVelocity(Rope rope, Vector3 target)
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//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_001a: 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_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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)
		if ((Object)(object)trackingRope != (Object)(object)rope)
		{
			trackingRope = rope;
			previousTarget = target;
			targetVelocity = Vector3.zero;
			return targetVelocity;
		}
		Vector3 val = target - previousTarget;
		Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 9f) ? Vector3.zero : Vector3.ClampMagnitude(val / Time.fixedDeltaTime, 60f));
		previousTarget = target;
		targetVelocity = Vector3.Lerp(targetVelocity, val2, 1f - Mathf.Exp((0f - Time.fixedDeltaTime) / 0.06f));
		return targetVelocity;
	}

	internal void ResetTracking(bool clearFlight = true)
	{
		//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_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		RestoreClimbCollisions();
		if (clearFlight)
		{
			launchAirActive = false;
			launchStrength = 0f;
		}
		rampRope = null;
		rampSeconds = 0f;
		trackingRope = null;
		targetVelocity = Vector3.zero;
		ownerSampleReceived = float.NegativeInfinity;
		followedRope = null;
		followedVelocity = Vector3.zero;
	}

	private void RestoreClimbCollisions()
	{
		foreach (ClimbCollisionPair climbCollisionPair in climbCollisionPairs)
		{
			if (Object.op_Implicit((Object)(object)climbCollisionPair.Body) && Object.op_Implicit((Object)(object)climbCollisionPair.Other))
			{
				Physics.IgnoreCollision(climbCollisionPair.Body, climbCollisionPair.Other, false);
			}
		}
		climbCollisionPairs.Clear();
		collisionRope = null;
		nextCollisionRefresh = 0f;
	}

	private void IgnoreClimbPair(Collider body, Collider other)
	{
		if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)other) && !((Object)(object)body == (Object)(object)other) && !body.isTrigger && !other.isTrigger && !Physics.GetIgnoreCollision(body, other))
		{
			Physics.IgnoreCollision(body, other, true);
			climbCollisionPairs.Add(new ClimbCollisionPair(body, other));
		}
	}

	private void UpdateClimbCollisions(Rope rope)
	{
		if ((Object)(object)collisionRope != (Object)(object)rope)
		{
			RestoreClimbCollisions();
		}
		if (!Object.op_Implicit((Object)(object)rope) || !Object.op_Implicit((Object)(object)character) || !Object.op_Implicit((Object)(object)character.refs.ragdoll))
		{
			return;
		}
		collisionRope = rope;
		if (Time.unscaledTime < nextCollisionRefresh)
		{
			return;
		}
		nextCollisionRefresh = Time.unscaledTime + 0.25f;
		RestoreClimbCollisions();
		collisionRope = rope;
		nextCollisionRefresh = Time.unscaledTime + 0.25f;
		Collider[] componentsInChildren = ((Component)character.refs.ragdoll).GetComponentsInChildren<Collider>();
		Collider[] componentsInChildren2 = ((Component)rope).GetComponentsInChildren<Collider>();
		Collider[] array = componentsInChildren;
		foreach (Collider body in array)
		{
			Collider[] array2 = componentsInChildren2;
			foreach (Collider other in array2)
			{
				IgnoreClimbPair(body, other);
			}
			foreach (Character item in rope.charactersClimbing)
			{
				if (Object.op_Implicit((Object)(object)item) && !((Object)(object)item == (Object)(object)character) && item.data.isRopeClimbing && !((Object)(object)item.data.heldRope != (Object)(object)rope) && Object.op_Implicit((Object)(object)item.refs.ragdoll))
				{
					Collider[] componentsInChildren3 = ((Component)item.refs.ragdoll).GetComponentsInChildren<Collider>();
					foreach (Collider other2 in componentsInChildren3)
					{
						IgnoreClimbPair(body, other2);
					}
				}
			}
		}
	}

	internal void Follow(Rope rope, Vector3 velocity)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		launchAirActive = false;
		followedRope = rope;
		followedVelocity = velocity;
	}

	internal bool TryCarrierVelocity(out Vector3 velocity)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: 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)
		velocity = Vector3.zero;
		if (!Object.op_Implicit((Object)(object)character) || !character.IsLocal || !character.data.isRopeClimbing || !Object.op_Implicit((Object)(object)followedRope) || (Object)(object)character.data.heldRope != (Object)(object)followedRope)
		{
			return false;
		}
		velocity = GripVelocity(followedRope, followedVelocity);
		if (!Finite(velocity))
		{
			return false;
		}
		velocity = Vector3.ClampMagnitude(velocity, 60f);
		return true;
	}

	internal float DriveStrength(Rope rope, Vector3 input)
	{
		if ((Object)(object)rampRope != (Object)(object)rope)
		{
			rampRope = rope;
			rampSeconds = 0f;
		}
		if (((Vector3)(ref input)).sqrMagnitude > 0.0001f)
		{
			rampSeconds = Mathf.Min(6f, rampSeconds + Time.fixedDeltaTime);
		}
		else
		{
			rampSeconds = Mathf.Max(0f, rampSeconds - Time.fixedDeltaTime);
		}
		return Mathf.Lerp(0.5f, 1f, Mathf.SmoothStep(0f, 1f, rampSeconds / 6f));
	}

	internal bool TryLaunchRetention(float nativeRetention, out float retention)
	{
		retention = 1f;
		if (!launchAirActive || !Object.op_Implicit((Object)(object)character) || !character.IsLocal || character.data.isRopeClimbing)
		{
			return false;
		}
		if ((Time.time > launchTime + 0.2f && character.data.isGrounded) || character.data.currentRagdollControll < 0.3f)
		{
			launchAirActive = false;
			return false;
		}
		float num = Mathf.Max(0f, Time.time - launchTime);
		if (num >= 1.8f)
		{
			launchAirActive = false;
			return false;
		}
		float num2 = launchStrength * (1f - Mathf.Clamp01(num / 1.8f));
		float num3 = Mathf.Exp((0f - RopeSwing.JumpAirDrag.Value) * Time.fixedDeltaTime);
		retention = Mathf.Lerp(nativeRetention, num3, num2);
		return true;
	}

	internal void PrepareRelease(bool jumped)
	{
		//IL_003c: 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_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_00ac: 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_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: 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_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: 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_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: 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_0289: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: 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_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: 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_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)character) || !character.IsLocal || !character.data.isRopeClimbing)
		{
			return;
		}
		Vector3 val = Vector3.zero;
		bool flag = jumped && Object.op_Implicit((Object)(object)character) && character.IsLocal && Object.op_Implicit((Object)(object)followedRope) && (Object)(object)character.data.heldRope == (Object)(object)followedRope;
		if (flag)
		{
			Rope val2 = followedRope;
			val = GripVelocity(val2, followedVelocity);
			if (((MonoBehaviourPun)val2).photonView.IsMine && Object.op_Implicit((Object)(object)val2.climbingAPI) && val2.SegmentCount > 1)
			{
				float num = Mathf.Clamp01(character.data.ropePercent);
				Transform segmentFromPercent = val2.climbingAPI.GetSegmentFromPercent(num);
				Vector3 val3 = val2.climbingAPI.GetPosition(num) + character.data.ropeClimbNormal * 0.5f;
				Rigidbody val4 = default(Rigidbody);
				if (Object.op_Implicit((Object)(object)segmentFromPercent) && ((Component)segmentFromPercent).TryGetComponent<Rigidbody>(ref val4))
				{
					val = val4.GetPointVelocity(val3);
				}
			}
			flag = Finite(val);
		}
		float num2 = (flag ? ((Vector3)(ref val)).magnitude : 0f);
		float num3 = Mathf.InverseLerp(0.5f, 12f, num2);
		flag = flag && num3 > 0f;
		if (flag)
		{
			val *= 1f / 3f;
		}
		if (flag && ((Vector3)(ref val)).sqrMagnitude > 0.01f)
		{
			Vector3 val5 = Vector3.zero;
			float num4 = 0f;
			foreach (Bodypart part in character.refs.ragdoll.partList)
			{
				if (Object.op_Implicit((Object)(object)part.Rig) && !part.Rig.isKinematic)
				{
					val5 += part.Rig.linearVelocity * part.Rig.mass;
					num4 += part.Rig.mass;
				}
			}
			if (num4 > 0f)
			{
				val5 /= num4;
				Vector3 val6 = val - val5;
				foreach (Bodypart part2 in character.refs.ragdoll.partList)
				{
					if (Object.op_Implicit((Object)(object)part2.Rig) && !part2.Rig.isKinematic)
					{
						Rigidbody rig = part2.Rig;
						rig.linearVelocity += val6;
					}
				}
			}
		}
		ResetTracking();
		if (flag)
		{
			launchAirActive = true;
			launchTime = Time.time;
			launchStrength = num3;
		}
	}

	private void OnDisable()
	{
		ResetTracking();
	}

	private void OnDestroy()
	{
		ResetTracking();
	}

	private void Awake()
	{
		character = ((Component)this).GetComponent<Character>();
	}

	[PunRPC]
	public void RopeSwingInputRpc(Vector3 direction, int ropeId, float percent, PhotonMessageInfo info)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)((MonoBehaviourPun)this).photonView) && info.Sender != null && info.Sender == ((MonoBehaviourPun)this).photonView.Owner && !float.IsNaN(direction.x) && !float.IsInfinity(direction.x) && !float.IsNaN(direction.y) && !float.IsInfinity(direction.y) && !float.IsNaN(direction.z) && !float.IsInfinity(direction.z) && !float.IsNaN(percent) && !float.IsInfinity(percent))
		{
			direction.y = 0f;
			remoteInput = Vector3.ClampMagnitude(direction, 1f);
			remoteRopeId = ropeId;
			remotePercent = Mathf.Clamp01(percent);
			lastReceived = Time.unscaledTime;
		}
	}

	private void Update()
	{
		//IL_0093: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: 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)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: 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_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_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: 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_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: 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_016f: 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_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)character) || (Object)(object)character.data == (Object)null || !Object.op_Implicit((Object)(object)((MonoBehaviourPun)this).photonView))
		{
			return;
		}
		bool flag = character.data.isRopeClimbing && Object.op_Implicit((Object)(object)character.data.heldRope);
		if (!flag)
		{
			ResetTracking(clearFlight: false);
		}
		UpdateClimbCollisions(flag ? character.data.heldRope : null);
		Vector3 val = Vector3.zero;
		if (!character.IsLocal)
		{
			return;
		}
		Vector3 val2;
		if (flag)
		{
			float num = (Input.GetKey(RopeSwing.Forward.Value) ? 1f : 0f) - (Input.GetKey(RopeSwing.Back.Value) ? 1f : 0f);
			float num2 = (Input.GetKey(RopeSwing.Right.Value) ? 1f : 0f) - (Input.GetKey(RopeSwing.Left.Value) ? 1f : 0f);
			val2 = Vector3.ProjectOnPlane(character.data.lookDirection_Flat, Vector3.up);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			val = Vector3.ClampMagnitude(normalized * num + Vector3.Cross(Vector3.up, normalized) * num2, 1f);
		}
		int num3 = (flag ? ((MonoBehaviourPun)character.data.heldRope).photonView.ViewID : 0);
		if (PhotonNetwork.InRoom)
		{
			if (!flag)
			{
				goto IL_01e4;
			}
			if (!(Time.unscaledTime >= nextSend) && num3 == lastSentRopeId)
			{
				val2 = val - lastSentInput;
				if (!(((Vector3)(ref val2)).sqrMagnitude > 0.04f))
				{
					goto IL_01e4;
				}
			}
			goto IL_01fc;
		}
		goto IL_0272;
		IL_01e4:
		if (!flag && sentClimbing)
		{
			goto IL_01fc;
		}
		goto IL_0272;
		IL_01fc:
		((MonoBehaviourPun)this).photonView.RPC("RopeSwingInputRpc", (RpcTarget)1, new object[3]
		{
			val,
			num3,
			flag ? character.data.ropePercent : 0f
		});
		nextSend = Time.unscaledTime + 0.05f;
		sentClimbing = flag;
		lastSentRopeId = num3;
		lastSentInput = val;
		goto IL_0272;
		IL_0272:
		localInput = val;
	}

	internal Vector3 GetInput(Rope rope, out float percent)
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		percent = 0f;
		if (!((Behaviour)this).isActiveAndEnabled || !Object.op_Implicit((Object)(object)character) || !character.data.isRopeClimbing || (Object)(object)character.data.heldRope != (Object)(object)rope)
		{
			return Vector3.zero;
		}
		if (character.IsLocal)
		{
			percent = Mathf.Clamp01(character.data.ropePercent);
			return localInput;
		}
		bool flag = remoteRopeId == ((MonoBehaviourPun)rope).photonView.ViewID && Time.unscaledTime - lastReceived <= 0.35f;
		percent = (flag ? remotePercent : Mathf.Clamp01(character.data.ropePercent));
		return flag ? remoteInput : Vector3.zero;
	}
}
[HarmonyPatch(typeof(Rope), "FixedUpdate")]
internal static class SwingPhysics
{
	private static readonly Dictionary<Rigidbody, Vector3> Drive = new Dictionary<Rigidbody, Vector3>();

	private static readonly Dictionary<Rigidbody, float> ReachScale = new Dictionary<Rigidbody, float>();

	private static readonly Dictionary<Rigidbody, float> Loads = new Dictionary<Rigidbody, float>();

	private static readonly List<float> ArcDistance = new List<float>();

	private static readonly HashSet<Character> Occupants = new HashSet<Character>();

	private static void Postfix(Rope __instance)
	{
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_040b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0403: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_049f: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04be: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0460: Unknown result type (might be due to invalid IL or missing references)
		//IL_0467: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0501: Unknown result type (might be due to invalid IL or missing references)
		//IL_0506: Unknown result type (might be due to invalid IL or missing references)
		//IL_0508: Unknown result type (might be due to invalid IL or missing references)
		//IL_050a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0519: Unknown result type (might be due to invalid IL or missing references)
		//IL_051e: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0563: Unknown result type (might be due to invalid IL or missing references)
		//IL_056a: Unknown result type (might be due to invalid IL or missing references)
		//IL_056f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0538: Unknown result type (might be due to invalid IL or missing references)
		//IL_053c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0541: Unknown result type (might be due to invalid IL or missing references)
		//IL_0546: Unknown result type (might be due to invalid IL or missing references)
		//IL_0548: Unknown result type (might be due to invalid IL or missing references)
		//IL_054a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0556: 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_0560: Unknown result type (might be due to invalid IL or missing references)
		//IL_0587: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_062f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0641: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		//IL_037f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_038b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		if (!((MonoBehaviourPun)__instance).photonView.IsMine || __instance.creatorLeft || !__instance.isClimbable || __instance.antigrav || !Object.op_Implicit((Object)(object)__instance.climbingAPI) || __instance.charactersClimbing.Count == 0)
		{
			return;
		}
		List<Transform> ropeSegments = __instance.GetRopeSegments();
		if (ropeSegments.Count < 2)
		{
			return;
		}
		ArcDistance.Clear();
		ArcDistance.Add(0f);
		for (int i = 1; i < ropeSegments.Count; i++)
		{
			ArcDistance.Add(ArcDistance[i - 1] + Vector3.Distance(ropeSegments[i - 1].position, ropeSegments[i].position));
		}
		Drive.Clear();
		ReachScale.Clear();
		Loads.Clear();
		Occupants.Clear();
		RopeSwingInput ropeSwingInput = default(RopeSwingInput);
		Rigidbody val = default(Rigidbody);
		Rigidbody val2 = default(Rigidbody);
		foreach (Character item in __instance.charactersClimbing)
		{
			if (!Object.op_Implicit((Object)(object)item) || !Occupants.Add(item) || !((Component)item).TryGetComponent<RopeSwingInput>(ref ropeSwingInput))
			{
				continue;
			}
			float percent;
			Vector3 input = ropeSwingInput.GetInput(__instance, out percent);
			if (!item.data.isRopeClimbing || (Object)(object)item.data.heldRope != (Object)(object)__instance)
			{
				continue;
			}
			ropeSwingInput.SendRopeVelocity(__instance, percent);
			Transform segmentFromPercent = __instance.climbingAPI.GetSegmentFromPercent(percent);
			int num = ropeSegments.IndexOf(segmentFromPercent);
			if (num < 0)
			{
				continue;
			}
			for (int j = Mathf.Max(1, num - 1); j <= Mathf.Min(ropeSegments.Count - 1, num + 1); j++)
			{
				if (((Component)ropeSegments[j]).TryGetComponent<Rigidbody>(ref val) && !val.isKinematic)
				{
					Loads.TryGetValue(val, out var value);
					Loads[val] = Mathf.Max(value, RopeSwing.ClimberLoad.Value * ((j == num) ? 1f : 0.5f));
				}
			}
			float num2 = ropeSwingInput.DriveStrength(__instance, input);
			if (((Vector3)(ref input)).sqrMagnitude < 0.0001f)
			{
				continue;
			}
			float num3 = Mathf.Max(0.5f, ArcDistance[num]);
			float num4 = Mathf.Clamp(Mathf.Sqrt(Mathf.Max(1f, num3 / 5f)), 1f, 2.5f);
			for (int k = 1; k < ropeSegments.Count; k++)
			{
				if (((Component)ropeSegments[k]).TryGetComponent<Rigidbody>(ref val2) && !val2.isKinematic)
				{
					Vector3 val3 = val2.worldCenterOfMass - ropeSegments[0].position;
					if (((Vector3)(ref val3)).sqrMagnitude < 0.0625f)
					{
						val3 = ropeSegments[k].up;
					}
					Vector3 val4 = Vector3.ProjectOnPlane(input, ((Vector3)(ref val3)).normalized);
					float num5 = Mathf.Clamp(ArcDistance[k] / num3, 0f, 1.5f);
					float num6 = num4 * num5;
					Drive.TryGetValue(val2, out var value2);
					Drive[val2] = value2 + val4 * (num6 * num2);
					ReachScale.TryGetValue(val2, out var value3);
					ReachScale[val2] = Mathf.Max(value3, num6);
				}
			}
		}
		Rigidbody val6 = default(Rigidbody);
		Vector3 val5 = (((Component)ropeSegments[0]).TryGetComponent<Rigidbody>(ref val6) ? val6.linearVelocity : Vector3.zero);
		Rigidbody val7 = default(Rigidbody);
		for (int l = 1; l < ropeSegments.Count; l++)
		{
			if (((Component)ropeSegments[l]).TryGetComponent<Rigidbody>(ref val7) && !val7.isKinematic)
			{
				Loads.TryGetValue(val7, out var value4);
				if (value4 > 0f)
				{
					val7.AddForce(Vector3.down * value4, (ForceMode)5);
				}
				Drive.TryGetValue(val7, out var value5);
				ReachScale.TryGetValue(val7, out var value6);
				value6 = Mathf.Max(0.01f, value6);
				Vector3 val8 = Vector3.ClampMagnitude(value5, 1.5f * value6);
				Vector3 val9 = val7.worldCenterOfMass - ropeSegments[0].position;
				if (((Vector3)(ref val9)).sqrMagnitude < 0.0625f)
				{
					val9 = ropeSegments[l].up;
				}
				Vector3 val10 = Vector3.ProjectOnPlane(val7.linearVelocity - val5, ((Vector3)(ref val9)).normalized);
				Vector3 val11 = -val10 * RopeSwing.CoastDamping.Value;
				if (((Vector3)(ref val8)).sqrMagnitude >= 0.0001f)
				{
					Vector3 val12 = Vector3.ProjectOnPlane(val10, ((Vector3)(ref val8)).normalized);
					val11 -= val12 * RopeSwing.SteeringDamping.Value;
				}
				val11 = Vector3.ClampMagnitude(val11, 4f);
				if (((Vector3)(ref val11)).sqrMagnitude > 0.0001f)
				{
					val7.AddForce(val11, (ForceMode)5);
				}
				if (!(((Vector3)(ref val8)).sqrMagnitude < 0.0001f))
				{
					Vector3 normalized = ((Vector3)(ref val8)).normalized;
					float num7 = Vector3.Dot(val10, normalized);
					float num8 = RopeSwing.MaxSpeed.Value * value6;
					float num9 = Mathf.InverseLerp(num8 * 0.65f, num8, Mathf.Max(0f, num7));
					float num10 = 1f - Mathf.SmoothStep(0f, 1f, num9);
					float num11 = 1f + RopeSwing.PumpBoost.Value * Mathf.Clamp01(num7 / (num8 * 0.5f));
					val7.WakeUp();
					val7.AddForce(val8 * (RopeSwing.Acceleration.Value * num10 * num11), (ForceMode)5);
				}
			}
		}
	}
}
[HarmonyPatch(typeof(CharacterRopeHandling), "ClimbForce")]
internal static class FollowMovingRope
{
	private static void Postfix(CharacterRopeHandling __instance, Character ___character, ref Vector3 __result)
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: 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_0122: 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_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: 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_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_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)___character) || !___character.IsLocal || !___character.data.isRopeClimbing)
		{
			return;
		}
		Rope heldRope = ___character.data.heldRope;
		RopeSwingInput ropeSwingInput = default(RopeSwingInput);
		if (!Object.op_Implicit((Object)(object)heldRope) || !Object.op_Implicit((Object)(object)heldRope.climbingAPI) || heldRope.SegmentCount < 2 || !((Component)___character).TryGetComponent<RopeSwingInput>(ref ropeSwingInput))
		{
			return;
		}
		float num = Mathf.Clamp01(___character.data.ropePercent);
		Vector3 val = heldRope.climbingAPI.GetPosition(num) + ___character.data.ropeClimbNormal * 0.5f;
		Vector3 fallback = ropeSwingInput.TrackVelocity(heldRope, val);
		Transform segmentFromPercent = heldRope.climbingAPI.GetSegmentFromPercent(num);
		Rigidbody val2 = default(Rigidbody);
		fallback = ((!((MonoBehaviourPun)heldRope).photonView.IsMine || !Object.op_Implicit((Object)(object)segmentFromPercent) || !((Component)segmentFromPercent).TryGetComponent<Rigidbody>(ref val2)) ? ropeSwingInput.GripVelocity(heldRope, fallback) : val2.GetPointVelocity(val));
		if (!RopeSwingInput.IsFiniteVelocity(fallback))
		{
			fallback = Vector3.zero;
		}
		fallback = Vector3.ClampMagnitude(fallback, 60f);
		ropeSwingInput.Follow(heldRope, fallback);
		foreach (Bodypart part in ___character.refs.ragdoll.partList)
		{
			if (((object)Unsafe.As<BodypartType, BodypartType>(ref part.partType)/*cast due to .constrained prefix*/).ToString() != "Torso" || !Object.op_Implicit((Object)(object)part.Rig))
			{
				continue;
			}
			float num2 = Mathf.Clamp(__instance.climbForce, 100f, 256f);
			float num3 = 1.4f * Mathf.Sqrt(num2);
			float fixedDeltaTime = Time.fixedDeltaTime;
			float num4 = 1f + num3 * fixedDeltaTime + num2 * fixedDeltaTime * fixedDeltaTime;
			Vector3 val3 = ((val - part.Rig.position) * num2 + (fallback - part.Rig.linearVelocity) * num3 - Physics.gravity) / num4;
			__result = Vector3.ClampMagnitude(val3, 120f);
			break;
		}
	}
}
[HarmonyPatch(typeof(CharacterRopeHandling), "StopRopeClimbingRpc")]
internal static class ReleaseSwingGrip
{
	private static void Prefix(Character ___character, bool jumped)
	{
		RopeSwingInput ropeSwingInput = default(RopeSwingInput);
		if (Object.op_Implicit((Object)(object)___character) && ((Component)___character).TryGetComponent<RopeSwingInput>(ref ropeSwingInput))
		{
			ropeSwingInput.PrepareRelease(jumped);
		}
	}
}
[HarmonyPatch(typeof(Bodypart), "Drag")]
internal static class RopeRelativeBodyDrag
{
	private static void Prefix(Bodypart __instance, Character ___character, float drag, bool ignoreRagdoll, out Vector3 __state)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: 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)
		//IL_009a: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
		__state = Vector3.zero;
		RopeSwingInput ropeSwingInput = default(RopeSwingInput);
		if (ignoreRagdoll || drag <= 0f || drag >= 1f || !Object.op_Implicit((Object)(object)___character) || !___character.IsLocal || !((Component)___character).TryGetComponent<RopeSwingInput>(ref ropeSwingInput))
		{
			return;
		}
		float num = Mathf.Lerp(1f, drag, ___character.data.currentRagdollControll);
		Vector3 velocity;
		if (ropeSwingInput.TryLaunchRetention(num, out var retention))
		{
			if (Object.op_Implicit((Object)(object)__instance.Rig) && !__instance.Rig.isKinematic)
			{
				__state = __instance.Rig.linearVelocity * Mathf.Max(0f, retention - num);
			}
		}
		else if (ropeSwingInput.TryCarrierVelocity(out velocity))
		{
			__state = velocity * (1f - num);
		}
	}

	private static void Postfix(Bodypart __instance, Vector3 __state)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		if (((Vector3)(ref __state)).sqrMagnitude > 0f && Object.op_Implicit((Object)(object)__instance.Rig) && !__instance.Rig.isKinematic)
		{
			__instance.Rig.AddForce(__state, (ForceMode)2);
		}
	}
}