Decompiled source of alphacilp v5.0.0

Mods/alphacilp.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BoneLib;
using BoneLib.BoneMenu;
using BoneMenu;
using Il2Cpp;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppPuppetMasta;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.Combat;
using Il2CppSLZ.Marrow.Data;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.PuppetMasta;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.VRMK;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using LabFusion.Data;
using LabFusion.Entities;
using LabFusion.Marrow.Extenders;
using LabFusion.Marrow.Pool;
using LabFusion.Network;
using LabFusion.Network.Serialization;
using LabFusion.Player;
using LabFusion.RPC;
using LabFusion.SDK.Modules;
using LabFusion.Scene;
using LabFusion.Senders;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Main), "alphacilp", "5.0.0", "Me", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "BoneLib", "LabFusion" })]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BoneMenu
{
	public enum SyncKind
	{
		LocalOnly,
		LabFusionSynced
	}
	public abstract class Ability
	{
		public bool Enabled;

		public abstract string Name { get; }

		public abstract SyncKind Sync { get; }

		public virtual void OnEnable(RigManager rig)
		{
		}

		public virtual void OnDisable(RigManager rig)
		{
		}

		public virtual void Tick(RigManager rig)
		{
		}

		public virtual void LateTick(RigManager rig)
		{
		}

		public virtual void FixedTick(RigManager rig)
		{
		}
	}
	public static class Abilities
	{
		public static readonly List<Ability> All = new List<Ability>();

		private static RigManager _lastRig;

		public static void RegisterAll()
		{
			Register(new JetpackAbility());
			Register(new HandFlapFlightAbility());
			Register(new SpiderManAbility());
			Register(new ConfettiGunAbility());
			Register(new SuperJumpAbility());
			Register(new DashAbility());
			Register(new SuperDashAbility());
			Register(new BackfilpAbility());
			Register(new StickRagdollAbility());
			Register(new AirBrakeAbility());
			Register(new LowGravityAbility());
			Register(new SuperSpeedAbility());
			Register(new SuperStrengthAbility());
			Register(new VrHeadsetAbility());
			Register(new FullAutoGunsAbility());
			Register(new SwordfistAbility());
			Register(new WristHolstersAbility());
			Register(new BackpackHolsterAbility());
			Register(new ThighSpawnGunAbility());
			Register(new LaserEyesAbility());
		}

		private static void Register(Ability a)
		{
			All.Add(a);
			Melon<Main>.Logger.Msg("Ability added: " + a.Name + " (" + a.Sync.ToString() + ")");
		}

		public static void Toggle(Ability a, RigManager rig)
		{
			if (a == null)
			{
				return;
			}
			try
			{
				a.Enabled = !a.Enabled;
				if ((Object)(object)rig != (Object)null)
				{
					if (a.Enabled)
					{
						a.OnEnable(rig);
					}
					else
					{
						a.OnDisable(rig);
					}
				}
				Melon<Main>.Logger.Msg("Ability " + a.Name + (a.Enabled ? " ON" : " OFF"));
			}
			catch (Exception ex)
			{
				a.Enabled = false;
				Melon<Main>.Logger.Error("Ability " + a.Name + " failed: " + ex);
			}
		}

		public static void FixedTick(RigManager rig)
		{
			if (All.Count == 0 || (Object)(object)rig == (Object)null)
			{
				return;
			}
			foreach (Ability item in All)
			{
				if (item.Enabled)
				{
					try
					{
						item.FixedTick(rig);
					}
					catch (Exception ex)
					{
						item.Enabled = false;
						Melon<Main>.Logger.Error("Ability " + item.Name + " failed and was switched off: " + ex);
					}
				}
			}
		}

		public static void Tick(RigManager rig)
		{
			if (All.Count == 0 || (Object)(object)rig == (Object)null)
			{
				return;
			}
			bool flag = (Object)(object)rig != (Object)(object)_lastRig;
			_lastRig = rig;
			foreach (Ability item in All)
			{
				if (!item.Enabled)
				{
					continue;
				}
				try
				{
					if (flag)
					{
						item.OnEnable(rig);
					}
					item.Tick(rig);
				}
				catch (Exception ex)
				{
					item.Enabled = false;
					Melon<Main>.Logger.Error("Ability " + item.Name + " failed and was switched off: " + ex);
				}
			}
		}

		public static void LateTick(RigManager rig)
		{
			if (All.Count == 0 || (Object)(object)rig == (Object)null)
			{
				return;
			}
			foreach (Ability item in All)
			{
				if (item.Enabled)
				{
					try
					{
						item.LateTick(rig);
					}
					catch (Exception ex)
					{
						Melon<Main>.Logger.Error("Ability " + item.Name + " late pose failed: " + ex);
					}
				}
			}
		}
	}
	public enum JetpackButton
	{
		RightA,
		RightB,
		LeftX,
		LeftY
	}
	public static class AbilityInput
	{
		public static bool IsHeld(JetpackButton button)
		{
			try
			{
				if (Prefs.LeftHanded)
				{
					button = Mirror(button);
				}
				switch (button)
				{
				case JetpackButton.RightA:
					return (Object)(object)Player.RightController != (Object)null && Player.RightController.GetAButton();
				case JetpackButton.RightB:
					return (Object)(object)Player.RightController != (Object)null && Player.RightController.GetBButton();
				case JetpackButton.LeftX:
					return (Object)(object)Player.LeftController != (Object)null && Player.LeftController.GetAButton();
				case JetpackButton.LeftY:
					return (Object)(object)Player.LeftController != (Object)null && Player.LeftController.GetBButton();
				}
			}
			catch
			{
			}
			return false;
		}

		public static Vector2 Thumbstick(bool left)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0019: 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)
			try
			{
				BaseController val = (left ? Player.LeftController : Player.RightController);
				return ((Object)(object)val != (Object)null) ? val.GetThumbStickAxis() : Vector2.zero;
			}
			catch
			{
				return Vector2.zero;
			}
		}

		public static bool TopFaceButtonsHeld()
		{
			if (IsHeld(JetpackButton.RightB))
			{
				return IsHeld(JetpackButton.LeftY);
			}
			return false;
		}

		private static JetpackButton Mirror(JetpackButton button)
		{
			return button switch
			{
				JetpackButton.RightA => JetpackButton.LeftX, 
				JetpackButton.RightB => JetpackButton.LeftY, 
				JetpackButton.LeftX => JetpackButton.RightA, 
				JetpackButton.LeftY => JetpackButton.RightB, 
				_ => button, 
			};
		}

		public static void CacheBody(RigManager rig, List<Rigidbody> bodies)
		{
			bodies.Clear();
			PhysicsRig val = (((Object)(object)rig != (Object)null) ? rig.physicsRig : null);
			if ((Object)(object)val == (Object)null || val.selfRbs == null)
			{
				return;
			}
			Enumerator<Rigidbody> enumerator = val.selfRbs.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Rigidbody current = enumerator.Current;
				if ((Object)(object)current != (Object)null)
				{
					bodies.Add(current);
				}
			}
		}
	}
	internal static class AbilityHands
	{
		public static Hand Pick(RigManager rig, bool left)
		{
			if ((Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
			{
				return null;
			}
			if (!left)
			{
				return rig.physicsRig.rightHand;
			}
			return rig.physicsRig.leftHand;
		}

		public static Transform Palm(Hand hand)
		{
			if ((Object)(object)hand == (Object)null)
			{
				return null;
			}
			if (!((Object)(object)hand.palmPositionTransform != (Object)null))
			{
				return ((Component)hand).transform;
			}
			return hand.palmPositionTransform;
		}

		public static Transform PalmOf(RigManager rig, bool left)
		{
			return Palm(Pick(rig, left));
		}

		public static float Trigger(Hand hand)
		{
			if ((Object)(object)hand == (Object)null)
			{
				return 0f;
			}
			try
			{
				return hand.GetIndexTriggerAxis();
			}
			catch
			{
				return 0f;
			}
		}

		public static float Grip(bool left)
		{
			try
			{
				if (left)
				{
					return ((Object)(object)Player.LeftController != (Object)null) ? Player.LeftController.GetGripForce() : 0f;
				}
				return ((Object)(object)Player.RightController != (Object)null) ? Player.RightController.GetGripForce() : 0f;
			}
			catch
			{
				return 0f;
			}
		}

		public static Hand Preferred(RigManager rig)
		{
			return Pick(rig, Prefs.LeftHanded);
		}

		public static Vector3 Aim(Transform palm)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (((Object)(object)palm != (Object)null) ? palm.forward : Vector3.zero);
			if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
			{
				val = (((Object)(object)Player.Head != (Object)null) ? Player.Head.forward : Vector3.forward);
			}
			return ((Vector3)(ref val)).normalized;
		}

		public static void Muzzle(Transform palm, out Vector3 position, out Quaternion rotation)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_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)
			Vector3 val = Aim(palm);
			position = palm.position + val * 0.18f;
			rotation = Quaternion.LookRotation(val, palm.up);
		}

		public static void AddVelocity(List<Rigidbody> body, Vector3 delta, bool skipKinematic)
		{
			//IL_0027: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			foreach (Rigidbody item in body)
			{
				if ((Object)(object)item != (Object)null && (!skipKinematic || !item.isKinematic))
				{
					item.velocity += delta;
				}
			}
		}

		public static void AddAcceleration(List<Rigidbody> body, Vector3 acceleration, bool skipKinematic)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			foreach (Rigidbody item in body)
			{
				if ((Object)(object)item != (Object)null && (!skipKinematic || !item.isKinematic))
				{
					item.AddForce(acceleration, (ForceMode)5);
				}
			}
		}
	}
	public class JetpackAbility : Ability
	{
		private readonly List<Rigidbody> _body = new List<Rigidbody>();

		public override string Name
		{
			get
			{
				if (!Prefs.LeftHanded)
				{
					return "Jetpack (A)";
				}
				return "Jetpack (X)";
			}
		}

		public override SyncKind Sync => SyncKind.LocalOnly;

		public override void OnEnable(RigManager rig)
		{
			AbilityInput.CacheBody(rig, _body);
			Melon<Main>.Logger.Msg("Jetpack: found " + _body.Count + " body parts to lift.");
		}

		public override void OnDisable(RigManager rig)
		{
			_body.Clear();
		}

		public override void FixedTick(RigManager rig)
		{
			//IL_001c: 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_004e: 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)
			if (_body.Count != 0 && AbilityInput.IsHeld(JetpackButton.RightA))
			{
				float y = rig.physicsRig.wholeBodyVelocity.y;
				float num = 2.5f * BodyScale.Factor;
				float num2 = ((y < num) ? 13f : (0f - Physics.gravity.y));
				AbilityHands.AddAcceleration(_body, Vector3.up * num2, skipKinematic: false);
			}
		}
	}
	public class HandFlapFlightAbility : Ability
	{
		private sealed class Flap
		{
			private bool _started;

			private Vector3 _previous;

			private float _filteredSpeed;

			private bool _armed;

			public void Reset()
			{
				_started = false;
				_filteredSpeed = 0f;
				_armed = false;
			}

			public bool Downstroke(Transform palm, float dt)
			{
				//IL_000c: 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)
				//IL_002a: 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_0041: 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_001c: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)palm == (Object)null)
				{
					return false;
				}
				Vector3 position = palm.position;
				if (!_started)
				{
					_previous = position;
					_started = true;
					return false;
				}
				float num = (position.y - _previous.y) / dt;
				_previous = position;
				_filteredSpeed = Mathf.Lerp(_filteredSpeed, num, 0.35f);
				if (_filteredSpeed > 0.65f)
				{
					_armed = true;
				}
				if (_armed && _filteredSpeed < -1.45f)
				{
					_armed = false;
					return true;
				}
				return false;
			}
		}

		private readonly List<Rigidbody> _body = new List<Rigidbody>();

		private readonly Flap _left = new Flap();

		private readonly Flap _right = new Flap();

		private float _liftRemaining;

		public override string Name => "Hand flap flight";

		public override SyncKind Sync => SyncKind.LocalOnly;

		public override void OnEnable(RigManager rig)
		{
			AbilityInput.CacheBody(rig, _body);
			Reset();
		}

		public override void OnDisable(RigManager rig)
		{
			_body.Clear();
			Reset();
		}

		private void Reset()
		{
			_left.Reset();
			_right.Reset();
			_liftRemaining = 0f;
		}

		public override void FixedTick(RigManager rig)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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)
			if ((Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
			{
				return;
			}
			if (_body.Count == 0)
			{
				AbilityInput.CacheBody(rig, _body);
			}
			Transform val = AbilityHands.Palm(rig.physicsRig.leftHand);
			Transform val2 = AbilityHands.Palm(rig.physicsRig.rightHand);
			if ((Object)(object)val == (Object)null && (Object)(object)val2 == (Object)null)
			{
				return;
			}
			float num = Mathf.Max(Time.fixedDeltaTime, 0.001f);
			if (_left.Downstroke(val, num) | _right.Downstroke(val2, num))
			{
				_liftRemaining = 0.28f;
			}
			if (_liftRemaining <= 0f)
			{
				return;
			}
			foreach (Rigidbody item in _body)
			{
				if (!((Object)(object)item == (Object)null) && !item.isKinematic && item.velocity.y < 5.5f)
				{
					item.AddForce(Vector3.up * 17f, (ForceMode)5);
				}
			}
			_liftRemaining -= num;
		}
	}
	public class SpiderManAbility : Ability
	{
		private sealed class Web
		{
			public bool Active;

			public bool Landed;

			public bool Boosted;

			public bool Left;

			public Hand Hand;

			public Vector3 Start;

			public Vector3 Anchor;

			public float ShotAt;

			public float Distance;

			public LineRenderer Line;

			public float NextDebug;
		}

		private readonly List<Rigidbody> _body = new List<Rigidbody>();

		private readonly RaycastHit[] _hits = (RaycastHit[])(object)new RaycastHit[48];

		private readonly Vector3[] _fingertips = (Vector3[])(object)new Vector3[5];

		private readonly Web _web = new Web();

		private bool _triggerWasDown;

		private float _nextAimTry;

		private float _nextMissLog;

		private int _rawHits;

		private Material _ropeMaterial;

		private int _ropeThemeVersion = -1;

		private float _nextBusyLog;

		public override string Name => "Spider-man";

		public override SyncKind Sync => SyncKind.LocalOnly;

		public override void OnEnable(RigManager rig)
		{
			AbilityInput.CacheBody(rig, _body);
			Release();
			_triggerWasDown = IsTriggerDown(rig);
			_nextAimTry = 0f;
			Melon<Main>.Logger.Msg("Spider-man ready: point an empty hand and pull the trigger.");
		}

		public override void OnDisable(RigManager rig)
		{
			Release();
			if ((Object)(object)_web.Line != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_web.Line).gameObject);
			}
			_web.Line = null;
			_body.Clear();
			_nextAimTry = 0f;
			if ((Object)(object)_ropeMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)_ropeMaterial);
			}
			_ropeMaterial = null;
			_ropeThemeVersion = -1;
		}

		public override void Tick(RigManager rig)
		{
			//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_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
			{
				return;
			}
			if (_body.Count == 0)
			{
				AbilityInput.CacheBody(rig, _body);
			}
			Hand leftHand = rig.physicsRig.leftHand;
			Hand rightHand = rig.physicsRig.rightHand;
			bool flag = Armed(leftHand);
			bool flag2 = Armed(rightHand);
			bool flag3 = flag || flag2;
			if (MenuSet.IsAnyOpen)
			{
				Release();
				_triggerWasDown = flag3;
				_nextAimTry = 0f;
				return;
			}
			LogBusy(leftHand, left: true);
			LogBusy(rightHand, left: false);
			bool num = flag3 && !_triggerWasDown;
			_triggerWasDown = flag3;
			if (!flag3)
			{
				_nextAimTry = 0f;
			}
			if (num || (flag3 && !_web.Active && _nextAimTry > 0f && Time.time >= _nextAimTry))
			{
				_nextAimTry = Time.time + 0.2f;
				bool flag4 = flag;
				TryHook(rig, flag4 ? leftHand : rightHand, flag4);
			}
			if (!_web.Active)
			{
				return;
			}
			bool num2 = (_web.Left ? flag : flag2);
			Transform val = AbilityHands.Palm(_web.Hand);
			if (!num2 || (Object)(object)val == (Object)null)
			{
				Release();
				return;
			}
			_web.Start = val.position;
			float num3 = (Time.time - _web.ShotAt) * 110f;
			if (!_web.Landed && (_web.Distance <= 0.01f || num3 >= _web.Distance))
			{
				_web.Landed = true;
				Melon<Main>.Logger.Msg("Spider-man: rope landed, pulling.");
			}
			float num4 = (_web.Landed ? 1f : Mathf.Clamp01(num3 / Mathf.Max(0.01f, _web.Distance)));
			Vector3 end = Vector3.Lerp(_web.Start, _web.Anchor, num4);
			Draw(_web.Start, end);
		}

		public override void FixedTick(RigManager rig)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0086: 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_009a: 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_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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			if (!_web.Active || !_web.Landed || (Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
			{
				return;
			}
			if (_body.Count == 0)
			{
				AbilityInput.CacheBody(rig, _body);
			}
			Transform head = ((Rig)rig.physicsRig).m_head;
			Vector3 val = (((Object)(object)head != (Object)null) ? head.position : ((Component)rig).transform.position);
			Vector3 val2 = _web.Anchor - val;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (magnitude < 0.9f)
			{
				return;
			}
			Vector3 val3 = val2 / magnitude;
			float num = Vector3.Dot(rig.physicsRig.wholeBodyVelocity, val3);
			if (!_web.Boosted)
			{
				_web.Boosted = true;
				float num2 = Mathf.Min(7f, 22f - num);
				if (num2 > 0f)
				{
					AbilityHands.AddVelocity(_body, val3 * num2, skipKinematic: true);
				}
			}
			float num3 = 0f;
			if (num < 22f)
			{
				float num4 = Mathf.Max(Time.fixedDeltaTime, 0.001f);
				num3 = Mathf.Min(22f - num, 45f * num4);
				AbilityHands.AddVelocity(_body, val3 * num3, skipKinematic: true);
			}
			if (Time.time >= _web.NextDebug)
			{
				_web.NextDebug = Time.time + 0.5f;
				Melon<Main>.Logger.Msg("[debug] spider-man: " + magnitude.ToString("F1") + " m to rope, " + (num + num3).ToString("F1") + " m/s toward it");
			}
		}

		private static bool Armed(Hand hand)
		{
			if ((Object)(object)hand == (Object)null)
			{
				return false;
			}
			bool flag = false;
			try
			{
				flag = hand.HasAttachedObject();
			}
			catch
			{
			}
			if (!flag)
			{
				return AbilityHands.Trigger(hand) >= 0.6f;
			}
			return false;
		}

		private static bool IsTriggerDown(RigManager rig)
		{
			if ((Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
			{
				return false;
			}
			if (!Armed(rig.physicsRig.leftHand))
			{
				return Armed(rig.physicsRig.rightHand);
			}
			return true;
		}

		private void LogBusy(Hand hand, bool left)
		{
			if (!((Object)(object)hand == (Object)null) && !(Time.time < _nextBusyLog) && !(AbilityHands.Trigger(hand) < 0.6f))
			{
				bool flag;
				try
				{
					flag = hand.HasAttachedObject();
				}
				catch
				{
					return;
				}
				if (flag)
				{
					_nextBusyLog = Time.time + 1f;
					Melon<Main>.Logger.Msg("Spider-man: " + (left ? "left" : "right") + " hand is holding something, so the trigger is left to it.");
				}
			}
		}

		private void TryHook(RigManager rig, Hand hand, bool left)
		{
			//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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: 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_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: 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_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: 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_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			Transform val = AbilityHands.Palm(hand);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			_rawHits = 0;
			Vector3 point;
			float distance;
			bool flag = TryAim(rig, val.position, AbilityHands.Aim(val), out point, out distance);
			if (!flag && (Object)(object)((Component)hand).transform != (Object)null)
			{
				flag = TryAim(rig, ((Component)hand).transform.position, ((Component)hand).transform.forward, out point, out distance);
			}
			if (!flag)
			{
				flag = TryFingerAim(rig, hand, left, val, out point, out distance);
			}
			Transform gaze = null;
			try
			{
				gaze = Player.Head;
			}
			catch
			{
			}
			if (!flag)
			{
				flag = TryGaze(rig, gaze, out point, out distance);
			}
			if (!flag)
			{
				Camera val2 = null;
				try
				{
					val2 = Camera.main;
				}
				catch
				{
				}
				if ((Object)(object)val2 != (Object)null)
				{
					flag = TryGaze(rig, ((Component)val2).transform, out point, out distance);
				}
			}
			if (!flag && (Object)(object)rig.physicsRig != (Object)null)
			{
				flag = TryGaze(rig, ((Rig)rig.physicsRig).m_head, out point, out distance);
			}
			if (!flag)
			{
				try
				{
					Animator val3 = (((Object)(object)rig.avatar != (Object)null) ? rig.avatar.animator : null);
					Transform gaze2 = (((Object)(object)val3 != (Object)null) ? val3.GetBoneTransform((HumanBodyBones)10) : null);
					flag = TryGaze(rig, gaze2, out point, out distance);
				}
				catch
				{
				}
			}
			if (!flag)
			{
				Vector3 forward = ((Component)rig).transform.forward;
				if (((Vector3)(ref forward)).sqrMagnitude > 0.001f)
				{
					((Vector3)(ref forward)).Normalize();
					Vector3 val4 = (((Object)(object)((Rig)rig.physicsRig).m_head != (Object)null) ? ((Rig)rig.physicsRig).m_head.position : ((Component)rig).transform.position);
					flag = TryAim(rig, val4 + forward * 0.2f, forward, out point, out distance);
				}
			}
			if (!flag)
			{
				if (Time.time >= _nextMissLog)
				{
					_nextMissLog = Time.time + 1f;
					Instance logger = Melon<Main>.Logger;
					string[] obj4 = new string[9]
					{
						"Spider-man: nothing to hook within ",
						35f.ToString("F0"),
						" m (raw hits ",
						_rawHits.ToString(),
						", hand ",
						null,
						null,
						null,
						null
					};
					Vector3 val5 = val.position;
					obj4[5] = ((Vector3)(ref val5)).ToString("F1");
					obj4[6] = " aim ";
					val5 = AbilityHands.Aim(val);
					obj4[7] = ((Vector3)(ref val5)).ToString("F2");
					obj4[8] = ").";
					logger.Msg(string.Concat(obj4));
				}
			}
			else
			{
				if (_web.Active)
				{
					Release();
				}
				_web.Active = true;
				_web.Landed = false;
				_web.Boosted = false;
				_web.Left = left;
				_web.Hand = hand;
				_web.Anchor = point;
				_web.Start = val.position;
				_web.ShotAt = Time.time;
				_web.Distance = Vector3.Distance(_web.Start, _web.Anchor);
				_web.NextDebug = 0f;
				EnsureLine();
				Draw(_web.Start, _web.Start);
				Melon<Main>.Logger.Msg("Spider-man: rope shot " + distance.ToString("F1") + " m to a surface.");
			}
		}

		private bool TryAim(RigManager rig, Vector3 origin, Vector3 direction, out Vector3 point, out float distance)
		{
			//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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			point = Vector3.zero;
			distance = float.MaxValue;
			if (((Vector3)(ref direction)).sqrMagnitude < 0.001f)
			{
				return false;
			}
			((Vector3)(ref direction)).Normalize();
			if (Cast(rig, origin, direction, 0f, out point, out distance))
			{
				return true;
			}
			return Cast(rig, origin, direction, 0.12f, out point, out distance);
		}

		private bool Cast(RigManager rig, Vector3 origin, Vector3 direction, float radius, out Vector3 point, out float distance)
		{
			//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_0016: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			point = Vector3.zero;
			distance = float.MaxValue;
			if (CastGlobal(rig, origin, direction, radius, ref point, ref distance))
			{
				return true;
			}
			if (CastAll(rig, origin, direction, radius, ref point, ref distance))
			{
				return true;
			}
			if (CastRayOut(rig, origin, direction, radius, ref point, ref distance))
			{
				return true;
			}
			if (CastScenes(rig, origin, direction, radius, ref point, ref distance))
			{
				return true;
			}
			return CastNearby(rig, origin, direction, ref point, ref distance);
		}

		private bool CastGlobal(RigManager rig, Vector3 origin, Vector3 direction, float radius, ref Vector3 point, ref float distance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			int num = ((radius > 0f) ? Physics.SphereCastNonAlloc(origin, radius, direction, Il2CppStructArray<RaycastHit>.op_Implicit(_hits), 35f, -1, (QueryTriggerInteraction)1) : Physics.RaycastNonAlloc(origin, direction, Il2CppStructArray<RaycastHit>.op_Implicit(_hits), 35f, -1, (QueryTriggerInteraction)1));
			_rawHits = Mathf.Max(_rawHits, num);
			return SelectHit(rig, _hits, num, ref point, ref distance);
		}

		private bool CastAll(RigManager rig, Vector3 origin, Vector3 direction, float radius, ref Vector3 point, ref float distance)
		{
			//IL_0019: 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)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Il2CppArrayBase<RaycastHit>.op_Implicit((Il2CppArrayBase<RaycastHit>)(object)((radius > 0f) ? Physics.SphereCastAll(origin, radius, direction, 35f, -1, (QueryTriggerInteraction)1) : Physics.RaycastAll(origin, direction, 35f, -1, (QueryTriggerInteraction)1)));
			if (array != null)
			{
				_rawHits = Mathf.Max(_rawHits, array.Length);
				if (SelectHit(rig, array, array.Length, ref point, ref distance))
				{
					return true;
				}
			}
			array = Il2CppArrayBase<RaycastHit>.op_Implicit((Il2CppArrayBase<RaycastHit>)(object)((radius > 0f) ? Physics.SphereCastAll(origin, radius, direction, 35f, -1, (QueryTriggerInteraction)2) : Physics.RaycastAll(origin, direction, 35f, -1, (QueryTriggerInteraction)2)));
			if (array == null)
			{
				return false;
			}
			_rawHits = Mathf.Max(_rawHits, array.Length);
			return SelectHit(rig, array, array.Length, ref point, ref distance);
		}

		private bool CastRayOut(RigManager rig, Vector3 origin, Vector3 direction, float radius, ref Vector3 point, ref float distance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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)
			RaycastHit val = default(RaycastHit);
			if (!((radius > 0f) ? Physics.SphereCast(origin, radius, direction, ref val, 35f, -1, (QueryTriggerInteraction)1) : Physics.Raycast(origin, direction, ref val, 35f, -1, (QueryTriggerInteraction)1)) || (Object)(object)((RaycastHit)(ref val)).collider == (Object)null || IsPlayerPart(rig, ((RaycastHit)(ref val)).collider))
			{
				return false;
			}
			distance = Mathf.Max(0.02f, ((RaycastHit)(ref val)).distance);
			point = ((RaycastHit)(ref val)).point;
			return true;
		}

		private bool CastScenes(RigManager rig, Vector3 origin, Vector3 direction, float radius, ref Vector3 point, ref float distance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0028: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_004b: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rig == (Object)null || (Object)(object)((Component)rig).gameObject == (Object)null)
			{
				return false;
			}
			Scene scene = ((Component)rig).gameObject.scene;
			if (CastScene(scene, rig, origin, direction, radius, ref point, ref distance))
			{
				return true;
			}
			int sceneCount = SceneManager.sceneCount;
			for (int i = 0; i < sceneCount; i++)
			{
				Scene sceneAt = SceneManager.GetSceneAt(i);
				if (!(sceneAt == scene) && CastScene(sceneAt, rig, origin, direction, radius, ref point, ref distance))
				{
					return true;
				}
			}
			return false;
		}

		private bool CastScene(Scene scene, RigManager rig, Vector3 origin, Vector3 direction, float radius, ref Vector3 point, ref float distance)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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)
			if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded)
			{
				return false;
			}
			PhysicsScene physicsScene;
			try
			{
				physicsScene = PhysicsSceneExtensions.GetPhysicsScene(scene);
			}
			catch
			{
				return false;
			}
			if (!((PhysicsScene)(ref physicsScene)).IsValid())
			{
				return false;
			}
			int num = ((radius > 0f) ? ((PhysicsScene)(ref physicsScene)).SphereCast(origin, radius, direction, Il2CppStructArray<RaycastHit>.op_Implicit(_hits), 35f, -1, (QueryTriggerInteraction)1) : ((PhysicsScene)(ref physicsScene)).Raycast(origin, direction, Il2CppStructArray<RaycastHit>.op_Implicit(_hits), 35f, -1, (QueryTriggerInteraction)1));
			_rawHits = Mathf.Max(_rawHits, num);
			return SelectHit(rig, _hits, num, ref point, ref distance);
		}

		private bool CastNearby(RigManager rig, Vector3 origin, Vector3 direction, ref Vector3 point, ref float distance)
		{
			//IL_000d: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rig == (Object)null)
			{
				return false;
			}
			if (CastNearbyWith(rig, origin, direction, (QueryTriggerInteraction)1, ref point, ref distance))
			{
				return true;
			}
			return CastNearbyWith(rig, origin, direction, (QueryTriggerInteraction)2, ref point, ref distance);
		}

		private bool CastNearbyWith(RigManager rig, Vector3 origin, Vector3 direction, QueryTriggerInteraction triggers, ref Vector3 point, ref float distance)
		{
			//IL_0000: 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_0044: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(origin, 35f, -1, triggers));
			if (array == null)
			{
				return false;
			}
			bool flag = false;
			float num = 40f;
			foreach (Collider val in array)
			{
				if ((Object)(object)val == (Object)null || IsPlayerPart(rig, val))
				{
					continue;
				}
				Vector3 val2 = val.ClosestPoint(origin);
				Vector3 val3 = val2 - origin;
				float magnitude = ((Vector3)(ref val3)).magnitude;
				if (!(magnitude < 0.1f) && !(magnitude > 35f))
				{
					float num2 = Vector3.Angle(direction, val3);
					if (!(num2 > num) && (!flag || !(num2 > num - 0.01f) || !(magnitude >= distance)))
					{
						point = val2;
						distance = magnitude;
						num = num2;
						flag = true;
					}
				}
			}
			return flag;
		}

		private bool SelectHit(RigManager rig, RaycastHit[] hits, int count, ref Vector3 point, ref float distance)
		{
			//IL_0013: 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_006a: 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)
			bool result = false;
			count = Mathf.Min(count, hits.Length);
			for (int i = 0; i < count; i++)
			{
				RaycastHit val = hits[i];
				if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !(((RaycastHit)(ref val)).distance < 0f) && !(((RaycastHit)(ref val)).distance >= distance) && !IsPlayerPart(rig, ((RaycastHit)(ref val)).collider))
				{
					distance = Mathf.Max(0.02f, ((RaycastHit)(ref val)).distance);
					point = ((RaycastHit)(ref val)).point;
					result = true;
				}
			}
			return result;
		}

		private bool TryGaze(RigManager rig, Transform gaze, out Vector3 point, out float distance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_004f: 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)
			point = Vector3.zero;
			distance = float.MaxValue;
			if ((Object)(object)gaze == (Object)null)
			{
				return false;
			}
			Vector3 forward = gaze.forward;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.001f)
			{
				return false;
			}
			((Vector3)(ref forward)).Normalize();
			return TryAim(rig, gaze.position + forward * 0.2f, forward, out point, out distance);
		}

		private bool TryFingerAim(RigManager rig, Hand hand, bool left, Transform palm, out Vector3 point, out float distance)
		{
			//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_0043: 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_004f: 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_0070: 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)
			point = Vector3.zero;
			distance = float.MaxValue;
			if ((Object)(object)hand == (Object)null || (Object)(object)palm == (Object)null)
			{
				return false;
			}
			if (Fingertips.Get(rig, left, _fingertips, 0) < 2)
			{
				return false;
			}
			Vector3 direction = _fingertips[1] - palm.position;
			if (((Vector3)(ref direction)).magnitude < 0.06f)
			{
				return false;
			}
			((Vector3)(ref direction)).Normalize();
			return TryAim(rig, palm.position, direction, out point, out distance);
		}

		private bool IsPlayerPart(RigManager rig, Collider col)
		{
			if ((Object)(object)col == (Object)null)
			{
				return true;
			}
			if ((Object)(object)rig != (Object)null && ((Component)col).transform.IsChildOf(((Component)rig).transform))
			{
				return true;
			}
			return false;
		}

		private void Draw(Vector3 start, Vector3 end)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_web.Line == (Object)null))
			{
				ApplyRopeColor(_web.Line);
				_web.Line.SetPosition(0, start);
				_web.Line.SetPosition(1, end);
				((Renderer)_web.Line).enabled = true;
			}
		}

		private void ApplyRopeColor(LineRenderer line)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)line == (Object)null) && _ropeThemeVersion != Theme.Version)
			{
				_ropeThemeVersion = Theme.Version;
				Color accent = Theme.Accent;
				accent.a = 0.95f;
				Color accentEnd = Theme.AccentEnd;
				accentEnd.a = 0.55f;
				line.startColor = accent;
				line.endColor = accentEnd;
			}
		}

		private void EnsureLine()
		{
			//IL_0038: 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: Expected O, but got Unknown
			if ((Object)(object)_web.Line != (Object)null)
			{
				return;
			}
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val == (Object)null)
			{
				val = Shader.Find("Unlit/Color");
			}
			LineRenderer val2 = new GameObject("AlphaClip_SpiderManRope").AddComponent<LineRenderer>();
			val2.useWorldSpace = true;
			val2.positionCount = 2;
			val2.startWidth = 0.018f;
			val2.endWidth = 0.009f;
			_ropeThemeVersion = -1;
			ApplyRopeColor(val2);
			if ((Object)(object)val != (Object)null)
			{
				if ((Object)(object)_ropeMaterial == (Object)null)
				{
					_ropeMaterial = new Material(val);
				}
				((Renderer)val2).sharedMaterial = _ropeMaterial;
			}
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val2).receiveShadows = false;
			_web.Line = val2;
		}

		private void Release()
		{
			if ((Object)(object)_web.Line != (Object)null)
			{
				((Renderer)_web.Line).enabled = false;
			}
			_web.Active = false;
			_web.Landed = false;
			_web.Boosted = false;
			_web.Hand = null;
		}
	}
	public class ConfettiGunAbility : Ability
	{
		private bool _leftComboWasHeld;

		private bool _rightComboWasHeld;

		private bool _warnedMissing;

		private float _nextShotAt;

		public override string Name => "Confetti gun";

		public override SyncKind Sync => SyncKind.LabFusionSynced;

		public override void OnEnable(RigManager rig)
		{
			_leftComboWasHeld = false;
			_rightComboWasHeld = false;
			_warnedMissing = false;
			_nextShotAt = 0f;
		}

		public override void OnDisable(RigManager rig)
		{
			_leftComboWasHeld = false;
			_rightComboWasHeld = false;
		}

		public override void Tick(RigManager rig)
		{
			if (!((Object)(object)rig == (Object)null) && !((Object)(object)rig.physicsRig == (Object)null))
			{
				bool flag = ComboHeld(rig.physicsRig.leftHand, left: true);
				bool flag2 = ComboHeld(rig.physicsRig.rightHand, left: false);
				bool flag3 = flag && !_leftComboWasHeld;
				bool flag4 = flag2 && !_rightComboWasHeld;
				_leftComboWasHeld = flag;
				_rightComboWasHeld = flag2;
				if (!(Time.time < _nextShotAt) && (flag3 || flag4))
				{
					bool flag5 = flag3 || (!flag4 && Prefs.LeftHanded);
					Launch(flag5 ? rig.physicsRig.leftHand : rig.physicsRig.rightHand);
					_nextShotAt = Time.time + 0.2f;
				}
			}
		}

		private static bool ComboHeld(Hand hand, bool left)
		{
			if ((Object)(object)hand == (Object)null)
			{
				return false;
			}
			if (AbilityHands.Trigger(hand) >= 0.6f)
			{
				return AbilityHands.Grip(left) >= 0.6f;
			}
			return false;
		}

		private void Launch(Hand hand)
		{
			//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)
			//IL_0065: 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_0067: 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)
			Transform val = AbilityHands.Palm(hand);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			CatalogEntry catalogEntry = FindConfettiBlaster();
			if (catalogEntry == null)
			{
				if (!Catalog.Scanning && Catalog.Spawnables.Count > 0 && !_warnedMissing)
				{
					_warnedMissing = true;
					Melon<Main>.Logger.Warning("Confetti gun: BONELAB Core Confetti Blaster barcode not found. Rescan spawnables and enable redacted barcodes if needed.");
				}
				return;
			}
			AbilityHands.Muzzle(val, out var position, out var rotation);
			Vector3 val2 = AbilityHands.Aim(val);
			Actions.Spawn(catalogEntry.Barcode, position, rotation, val2 * 24f, delegate(GameObject spawned)
			{
				if (!((Object)(object)spawned == (Object)null))
				{
					Gun componentInChildren = spawned.GetComponentInChildren<Gun>(true);
					if (!((Object)(object)componentInChildren == (Object)null))
					{
						try
						{
							componentInChildren.Fire();
							return;
						}
						catch (Exception ex)
						{
							Melon<Main>.Logger.Warning("Confetti Blaster could not fire: " + ex.Message);
							return;
						}
					}
					Melon<Main>.Logger.Warning("Confetti gun: spawned the Confetti Blaster barcode without a Gun component.");
				}
			});
		}

		private static CatalogEntry FindConfettiBlaster()
		{
			foreach (CatalogEntry spawnable in Catalog.Spawnables)
			{
				if (spawnable != null && (Prefs.ShowRedacted || !spawnable.Redacted))
				{
					string text = (spawnable.Title + " " + spawnable.Barcode).ToLowerInvariant().Replace(" ", "");
					if (text.Contains("confetti") && (text.Contains("blaster") || text.Contains("cannon")))
					{
						return spawnable;
					}
				}
			}
			return null;
		}
	}
	public class WristHolstersAbility : Ability
	{
		private sealed class WristSlot
		{
			public bool Left;

			public Rigidbody Held;

			public GameObject HeldGo;

			public Collider[] DisabledColliders;

			public Collider[] TriggeredColliders;

			public Grip[] Grips;

			public bool DrawBlocked;

			public bool WasKinematic;

			public bool WasGravity;

			public GameObject Candidate;

			public GameObject RingGo;

			public LineRenderer Ring;

			public Material RingMaterial;

			public Color RingColor;
		}

		private readonly WristSlot _left = new WristSlot
		{
			Left = true
		};

		private readonly WristSlot _right = new WristSlot();

		private Transform _leftWrist;

		private Transform _rightWrist;

		public override string Name => "Wrist holsters";

		public override SyncKind Sync => SyncKind.LocalOnly;

		public override void OnEnable(RigManager rig)
		{
			ResetSlot(_left);
			ResetSlot(_right);
			DestroyRings();
			BuildRings(rig);
			Melon<Main>.Logger.Msg("Wrist holsters ready: bring a weapon to a wrist and release it.");
		}

		public override void OnDisable(RigManager rig)
		{
			ResetSlot(_left);
			ResetSlot(_right);
			DestroyRings();
		}

		public override void Tick(RigManager rig)
		{
			if ((Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
			{
				return;
			}
			Transform handLf = ((Rig)rig.physicsRig).m_handLf;
			Transform handRt = ((Rig)rig.physicsRig).m_handRt;
			if (!((Object)(object)handLf == (Object)null) && !((Object)(object)handRt == (Object)null))
			{
				if ((Object)(object)handLf != (Object)(object)_leftWrist || (Object)(object)handRt != (Object)(object)_rightWrist || (Object)(object)_left.RingGo == (Object)null || (Object)(object)_right.RingGo == (Object)null)
				{
					ResetSlot(_left);
					ResetSlot(_right);
					DestroyRings();
					BuildRings(rig);
				}
				PaintRing(_left);
				PaintRing(_right);
				Hand leftHand = rig.physicsRig.leftHand;
				Hand rightHand = rig.physicsRig.rightHand;
				TickSlot(_left, leftHand, _right, leftHand, rightHand, handLf);
				TickSlot(_right, rightHand, _left, leftHand, rightHand, handRt);
			}
		}

		private void TickSlot(WristSlot slot, Hand ownHand, WristSlot other, Hand leftHand, Hand rightHand, Transform wrist)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)slot.Held != (Object)null)
			{
				TickStored(slot, leftHand, rightHand, wrist);
				return;
			}
			GameObject val = HandObject(ownHand);
			if ((Object)(object)val == (Object)null)
			{
				if ((Object)(object)slot.Candidate != (Object)null)
				{
					Store(slot, other, wrist);
				}
				return;
			}
			if ((Object)(object)val == (Object)(object)other.HeldGo || !IsHolsterable(val))
			{
				slot.Candidate = null;
				return;
			}
			Vector3 val2 = WristPoint(wrist);
			if (Vector3.Distance(((Object)(object)ownHand != (Object)null) ? ((Component)ownHand).transform.position : val.transform.position, val2) <= 0.22f)
			{
				slot.Candidate = val;
			}
			else if ((Object)(object)slot.Candidate == (Object)(object)val)
			{
				slot.Candidate = null;
			}
		}

		private void Store(WristSlot slot, WristSlot other, Transform wrist)
		{
			//IL_00b3: 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_00c9: 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)
			GameObject candidate = slot.Candidate;
			slot.Candidate = null;
			if ((Object)(object)candidate == (Object)null || (Object)(object)candidate == (Object)(object)other.HeldGo)
			{
				return;
			}
			Rigidbody val = null;
			try
			{
				val = candidate.GetComponent<Rigidbody>() ?? candidate.GetComponentInParent<Rigidbody>();
			}
			catch
			{
			}
			if (!((Object)(object)val == (Object)null))
			{
				slot.Held = val;
				slot.HeldGo = candidate;
				slot.WasKinematic = val.isKinematic;
				slot.WasGravity = val.useGravity;
				HolsterColliders.Store(val, candidate, out var disabled, out var madeTrigger);
				slot.DisabledColliders = disabled;
				slot.TriggeredColliders = madeTrigger;
				slot.Grips = HolsterDraw.Collect(candidate);
				slot.DrawBlocked = true;
				WristPose(wrist, out var position, out var rotation);
				try
				{
					val.isKinematic = false;
					val.useGravity = false;
					val.velocity = Vector3.zero;
					val.angularVelocity = Vector3.zero;
					val.position = position;
					val.rotation = rotation;
				}
				catch
				{
					RestoreSlot(slot);
					return;
				}
				Melon<Main>.Logger.Msg("Wrist holster: stored " + ((Object)candidate).name + " on the " + (slot.Left ? "left" : "right") + " wrist.");
			}
		}

		private void TickStored(WristSlot slot, Hand leftHand, Hand rightHand, Transform wrist)
		{
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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)
			if ((Object)(object)slot.Held == (Object)null || (Object)(object)slot.HeldGo == (Object)null)
			{
				RestoreSlot(slot);
				return;
			}
			if (HandHolding(leftHand, slot.HeldGo) || HandHolding(rightHand, slot.HeldGo))
			{
				Melon<Main>.Logger.Msg("Wrist holster: weapon drawn.");
				RestoreSlot(slot);
				return;
			}
			if (slot.DrawBlocked && AbilityHands.Grip(left: true) < 0.55f && AbilityHands.Grip(left: false) < 0.55f)
			{
				slot.DrawBlocked = false;
			}
			if (!slot.DrawBlocked)
			{
				Grip chosenGrip;
				Hand val = HolsterDraw.FindHand(leftHand, rightHand, slot.Grips, !slot.Left, slot.Left, 0.22f, out chosenGrip);
				if ((Object)(object)val != (Object)null && (Object)(object)chosenGrip != (Object)null)
				{
					Melon<Main>.Logger.Msg("Wrist holster: drew with the " + (((Object)(object)val == (Object)(object)leftHand) ? "left" : "right") + " hand.");
					RestoreSlot(slot);
					HolsterDraw.TrySnatch(val, chosenGrip);
					return;
				}
			}
			WristPose(wrist, out var position, out var rotation);
			try
			{
				slot.Held.isKinematic = false;
				slot.Held.useGravity = false;
				slot.Held.velocity = Vector3.zero;
				slot.Held.angularVelocity = Vector3.zero;
				slot.Held.position = position;
				slot.Held.rotation = rotation;
				slot.Held.WakeUp();
			}
			catch
			{
				RestoreSlot(slot);
			}
		}

		private static bool HandHolding(Hand hand, GameObject item)
		{
			GameObject val = HandObject(hand);
			if ((Object)(object)val == (Object)null || (Object)(object)item == (Object)null)
			{
				return false;
			}
			try
			{
				return (Object)(object)val == (Object)(object)item || val.transform.IsChildOf(item.transform) || item.transform.IsChildOf(val.transform);
			}
			catch
			{
				return false;
			}
		}

		private static GameObject HandObject(Hand hand)
		{
			try
			{
				return ((Object)(object)hand != (Object)null) ? hand.m_CurrentAttachedGO : null;
			}
			catch
			{
				return null;
			}
		}

		private static bool IsHolsterable(GameObject go)
		{
			try
			{
				return (Object)(object)go != (Object)null && (Object)(object)go.GetComponentInParent<Grip>() != (Object)null;
			}
			catch
			{
				return false;
			}
		}

		private static Vector3 WristPoint(Transform wrist)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			WristPose(wrist, out var position, out var _);
			return position;
		}

		private static void WristPose(Transform wrist, out Vector3 position, out Quaternion rotation)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//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_0066: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_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_0098: 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_0050: 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)
			Vector3 val = (((Object)(object)wrist != (Object)null) ? wrist.forward : Vector3.forward);
			Vector3 val2 = (((Object)(object)wrist != (Object)null) ? wrist.up : Vector3.up);
			if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
			{
				val = Vector3.forward;
			}
			if (((Vector3)(ref val2)).sqrMagnitude < 0.001f)
			{
				val2 = Vector3.up;
			}
			((Vector3)(ref val)).Normalize();
			((Vector3)(ref val2)).Normalize();
			position = wrist.position + val2 * 0.045f - val * 0.055f;
			rotation = Quaternion.LookRotation(-val, val2);
		}

		private void BuildRings(RigManager rig)
		{
			if (!((Object)(object)rig == (Object)null) && !((Object)(object)rig.physicsRig == (Object)null))
			{
				_leftWrist = ((Rig)rig.physicsRig).m_handLf;
				_rightWrist = ((Rig)rig.physicsRig).m_handRt;
				if ((Object)(object)_leftWrist != (Object)null)
				{
					_left.RingGo = MakeRing(_left, _leftWrist);
				}
				if ((Object)(object)_rightWrist != (Object)null)
				{
					_right.RingGo = MakeRing(_right, _rightWrist);
				}
			}
		}

		private static GameObject MakeRing(WristSlot slot, Transform wrist)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_010c: Expected O, but got Unknown
			GameObject val = new GameObject("AlphaClip_WristHolster_" + (slot.Left ? "L" : "R"));
			val.transform.SetParent(wrist, false);
			val.transform.localPosition = new Vector3(0f, 0.045f, -0.055f);
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			val2.useWorldSpace = false;
			val2.loop = true;
			val2.positionCount = 24;
			val2.startWidth = 0.008f;
			val2.endWidth = 0.008f;
			val2.numCapVertices = 2;
			for (int i = 0; i < 24; i++)
			{
				float num = (float)i * MathF.PI * 2f / 24f;
				val2.SetPosition(i, new Vector3(Mathf.Cos(num) * 0.045f, Mathf.Sin(num) * 0.045f, 0f));
			}
			Shader val3 = Shader.Find("Sprites/Default");
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = Shader.Find("Unlit/Color");
			}
			if ((Object)(object)val3 != (Object)null)
			{
				slot.RingMaterial = new Material(val3);
				((Renderer)val2).sharedMaterial = slot.RingMaterial;
			}
			slot.Ring = val2;
			slot.RingColor = new Color(0f, 0f, 0f, 0f);
			PaintRing(slot);
			return val;
		}

		private static void PaintRing(WristSlot slot)
		{
			//IL_0027: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0048: 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_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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (slot != null && !((Object)(object)slot.Ring == (Object)null))
			{
				Color val = (((Object)(object)slot.Held != (Object)null) ? Color.Lerp(Theme.Accent, Color.white, 0.35f) : Theme.Accent);
				val.a = 0.85f;
				if (!(val == slot.RingColor))
				{
					slot.RingColor = val;
					slot.Ring.startColor = val;
					slot.Ring.endColor = val;
				}
			}
		}

		private void ResetSlot(WristSlot slot)
		{
			slot.Candidate = null;
			RestoreSlot(slot);
		}

		private void RestoreSlot(WristSlot slot)
		{
			slot.Candidate = null;
			if ((Object)(object)slot.Held != (Object)null)
			{
				HolsterColliders.Restore(slot.DisabledColliders, slot.TriggeredColliders);
				try
				{
					slot.Held.isKinematic = slot.WasKinematic;
					slot.Held.useGravity = slot.WasGravity;
				}
				catch
				{
				}
			}
			slot.Held = null;
			slot.HeldGo = null;
			slot.DisabledColliders = null;
			slot.TriggeredColliders = null;
			slot.Grips = null;
			slot.DrawBlocked = false;
		}

		private void DestroyRings()
		{
			DestroyRing(_left);
			DestroyRing(_right);
			_leftWrist = null;
			_rightWrist = null;
		}

		private static void DestroyRing(WristSlot slot)
		{
			if ((Object)(object)slot.RingGo != (Object)null)
			{
				Object.Destroy((Object)(object)slot.RingGo);
			}
			if ((Object)(object)slot.RingMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)slot.RingMaterial);
			}
			slot.RingGo = null;
			slot.Ring = null;
			slot.RingMaterial = null;
		}
	}
	public class AutoHolsterAbility : Ability
	{
		private readonly Dictionary<InteractableHost, InventorySlotReceiver> _sourceSlots = new Dictionary<InteractableHost, InventorySlotReceiver>();

		private InteractableHost _leftItem;

		private InteractableHost _rightItem;

		private InventorySlotReceiver _leftSlot;

		private InventorySlotReceiver _rightSlot;

		private float _leftRetryAt;

		private float _rightRetryAt;

		private float _leftExpiresAt;

		private float _rightExpiresAt;

		public override string Name => "Auto Holster";

		public override SyncKind Sync => SyncKind.LabFusionSynced;

		public override void OnEnable(RigManager rig)
		{
			_sourceSlots.Clear();
			_leftItem = null;
			_rightItem = null;
			_leftSlot = null;
			_rightSlot = null;
			_leftRetryAt = (_rightRetryAt = 0f);
			_leftExpiresAt = (_rightExpiresAt = 0f);
		}

		public override void Tick(RigManager rig)
		{
			if (!((Object)(object)rig == (Object)null) && !((Object)(object)rig.physicsRig == (Object)null) && RigData.HasPlayer)
			{
				RigRefs refs = RigData.Refs;
				if (refs != null && refs.IsValid && refs.RigSlots != null)
				{
					Hand leftHand = rig.physicsRig.leftHand;
					Hand rightHand = rig.physicsRig.rightHand;
					RememberHolsteredItems(refs);
					InteractableHost val = HeldHost(leftHand);
					InteractableHost val2 = HeldHost(rightHand);
					TrackOrigin(val, ref _leftItem, ref _leftSlot, ref _leftExpiresAt);
					TrackOrigin(val2, ref _rightItem, ref _rightSlot, ref _rightExpiresAt);
					ReturnWhenDropped(val, val2, refs, ref _leftItem, ref _leftSlot, ref _leftRetryAt, ref _leftExpiresAt);
					ReturnWhenDropped(val, val2, refs, ref _rightItem, ref _rightSlot, ref _rightRetryAt, ref _rightExpiresAt);
				}
			}
		}

		private void RememberHolsteredItems(RigRefs refs)
		{
			InventorySlotReceiver[] rigSlots = refs.RigSlots;
			foreach (InventorySlotReceiver val in rigSlots)
			{
				if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled)
				{
					InteractableHost val2 = ((val.GetHost() != null) ? ((Il2CppObjectBase)val.GetHost()).TryCast<InteractableHost>() : null);
					if ((Object)(object)val2 != (Object)null)
					{
						_sourceSlots[val2] = val;
					}
				}
			}
		}

		private void TrackOrigin(InteractableHost held, ref InteractableHost tracked, ref InventorySlotReceiver slot, ref float expiresAt)
		{
			if (!((Object)(object)held == (Object)null) && _sourceSlots.TryGetValue(held, out var value) && !((Object)(object)value == (Object)null))
			{
				tracked = held;
				slot = value;
				expiresAt = Time.time + 30f;
			}
		}

		private void ReturnWhenDropped(InteractableHost leftHeld, InteractableHost rightHeld, RigRefs refs, ref InteractableHost tracked, ref InventorySlotReceiver slot, ref float retryAt, ref float expiresAt)
		{
			if ((Object)(object)tracked == (Object)null || (Object)(object)slot == (Object)null || (Object)(object)tracked == (Object)(object)leftHeld || (Object)(object)tracked == (Object)(object)rightHeld)
			{
				return;
			}
			InventorySlotReceiver[] rigSlots = refs.RigSlots;
			foreach (InventorySlotReceiver val in rigSlots)
			{
				if ((Object)(object)(((Object)(object)val != (Object)null && val.GetHost() != null) ? ((Il2CppObjectBase)val.GetHost()).TryCast<InteractableHost>() : null) == (Object)(object)tracked)
				{
					tracked = null;
					slot = null;
					return;
				}
			}
			if (Time.time >= expiresAt)
			{
				Melon<Main>.Logger.Warning("Auto Holster: item could not be returned to its original slot.");
				tracked = null;
				slot = null;
			}
			else
			{
				if (Time.time < retryAt)
				{
					return;
				}
				retryAt = Time.time + 0.2f;
				try
				{
					if (slot.GetHost() == null && slot.InsertInSlot(tracked))
					{
						Melon<Main>.Logger.Msg("Auto Holster: returned released item to its source slot.");
						tracked = null;
						slot = null;
					}
				}
				catch (Exception ex)
				{
					Melon<Main>.Logger.Warning("Auto Holster could not return item: " + ex.Message);
				}
			}
		}

		private static InteractableHost HeldHost(Hand hand)
		{
			if ((Object)(object)hand == (Object)null || !hand.HasAttachedObject())
			{
				return null;
			}
			HandReciever attachedReceiver = hand.AttachedReceiver;
			if (!((Object)(object)attachedReceiver != (Object)null))
			{
				return null;
			}
			return ((Component)attachedReceiver).GetComponentInParent<InteractableHost>();
		}
	}
	public class TelekinesisAbility : Ability
	{
		private const float MinRadius = 0.25f;

		private const float MaxRadius = 0.9f;

		private const float RadiusStep = 0.1f;

		private static float _radius = 0.45f;

		private readonly Collider[] _overlaps = (Collider[])(object)new Collider[128];

		private readonly HashSet<Rigidbody> _seen = new HashSet<Rigidbody>();

		private readonly Dictionary<int, float> _ownershipRetry = new Dictionary<int, float>();

		private GameObject _ball;

		private Renderer _ballRenderer;

		private Vector3 _pullCenter;

		private bool _pulling;

		public static float Radius => _radius;

		public override string Name => "Telekinesis";

		public override SyncKind Sync => SyncKind.LabFusionSynced;

		public static void ChangeRadius(int direction)
		{
			_radius = Mathf.Clamp(_radius + 0.1f * (float)Math.Sign(direction), 0.25f, 0.9f);
		}

		public override void OnEnable(RigManager rig)
		{
			_pulling = false;
			_ownershipRetry.Clear();
			EnsureBall();
			UpdateBallScale();
			Melon<Main>.Logger.Msg("Telekinesis enabled. Pull radius: " + _radius.ToString("F2") + " m.");
		}

		public override void OnDisable(RigManager rig)
		{
			_pulling = false;
			_ownershipRetry.Clear();
			if ((Object)(object)_ball != (Object)null)
			{
				Object.Destroy((Object)(object)_ball);
			}
			_ball = null;
			_ballRenderer = null;
		}

		private void EnsureBall()
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_ball != (Object)null)
			{
				return;
			}
			_ball = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)_ball).name = "AlphaClip_TelekinesisBall";
			Collider component = _ball.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			_ballRenderer = _ball.GetComponent<Renderer>();
			if (!((Object)(object)_ballRenderer == (Object)null))
			{
				Shader val = Shader.Find("Unlit/Color");
				if ((Object)(object)val == (Object)null)
				{
					val = Shader.Find("Sprites/Default");
				}
				if ((Object)(object)val != (Object)null)
				{
					_ballRenderer.material.shader = val;
				}
				_ballRenderer.material.color = new Color(0.72f, 0.32f, 1f, 1f);
			}
		}

		public override void Tick(RigManager rig)
		{
			//IL_0088: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00b2: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
			{
				return;
			}
			if ((Object)(object)_ball == (Object)null)
			{
				OnEnable(rig);
			}
			Hand leftHand = rig.physicsRig.leftHand;
			Hand rightHand = rig.physicsRig.rightHand;
			bool flag = AbilityHands.Trigger(leftHand) > 0.6f;
			bool flag2 = AbilityHands.Trigger(rightHand) > 0.6f;
			Transform val = AbilityHands.Palm(flag ? leftHand : (flag2 ? rightHand : AbilityHands.Preferred(rig)));
			if (!((Object)(object)val == (Object)null))
			{
				_pullCenter = val.position + val.forward * 0.18f + Vector3.up * 0.025f;
				if ((Object)(object)_ball != (Object)null)
				{
					_ball.SetActive(true);
					_ball.transform.position = _pullCenter;
					_ball.transform.rotation = val.rotation;
					UpdateBallScale();
				}
				_pulling = flag || flag2;
			}
		}

		public override void FixedTick(RigManager rig)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01a9: Unknown result type (might be due to invalid IL or missing references)
			if (!_pulling || (Object)(object)_ball == (Object)null || (Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
			{
				return;
			}
			int num = Physics.OverlapSphereNonAlloc(_pullCenter, _radius, Il2CppReferenceArray<Collider>.op_Implicit(_overlaps), -1, (QueryTriggerInteraction)1);
			_seen.Clear();
			bool flag = false;
			try
			{
				flag = NetworkSceneManager.IsLevelNetworked;
			}
			catch
			{
			}
			for (int i = 0; i < num; i++)
			{
				Collider val = _overlaps[i];
				_overlaps[i] = null;
				if ((Object)(object)val == (Object)null || ((Component)val).transform.IsChildOf(((Component)rig).transform))
				{
					continue;
				}
				Rigidbody attachedRigidbody = val.attachedRigidbody;
				if ((Object)(object)attachedRigidbody == (Object)null || attachedRigidbody.isKinematic || !_seen.Add(attachedRigidbody))
				{
					continue;
				}
				if (flag)
				{
					NetworkEntity val2 = null;
					MarrowEntity componentInParent = ((Component)attachedRigidbody).GetComponentInParent<MarrowEntity>();
					if ((Object)(object)componentInParent == (Object)null || !IMarrowEntityExtender.Cache.TryGet(componentInParent, ref val2) || val2 == null)
					{
						continue;
					}
					if (!val2.IsOwner)
					{
						int instanceID = ((Object)attachedRigidbody).GetInstanceID();
						if (!_ownershipRetry.TryGetValue(instanceID, out var value) || Time.time >= value)
						{
							NetworkEntityManager.TakeOwnership(val2);
							_ownershipRetry[instanceID] = Time.time + 0.3f;
						}
						continue;
					}
				}
				Vector3 val3 = attachedRigidbody.velocity - rig.physicsRig.wholeBodyVelocity;
				Vector3 val4 = (_pullCenter - attachedRigidbody.worldCenterOfMass) * 42f - val3 * 7f;
				attachedRigidbody.AddForce(Vector3.ClampMagnitude(val4, 55f), (ForceMode)5);
			}
			if (_ownershipRetry.Count > 256)
			{
				_ownershipRetry.Clear();
			}
		}

		private void UpdateBallScale()
		{
			//IL_0019: 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)
			if ((Object)(object)_ball != (Object)null)
			{
				_ball.transform.localScale = Vector3.one * (_radius * 2f);
			}
		}
	}
	public class SuperJumpAbility : Ability
	{
		private readonly List<Rigidbody> _body = new List<Rigidbody>();

		private bool _wasHeld;

		public override string Name
		{
			get
			{
				if (!Prefs.LeftHanded)
				{
					return "Super jump (A)";
				}
				return "Super jump (X)";
			}
		}

		public override SyncKind Sync => SyncKind.LocalOnly;

		public override void OnEnable(RigManager rig)
		{
			AbilityInput.CacheBody(rig, _body);
			_wasHeld = AbilityInput.IsHeld(JetpackButton.RightA);
		}

		public override void OnDisable(RigManager rig)
		{
			_body.Clear();
		}

		public override void FixedTick(RigManager rig)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			bool flag = AbilityInput.IsHeld(JetpackButton.RightA);
			if (flag && !_wasHeld)
			{
				AbilityHands.AddVelocity(_body, Vector3.up * 4.5f, skipKinematic: false);
			}
			_wasHeld = flag;
		}
	}
	public class DashAbility : Ability
	{
		private readonly List<Rigidbody> _body = new List<Rigidbody>();

		private bool _wasHeld;

		private bool _dashQueued;

		private float _nextDashTime;

		public override string Name
		{
			get
			{
				if (!Prefs.LeftHanded)
				{
					return "Dash (B)";
				}
				return "Dash (Y)";
			}
		}

		public override SyncKind Sync => SyncKind.LocalOnly;

		public override void OnEnable(RigManager rig)
		{
			AbilityInput.CacheBody(rig, _body);
			_wasHeld = AbilityInput.IsHeld(JetpackButton.RightB);
			_dashQueued = false;
			_nextDashTime = 0f;
		}

		public override void OnDisable(RigManager rig)
		{
			_body.Clear();
			_dashQueued = false;
		}

		public override void Tick(RigManager rig)
		{
			if (ThighSpawnGunAbility.Active && Prefs.LeftHanded)
			{
				_wasHeld = SpawnGunButton.Held;
				if (SpawnGunButton.TapThisFrame)
				{
					SpawnGunButton.ConsumeTap("Dash");
					_dashQueued = true;
				}
			}
			else
			{
				bool flag = AbilityInput.IsHeld(JetpackButton.RightB);
				if (flag && !_wasHeld)
				{
					_dashQueued = true;
				}
				_wasHeld = flag;
			}
		}

		public override void FixedTick(RigManager rig)
		{
			//IL_004a: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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 (!_dashQueued)
			{
				return;
			}
			_dashQueued = false;
			if (_body.Count == 0 || Time.time < _nextDashTime || (Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
			{
				return;
			}
			PhysicsRig physicsRig = rig.physicsRig;
			Vector3 val = FloatingMenu.TorsoForward(physicsRig);
			val.y = 0f;
			if (!(((Vector3)(ref val)).sqrMagnitude <= 0.001f))
			{
				((Vector3)(ref val)).Normalize();
				float num = Vector3.Dot(physicsRig.wholeBodyVelocity, val);
				float num2 = Mathf.Min(7.5f, 11f - num);
				if (!(num2 <= 0f))
				{
					AbilityHands.AddVelocity(_body, val * num2, skipKinematic: true);
					_nextDashTime = Time.time + 0.3f;
					Melon<Main>.Logger.Msg("Dash: added " + num2.ToString("F1") + " m/s forward velocity.");
				}
			}
		}
	}
	public class SuperDashAbility : Ability
	{
		private const float BurstSpeed = 10f;

		private const float MaximumForwardSpeed = 15f;

		private const float RagdollDuration = 0.85f;

		private const float Cooldown = 1.4f;

		private readonly List<Rigidbody> _body = new List<Rigidbody>();

		private PhysicsRig _ragdollRig;

		private bool _wasHeld;

		private bool _dashQueued;

		private float _recoverAt;

		private float _nextDashTime;

		public override string Name
		{
			get
			{
				if (!Prefs.LeftHanded)
				{
					return "Super dash (B)";
				}
				return "Super dash (Y)";
			}
		}

		public override SyncKind Sync => SyncKind.LocalOnly;

		public override void OnEnable(RigManager rig)
		{
			Recover();
			AbilityInput.CacheBody(rig, _body);
			_wasHeld = AbilityInput.IsHeld(JetpackButton.RightB);
			_dashQueued = false;
			_nextDashTime = 0f;
		}

		public override void OnDisable(RigManager rig)
		{
			Recover();
			_body.Clear();
			_dashQueued = false;
		}

		public override void Tick(RigManager rig)
		{
			if ((Object)(object)_ragdollRig != (Object)null && Time.time >= _recoverAt)
			{
				Recover();
			}
			if (ThighSpawnGunAbility.Active && Prefs.LeftHanded)
			{
				_wasHeld = SpawnGunButton.Held;
				if (SpawnGunButton.TapThisFrame)
				{
					SpawnGunButton.ConsumeTap("Super Dash");
					_dashQueued = true;
				}
			}
			else
			{
				bool flag = AbilityInput.IsHeld(JetpackButton.RightB);
				if (flag && !_wasHeld)
				{
					_dashQueued = true;
				}
				_wasHeld = flag;
			}
		}

		public override void FixedTick(RigManager rig)
		{
			//IL_004a: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (!_dashQueued)
			{
				return;
			}
			_dashQueued = false;
			if (_body.Count == 0 || Time.time < _nextDashTime || (Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
			{
				return;
			}
			PhysicsRig physicsRig = rig.physicsRig;
			Vector3 val = FloatingMenu.TorsoForward(physicsRig);
			val.y = 0f;
			if (!(((Vector3)(ref val)).sqrMagnitude <= 0.001f))
			{
				((Vector3)(ref val)).Normalize();
				float num = Vector3.Dot(physicsRig.wholeBodyVelocity, val);
				float num2 = Mathf.Min(10f, 15f - num);
				if (!(num2 <= 0.1f))
				{
					Recover();
					physicsRig.RagdollRig();
					_ragdollRig = physicsRig;
					_recoverAt = Time.time + 0.85f;
					AbilityHands.AddVelocity(_body, val * num2, skipKinematic: true);
					_nextDashTime = Time.time + 1.4f;
					Melon<Main>.Logger.Msg("Super dash: ragdolled burst at " + (num + num2).ToString("F1") + " m/s.");
				}
			}
		}

		private void Recover()
		{
			if (!((Object)(object)_ragdollRig == (Object)null))
			{
				try
				{
					_ragdollRig.UnRagdollRig();
				}
				catch (Exception ex)
				{
					Melon<Main>.Logger.Warning("Super dash recovery failed: " + ex.Message);
				}
				_ragdollRig = null;
				_recoverAt = 0f;
			}
		}
	}
	public class BackfilpAbility : Ability
	{
		private readonly List<Rigidbody> _body = new List<Rigidbody>();

		private PhysicsRig _ragdollRig;

		private bool _usedFusionRagdoll;

		private bool _wasHeld;

		private bool _flipQueued;

		private float _recoverAt;

		private float _nextFlipTime;

		private bool _flipSpin;

		private float _spinUntil;

		private Vector3 _spinAxis;

		public override string Name
		{
			get
			{
				if (!Prefs.LeftHanded)
				{
					return "Backfilp (Y)";
				}
				return "Backfilp (B)";
			}
		}

		public override SyncKind Sync => SyncKind.LabFusionSynced;

		public override void OnEnable(RigManager rig)
		{
			Recover();
			_usedFusionRagdoll = false;
			AbilityInput.CacheBody(rig, _body);
			_wasHeld = AbilityInput.IsHeld(JetpackButton.LeftY);
			_flipQueued = false;
			_nextFlipTime = 0f;
			_flipSpin = false;
			_spinUntil = 0f;
			Melon<Main>.Logger.Msg("Backfilp ready: press " + (Prefs.LeftHanded ? "B" : "Y") + ".");
		}

		public override void OnDisable(RigManager rig)
		{
			CancelFusionRagdoll();
			Recover();
			_body.Clear();
			_flipQueued = false;
			_flipSpin = false;
			_spinUntil = 0f;
		}

		public override void Tick(RigManager rig)
		{
			if ((Object)(object)_ragdollRig != (Object)null && Time.time >= _recoverAt)
			{
				Recover();
			}
			else if (_usedFusionRagdoll && Time.time >= _recoverAt)
			{
				_usedFusionRagdoll = false;
				_flipSpin = false;
			}
			if (MenuSet.IsAnyOpen)
			{
				_wasHeld = AbilityInput.IsHeld(JetpackButton.LeftY);
				_flipQueued = false;
			}
			else if (ThighSpawnGunAbility.Active && !Prefs.LeftHanded)
			{
				_wasHeld = SpawnGunButton.Held;
				if (SpawnGunButton.TapThisFrame)
				{
					SpawnGunButton.ConsumeTap("Backflip");
					_flipQueued = true;
				}
			}
			else
			{
				bool flag = AbilityInput.IsHeld(JetpackButton.LeftY);
				if (flag && !_wasHeld)
				{
					_flipQueued = true;
				}
				_wasHeld = flag;
			}
		}

		public override void FixedTick(RigManager rig)
		{
			//IL_01ba: 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_0072: 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_0096: 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_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)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_00fd: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			ApplyFlipSpin(rig);
			if (!_flipQueued)
			{
				return;
			}
			_flipQueued = false;
			if (MenuSet.IsAnyOpen || _body.Count == 0 || (Object)(object)_ragdollRig != (Object)null || LocalRagdoll.KnockedOut || Time.time < _nextFlipTime || (Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
			{
				return;
			}
			PhysicsRig physicsRig = rig.physicsRig;
			Vector3 val = FloatingMenu.TorsoForward(physicsRig);
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude <= 0.001f)
			{
				return;
			}
			((Vector3)(ref val)).Normalize();
			Vector3 val2 = -val;
			Vector3 wholeBodyVelocity = physicsRig.wholeBodyVelocity;
			float num = Mathf.Max(0f, 9f - Vector3.Dot(wholeBodyVelocity, val2));
			float num2 = Mathf.Max(0f, 5.5f - wholeBodyVelocity.y);
			Vector3 delta = val2 * num + Vector3.up * num2;
			Recover();
			_usedFusionRagdoll = false;
			_spinAxis = Vector3.Cross(val, Vector3.up);
			if (((Vector3)(ref _spinAxis)).sqrMagnitude > 0.0001f)
			{
				((Vector3)(ref _spinAxis)).Normalize();
			}
			else
			{
				_spinAxis = Vector3.right;
			}
			_flipSpin = true;
			_spinUntil = Time.time + 1.1f;
			bool flag = false;
			try
			{
				flag = NetworkSceneManager.IsLevelNetworked;
			}
			catch
			{
			}
			if (flag)
			{
				try
				{
					LocalRagdoll.Knockout(1.1f, false);
					_usedFusionRagdoll = true;
					_recoverAt = Time.time + 1.1f;
				}
				catch (Exception ex)
				{
					Melon<Main>.Logger.Warning("Backfilp: Fusion ragdoll failed, using the local one: " + ex.Message);
					RagdollLocally(physicsRig);
				}
			}
			else
			{
				RagdollLocally(physicsRig);
			}
			AbilityHands.AddVelocity(_body, delta, skipKinematic: true);
			ApplyFlipSpin(rig);
			_nextFlipTime = Time.time + 1.5f;
			Melon<Main>.Logger.Msg("Backfilp: " + (flag ? "Fusion" : "local") + " ragdoll, backward " + num.ToString("F1") + " m/s, up " + num2.ToString("F1") + " m/s.");
		}

		private void ApplyFlipSpin(RigManager rig)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (!_flipSpin)
			{
				return;
			}
			if (Time.time > _spinUntil)
			{
				_flipSpin = false;
			}
			else
			{
				if ((Object)(object)rig == (Object)null || (Object)(object)rig.physicsRig == (Object)null)
				{
					return;
				}
				Vector3 target = _spinAxis * (MathF.PI * 2f);
				Rigidbody val = null;
				try
				{
					val = ((Component)((Rig)rig.physicsRig).m_pelvis).GetComponent<Rigidbody>();
					if ((Object)(object)val == (Object)null)
					{
						val = ((Component)((Component)((Rig)rig.physicsRig).m_pelvis).transform).GetComponentInParent<Rigidbody>();
					}
				}
				catch
				{
				}
				if (!((Object)(object)val != (Object)null) || val.isKinematic)
				{
					foreach (Rigidbody item in _body)
					{
						if ((Object)(object)item != (Object)null && !item.isKinematic)
						{
							SetSpin(item, target);
						}
					}
					return;
				}
				SetSpin(val, target);
			}
		}

		private void SetSpin(Rigidbody rb, Vector3 target)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0009: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 angularVelocity = rb.angularVelocity;
			Vector3 val = Vector3.Project(angularVelocity, _spinAxis);
			rb.angularVelocity = angularVelocity + (target - val);
		}

		private void RagdollLocally(PhysicsRig phys)
		{
			phys.RagdollRig();
			_ragdollRig = phys;
			_recoverAt = Time.time + 1.1f;
		}

		private void Recover()
		{
			_flipSpin = false;
			_spinUntil = 0f;
			if (!((Object)(object)_ragdollRig == (Object)null))
			{
				try
				{
					_ragdollRig.UnRagdollRig();
				}
				catch (Exception ex)
				{
					Melon<Main>.Logger.Warning("Backfilp recovery failed: " + ex.Message);
				}
				_ragdollRig = null;
				_recoverAt = 0f;
			}
		}

		private void CancelFusionRagdoll()
		{
			if (!_usedFusionRagdoll)
			{
				return;
			}
			_usedFusionRagdoll = false;
			try
			{
				LocalRagdoll.ToggleRagdoll(false);
			}
			catch (Exception ex)
			{
				Melon<Main>.Logger.Warning("Backfilp: could not clear the Fusion ragdoll: " + ex.Message);
			}
		}
	}
	public class StickRagdollAbility : Ability
	{
		private readonly List<Rigidbody> _body = new List<Rigidbody>();

		private PhysicsRig _ragdollRig;

		private bool _usedFusionRagdoll;

		private bool _launchQueued;

		private bool _launchLeft;

		private bool _lastStickLeft;

		private bool _armed;

		private Vector2 _launchStick;

		private float _recoverAt;

		private float _nextLaunchTime;

		private bool _spinning;

		private float _spinUntil;

		private Vector3 _spinAxis;

		public override string Name
		{
			get
			{
				if (!Prefs.LeftHanded)
				{
					return "Stick ragdoll (L)";
				}
				return "Stick ragdoll (R)";
			}
		}

		public override SyncKind Sync => SyncKind.LabFusionSynced;

		public override void OnEnable(RigManager rig)
		{
			//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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Recover();
			_usedFusionRagdoll = false;
			AbilityInput.CacheBody(rig, _body);
			_launchQueued = false;
			_launchLeft = !Prefs.LeftHanded;
			_lastStickLeft = _launchLeft;
			_launchStick = Vector2.zero;
			_nextLaunchTime = 0f;
			_spinning = false;
			_spinUntil = 0f;
			float num = 0.3f;
			Vector2 val = AbilityInput.Thumbstick(_launchLeft);
			_armed = ((Vector2)(ref val)).sqrMagnitude < num * num;
			Melon<Main>.Logger.Msg("Stick ragdoll ready: push the " + (_launchLeft ? "left" : "right") + " stick in a direction (" + _body.Count + " body parts).");
		}

		public override void OnDisable(RigManager rig)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			CancelFusionRagdoll();
			Recover();
			_body.Clear();
			_launchQueued = false;
			_launchStick = Vector2.zero;
			_armed = false;
			_spinning = false;
			_spinUntil = 0f;
		}

		public override void Tick(RigManager rig)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_ragdollRig != (Object)null && Time.time >= _recoverAt)
			{
				Recover();
			}
			else if (_usedFusionRagdoll && Time.time >= _recoverAt)
			{
				_usedFusionRagdoll = false;
				_spinning = false;
			}
			bool flag = !Prefs.LeftHanded;
			if (flag != _lastStickLeft)
			{
				_lastStickLeft = flag;
				_launchLeft = flag;
				_launchQueued = false;
				_launchStick = Vector2.zero;
				_armed = false;
			}
			if (MenuSet.IsAnyOpen)
			{
				_launchQueued = false;
				_launchStick = Vector2.zero;
				_armed = false;
				return;
			}
			float num = 0.3f;
			Vector2 launchStick = AbilityInput.Thumbstick(flag);
			if (((Vector2)(ref launchStick)).sqrMagnitude < num * num)
			{
				_armed = true;
			}
			else if (_armed)
			{
				_armed = false;
				_launchLeft = flag;
				_launchStick = launchStick;
				_launchQueued = true;
				Melon<Main>.Logger.Msg("Stick ragdoll: " + (_launchLeft ? "left" : "right") + " stick pushed " + launchStick.x.ToString("F2") + "," + launchStick.y.ToString("F2") + ".");
			}
		}

		public override void FixedTick(RigManager rig)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might