Decompiled source of bmo gui v1.0.2

mods/ModMenu.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.VRMK;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LabFusion.Network;
using LabFusion.Network.Serialization;
using LabFusion.SDK.Modules;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using ModMenu;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Main), "ModMenu", "0.3.0", "You", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "BoneLib" })]
[assembly: MelonOptionalDependencies(new string[] { "LabFusion" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ModMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ModMenu")]
[assembly: AssemblyTitle("ModMenu")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[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 ModMenu
{
	public static class FusionSync
	{
		public static void Register()
		{
			ModuleManager.RegisterModule<ModMenuModule>();
			Main.FlingBroadcast = SendFling;
		}

		private static void SendFling(Vector3 targetPos, Vector3 velocity, int kind)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_002a: 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_0042: 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)
			MessageRelay.RelayModule<FlingMessage, FlingData>(new FlingData
			{
				Tx = targetPos.x,
				Ty = targetPos.y,
				Tz = targetPos.z,
				Vx = velocity.x,
				Vy = velocity.y,
				Vz = velocity.z,
				Kind = kind
			}, new MessageRoute((RelayType)3, (NetworkChannel)0));
		}
	}
	public class ModMenuModule : Module
	{
		public override string Name => "ModMenu";

		public override string Author => "You";

		public override Version Version => new Version(1, 1, 0);

		public override ConsoleColor Color => ConsoleColor.Cyan;

		protected override void OnModuleRegistered()
		{
			ModuleMessageManager.RegisterHandler<FlingMessage>();
		}

		protected override void OnModuleUnregistered()
		{
		}
	}
	public class FlingData : INetSerializable
	{
		public float Tx;

		public float Ty;

		public float Tz;

		public float Vx;

		public float Vy;

		public float Vz;

		public float Kind;

		public int? GetSize()
		{
			return 28;
		}

		public void Serialize(INetSerializer serializer)
		{
			serializer.SerializeValue(ref Tx);
			serializer.SerializeValue(ref Ty);
			serializer.SerializeValue(ref Tz);
			serializer.SerializeValue(ref Vx);
			serializer.SerializeValue(ref Vy);
			serializer.SerializeValue(ref Vz);
			serializer.SerializeValue(ref Kind);
		}
	}
	public class FlingMessage : ModuleMessageHandler
	{
		protected override void OnHandleMessage(ReceivedMessage received)
		{
			//IL_002f: 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)
			FlingData flingData = ((ReceivedMessage)(ref received)).ReadData<FlingData>();
			Main.OnRemoteFling(((ReceivedMessage)(ref received)).Sender.ToString(), new Vector3(flingData.Tx, flingData.Ty, flingData.Tz), new Vector3(flingData.Vx, flingData.Vy, flingData.Vz), (int)flingData.Kind);
		}
	}
	public class Main : MelonMod
	{
		private class CatItem
		{
			public string Title;

			public string Barcode;

			public bool Stock;

			public bool Gun;

			public bool Melee;
		}

		private class Btn
		{
			public RectTransform Rt;

			public Image Img;

			public Text Txt;

			public Action<Text> Act;

			public Color Base;

			public Color Hover;

			public Color TextBase;

			public float FlashUntil;

			public Text Txt2;
		}

		private class PendingLaunch
		{
			public Vector3 Pos;

			public Vector3 Vel;

			public HashSet<int> Before;

			public float Due;

			public float Expire;
		}

		private class SpawnJob
		{
			public CatItem Item;

			public int Total;

			public int Done;

			public bool Online;

			public bool Capped;

			public float Next;

			public Vector3 Origin;

			public Vector3 Right;

			public Vector3 Forward;
		}

		private class Claw
		{
			public bool Left;

			public bool Fist;

			public bool Pending;

			public GameObject Go;

			public Rigidbody Body;

			public Vector3 AxisLocal = Vector3.up;

			public Vector3 HiltLocal;

			public Vector3 SpawnPos;

			public Vector3 TargetPos;

			public Quaternion TargetRot = Quaternion.identity;

			public HashSet<int> Before;

			public float Due;

			public float Expire;

			public float LastChange;
		}

		private class VoidPending
		{
			public Vector3 Pos;

			public Vector3 Vel;

			public HashSet<int> Before;

			public float Due;

			public float Expire;
		}

		private class VoidFlying
		{
			public Transform T;

			public Rigidbody Rb;

			public Vector3 Vel;

			public float Until;
		}

		private class Drop
		{
			public GameObject Go;

			public Vector3 Vel;

			public float Born;

			public bool Alive;
		}

		private class PeeSource
		{
			public Vector3 Pos;

			public Vector3 Vel;

			public float Until;

			public float NextEmit;
		}

		private const float CanvasScale = 0.0007f;

		private const float TogetherDist = 0.15f;

		private const float DoubleTapWindow = 0.6f;

		private const float HoverDepth = 0.18f;

		private const float ClickDepth = 0.07f;

		private const bool ShowTipDots = true;

		private const float HitPad = 10f;

		private const float RowH = 44f;

		private const float RowW = 392f;

		private static Color Border = new Color(1f, 1f, 1f, 0.2f);

		private static Color FillCol = new Color(0.18f, 0.18f, 0.2f, 0.72f);

		private static Color RowCol = new Color(0.34f, 0.34f, 0.37f, 0.6f);

		private static Color TabOff = new Color(0.3f, 0.3f, 0.33f, 0.55f);

		private static Color PillOff = new Color(0.14f, 0.14f, 0.16f, 0.85f);

		private static readonly Color WhiteCol = new Color(0.97f, 0.97f, 0.97f, 0.95f);

		private static readonly Color DarkCol = new Color(0.12f, 0.12f, 0.13f, 1f);

		private static readonly Color SoftCol = new Color(0.82f, 0.82f, 0.85f, 0.9f);

		private static Color Divider = new Color(1f, 1f, 1f, 0.18f);

		private GameObject _root;

		private GameObject _content;

		private Sprite _round;

		private Text _status;

		private string _page = "home";

		private string _query = "";

		private string _kbKind = "spawn";

		private Text _queryLabel;

		private float _menuScale = 1f;

		private bool _followHead = true;

		private bool _showDots = true;

		private bool _open;

		private bool _fly;

		private bool _together;

		private bool _armed = true;

		private bool _showStock;

		private bool _catalogLoaded;

		private float _speed = 4f;

		private float _strength = 1f;

		private float _scale = 1f;

		private float _baseJump = -1f;

		private float _lastTap = -10f;

		private float _lastPress = -10f;

		private float _openedAt;

		private readonly List<Btn> _buttons = new List<Btn>();

		private readonly List<CatItem> _avatarItems = new List<CatItem>();

		private readonly List<CatItem> _spawnItems = new List<CatItem>();

		private readonly List<CatItem> _hiddenItems = new List<CatItem>();

		private bool _god;

		private bool _infAmmo;

		private bool _punchFling;

		private float _nextGodTick;

		private float _nextAmmoTick;

		private float _nextRigScan;

		private float _lastFlingSent;

		private bool _haveLastHands;

		private bool _ammoShapeLogged;

		private Vector3 _lastLeftHand;

		private Vector3 _lastRightHand;

		private Type _magazineType;

		private RigManager[] _remoteRigs = (RigManager[])(object)new RigManager[0];

		private const float PunchSpeed = 3.5f;

		private const float PunchReach = 0.5f;

		private const float FlingSpeed = 10f;

		private const float FlingLift = 4f;

		private const float MaxFlingSpeed = 45f;

		private string _godInfo = "God: off";

		private string _ammoInfo = "Ammo: off";

		private Text _infoGod;

		private Text _infoAmmo;

		private const float ObjectReach = 0.3f;

		private const float BoostDuration = 0.15f;

		private float _flingPower = 1f;

		private string _punchInfo = "Punch: off";

		private Text _infoPunch;

		private static float _boostUntil;

		private static Vector3 _boostVelocity;

		private static string _pendingSay;

		private const float ObjectFlingSpeed = 9f;

		private float _lastPlayerFling;

		private static float _lastObjectFlingStatic;

		private float _gravity = 1f;

		private bool _flap;

		private float _flapPower = 1f;

		private float _lastFlapL = -10f;

		private float _lastFlapR = -10f;

		private float _nextBodyScan;

		private Vector3 _flapPrevL;

		private Vector3 _flapPrevR;

		private bool _flapHavePrev;

		private Rigidbody[] _bodyRbs = (Rigidbody[])(object)new Rigidbody[0];

		private const float FlapMinSpeed = 1.6f;

		private const float FlapGain = 0.8f;

		private const float FlapMaxLift = 4f;

		private const float MaxRiseSpeed = 7f;

		private bool _swordFist;

		private bool _fistL;

		private bool _fistR;

		private bool _gripSearched;

		private int _swordIdx;

		private float _lastSword;

		private float _openDistL = 0.01f;

		private float _openDistR = 0.01f;

		private string _swordInfo = "Sword fist: off";

		private string _fistSource = "none";

		private Text _infoSword;

		private MethodInfo _gripMethodL;

		private MethodInfo _gripMethodR;

		private PropertyInfo _gripPropL;

		private PropertyInfo _gripPropR;

		private readonly List<PendingLaunch> _launches = new List<PendingLaunch>();

		private const float SwordSpeed = 18f;

		private const float SwordRepeat = 0.6f;

		private const float SwordFistThreshold = 0.8f;

		private static readonly int[] AmountSteps = new int[9] { 1, 5, 10, 25, 50, 100, 250, 500, 1000 };

		private const int OnlineMaxPerPress = 25;

		private int _amountIdx;

		private SpawnJob _job;

		private readonly Claw _clawL = new Claw
		{
			Left = true
		};

		private readonly Claw _clawR = new Claw
		{
			Left = false
		};

		private bool _claws;

		private int _bladeIdx;

		private int _clawHands;

		private string _clawInfo = "Claws: off";

		private Text _infoClaw;

		private Type _pooleeType;

		private const float ClawOut = 0.9f;

		private const float ClawIn = 0.6f;

		private bool _void;

		private bool _voidTrigL;

		private bool _voidTrigR;

		private bool _trigSearched;

		private float _lastVoid;

		private int _voidIdx;

		private string _voidInfo = "Void: off";

		private string _trigSource = "none";

		private Text _infoVoid;

		private MethodInfo _trigFloatL;

		private MethodInfo _trigFloatR;

		private MethodInfo _trigBoolL;

		private MethodInfo _trigBoolR;

		private PropertyInfo _trigPropL;

		private PropertyInfo _trigPropR;

		private List<CatItem> _voidCandidates;

		private const float VoidSpeed = 22f;

		private const float VoidRepeat = 0.5f;

		private readonly List<VoidPending> _voidPending = new List<VoidPending>();

		private readonly List<VoidFlying> _voidFlying = new List<VoidFlying>();

		private bool _pee;

		private bool _peeSearched;

		private float _nextPeeEmit;

		private float _nextPeeSend;

		private MethodInfo _peeBtnMethod;

		private PropertyInfo _peeBtnProp;

		private const int MaxDrops = 120;

		private const float DropLife = 1.5f;

		private const float PeeRate = 0.025f;

		private const float PeeSendEvery = 0.2f;

		private readonly List<Drop> _drops = new List<Drop>();

		private static readonly Dictionary<string, PeeSource> _peeSources = new Dictionary<string, PeeSource>();

		public static Action<Vector3, Vector3, int> FlingBroadcast;

		public static bool AllowFlungByOthers = true;

		private static float _lastFlingReceived;

		private bool _fusionRegistered;

		private string _fusionStatus = "starting";

		private float _nextFusionTry;

		private int _fusionTries;

		private int _flingSent;

		private static int _flingRecv;

		private static int _flingHit;

		private static float _lastRecvTime = -1f;

		private static readonly string[] ThemeNames = new string[9] { "Grey", "Blue", "Red", "Green", "Purple", "Yellow", "Graffiti", "Einstein", "Slob Slibe" };

		private const int GraffitiTheme = 6;

		private const int EinsteinTheme = 7;

		private const int SlobTheme = 8;

		private static readonly Color[] ThemeAccent = (Color[])(object)new Color[9]
		{
			new Color(0.62f, 0.62f, 0.66f),
			new Color(0.25f, 0.5f, 1f),
			new Color(1f, 0.25f, 0.25f),
			new Color(0.25f, 0.85f, 0.4f),
			new Color(0.65f, 0.35f, 1f),
			new Color(1f, 0.85f, 0.2f),
			new Color(0.2f, 0.75f, 0.7f),
			new Color(0.85f, 0.85f, 0.88f),
			new Color(0.75f, 0.25f, 0.65f)
		};

		private int _themeIdx;

		private MelonPreferences_Entry<int> _themePref;

		private const int GraffitiW = 384;

		private const int GraffitiH = 512;

		private readonly Dictionary<int, Sprite> _themeSprites = new Dictionary<int, Sprite>();

		private const float FallbackReach = 0.12f;

		private Animator _animator;

		private float _nextAnimatorLookup;

		private string _tipSource = "none";

		private bool _tipReported;

		private readonly GameObject[] _tipDots = (GameObject[])(object)new GameObject[2];

		private const float DwellTime = 0.5f;

		private bool _freeze;

		private bool _dwellLocked;

		private Vector3 _lockPos;

		private Btn _dwellBtn;

		private float _dwellT;

		private float _heightBase = -1f;

		private string _scaleInfo = "Size: x1";

		private Text _infoScale;

		private static readonly string[] A = new string[20]
		{
			"Swift", "Silent", "Giant", "Tiny", "Wobbly", "Crimson", "Lunar", "Salty", "Cosmic", "Fuzzy",
			"Turbo", "Sleepy", "Neon", "Rusty", "Mighty", "Sneaky", "Frosty", "Spicy", "Cursed", "Golden"
		};

		private static readonly string[] N = new string[20]
		{
			"Fox", "Cube", "Ranger", "Pilot", "Goblin", "Ghost", "Biscuit", "Nomad", "Pickle", "Wizard",
			"Raccoon", "Toaster", "Falcon", "Noodle", "Viking", "Robot", "Bandit", "Moth", "Walrus", "Knight"
		};

		private float Cs
		{
			get
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)_root != (Object)null))
				{
					return 0.0007f;
				}
				return _root.transform.localScale.x;
			}
		}

		private static bool IsQuest => (int)Application.platform == 11;

		private static int MaxOfflineSpawn
		{
			get
			{
				if (!IsQuest)
				{
					return 1000;
				}
				return 100;
			}
		}

		private int Amount => AmountSteps[_amountIdx];

		private static object GetMember(object target, string name)
		{
			if (target == null)
			{
				return null;
			}
			Type type = target.GetType();
			PropertyInfo property = type.GetProperty(name, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null)
			{
				return property.GetValue(target);
			}
			FieldInfo field = type.GetField(name, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (!(field != null))
			{
				return null;
			}
			return field.GetValue(target);
		}

		private static PropertyInfo FindNumeric(Type t, params string[] words)
		{
			return t.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((PropertyInfo p) => p.CanRead && p.CanWrite && (p.PropertyType == typeof(float) || p.PropertyType == typeof(int)) && words.All((string w) => p.Name.IndexOf(w, StringComparison.OrdinalIgnoreCase) >= 0));
		}

		private static double GetNumber(PropertyInfo p, object target)
		{
			return Convert.ToDouble(p.GetValue(target));
		}

		private static void SetNumber(PropertyInfo p, object target, double v)
		{
			p.SetValue(target, (p.PropertyType == typeof(int)) ? ((object)(int)v) : ((object)(float)v));
		}

		private static object FindHealthObject()
		{
			RigManager rigManager = Player.RigManager;
			if ((Object)(object)rigManager == (Object)null)
			{
				return null;
			}
			object member = GetMember(rigManager, "health");
			if (member != null)
			{
				return member;
			}
			PropertyInfo[] properties = ((object)rigManager).GetType().GetProperties(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (propertyInfo.GetIndexParameters().Length != 0 || propertyInfo.PropertyType.Name.IndexOf("Health", StringComparison.OrdinalIgnoreCase) < 0)
				{
					continue;
				}
				try
				{
					object value = propertyInfo.GetValue(rigManager);
					if (value != null)
					{
						return value;
					}
				}
				catch
				{
				}
			}
			return null;
		}

		private string SetGodState(bool on)
		{
			object obj = FindHealthObject();
			if (obj == null)
			{
				return "no health object found";
			}
			Type type = obj.GetType();
			string text = "no Invincible setting found";
			PropertyInfo[] properties = type.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (!propertyInfo.CanRead || !propertyInfo.CanWrite || !propertyInfo.PropertyType.IsEnum || propertyInfo.GetIndexParameters().Length != 0)
				{
					continue;
				}
				string text2 = Enum.GetNames(propertyInfo.PropertyType).FirstOrDefault((string n) => n.Equals(on ? "Invincible" : "Mortal", StringComparison.OrdinalIgnoreCase));
				if (text2 != null)
				{
					try
					{
						propertyInfo.SetValue(obj, Enum.Parse(propertyInfo.PropertyType, text2));
						string text3 = propertyInfo.GetValue(obj).ToString();
						text = propertyInfo.Name + " = " + text3 + (text3.Equals(text2, StringComparison.OrdinalIgnoreCase) ? "" : " (reset by game)");
					}
					catch (Exception ex)
					{
						text = propertyInfo.Name + " failed: " + Trunc(ex.Message, 20);
					}
					break;
				}
			}
			if (on)
			{
				try
				{
					PropertyInfo propertyInfo2 = FindNumeric(type, "curr", "health");
					PropertyInfo propertyInfo3 = FindNumeric(type, "max", "health");
					if (propertyInfo2 != null && propertyInfo3 != null && GetNumber(propertyInfo2, obj) < GetNumber(propertyInfo3, obj))
					{
						SetNumber(propertyInfo2, obj, GetNumber(propertyInfo3, obj));
						text += ", health refilled";
					}
				}
				catch
				{
				}
			}
			return text;
		}

		private void ApplyGodMode()
		{
			try
			{
				_godInfo = "God: " + SetGodState(_god);
				Say(_god ? "God mode ON" : "God mode OFF");
				if (_god && _godInfo.Contains("no "))
				{
					FusionBridge.LogShape(FindHealthObject()?.GetType());
				}
			}
			catch (Exception ex)
			{
				_godInfo = "God: error " + Trunc(ex.Message, 30);
				MelonLogger.Warning(ex.ToString());
			}
			if ((Object)(object)_infoGod != (Object)null)
			{
				_infoGod.text = _godInfo;
			}
		}

		private void GodTick()
		{
			if (_god && !(Time.time < _nextGodTick))
			{
				_nextGodTick = Time.time + 0.25f;
				try
				{
					_godInfo = "God: " + SetGodState(on: true);
				}
				catch
				{
				}
				if ((Object)(object)_infoGod != (Object)null)
				{
					_infoGod.text = _godInfo;
				}
			}
		}

		private static PropertyInfo FindNumericDeep(object root, out object owner, params string[] words)
		{
			owner = null;
			Queue<KeyValuePair<object, int>> queue = new Queue<KeyValuePair<object, int>>();
			queue.Enqueue(new KeyValuePair<object, int>(root, 0));
			int num = 0;
			while (queue.Count > 0 && num++ < 40)
			{
				KeyValuePair<object, int> keyValuePair = queue.Dequeue();
				object key = keyValuePair.Key;
				Type type = key.GetType();
				PropertyInfo propertyInfo = FindNumeric(type, words);
				if (propertyInfo != null)
				{
					owner = key;
					return propertyInfo;
				}
				if (keyValuePair.Value >= 2)
				{
					continue;
				}
				PropertyInfo[] properties = type.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (PropertyInfo propertyInfo2 in properties)
				{
					if (!propertyInfo2.CanRead || propertyInfo2.GetIndexParameters().Length != 0 || propertyInfo2.PropertyType.IsEnum || !(propertyInfo2.PropertyType.Namespace ?? "").StartsWith("Il2CppSLZ"))
					{
						continue;
					}
					try
					{
						object value = propertyInfo2.GetValue(key);
						if (value != null)
						{
							queue.Enqueue(new KeyValuePair<object, int>(value, keyValuePair.Value + 1));
						}
					}
					catch
					{
					}
				}
			}
			return null;
		}

		private int RefillMagazine(object mag)
		{
			object owner;
			PropertyInfo propertyInfo = FindNumericDeep(mag, out owner, "ammo", "count") ?? FindNumericDeep(mag, out owner, "ammo");
			if (propertyInfo == null)
			{
				return -1;
			}
			object owner2;
			PropertyInfo propertyInfo2 = FindNumericDeep(mag, out owner2, "round") ?? FindNumericDeep(mag, out owner2, "capacity") ?? FindNumericDeep(mag, out owner2, "max", "ammo");
			double num = ((propertyInfo2 != null) ? GetNumber(propertyInfo2, owner2) : 30.0);
			if (num < 1.0)
			{
				num = 30.0;
			}
			if (GetNumber(propertyInfo, owner) < num)
			{
				SetNumber(propertyInfo, owner, num);
				return 1;
			}
			return 0;
		}

		private void AmmoTick(PhysicsRig rig)
		{
			//IL_013d: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			if (!_infAmmo || Time.time < _nextAmmoTick)
			{
				return;
			}
			_nextAmmoTick = Time.time + 0.25f;
			try
			{
				if (_magazineType == null)
				{
					_magazineType = (from a in AppDomain.CurrentDomain.GetAssemblies()
						where a.GetName().Name.StartsWith("Il2CppSLZ")
						select a).SelectMany(delegate(Assembly a)
					{
						try
						{
							return a.GetTypes();
						}
						catch
						{
							return new Type[0];
						}
					}).FirstOrDefault((Type t) => t.Name == "Magazine");
					if (_magazineType == null)
					{
						_ammoInfo = "Ammo: no Magazine class in the game files";
						_infAmmo = false;
						if ((Object)(object)_infoAmmo != (Object)null)
						{
							_infoAmmo.text = _ammoInfo;
						}
						return;
					}
				}
				Il2CppReferenceArray<Object> val = Object.FindObjectsOfType(Il2CppType.From(_magazineType));
				MethodInfo methodInfo = typeof(Il2CppObjectBase).GetMethod("TryCast").MakeGenericMethod(_magazineType);
				Vector3 position = ((Component)rig.leftHand).transform.position;
				Vector3 position2 = ((Component)rig.rightHand).transform.position;
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				int num4 = 0;
				foreach (Object item in (Il2CppArrayBase<Object>)(object)val)
				{
					num++;
					object obj = methodInfo.Invoke(item, null);
					Component val2 = (Component)((obj is Component) ? obj : null);
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					Vector3 position3 = val2.transform.position;
					if (!(Vector3.Distance(position3, position) > 3.5f) || !(Vector3.Distance(position3, position2) > 3.5f))
					{
						num2++;
						int num5 = RefillMagazine(obj);
						if (num5 == 1)
						{
							num3++;
						}
						else if (num5 < 0)
						{
							num4++;
							LogAmmoShapeOnce(obj);
						}
					}
				}
				_ammoInfo = "Ammo: " + num + " mags, " + num2 + " near, " + num3 + " refilled" + ((num4 > 0) ? ", fields?" : "");
			}
			catch (Exception ex)
			{
				_ammoInfo = "Ammo: error " + Trunc((ex.InnerException ?? ex).Message, 26);
				MelonLogger.Warning(ex.ToString());
			}
			if ((Object)(object)_infoAmmo != (Object)null)
			{
				_infoAmmo.text = _ammoInfo;
			}
		}

		private void LogAmmoShapeOnce(object mag)
		{
			if (!_ammoShapeLogged)
			{
				_ammoShapeLogged = true;
				Type type = mag.GetType();
				MelonLogger.Warning("Magazine members: " + string.Join(", ", from p in type.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
					select p.Name + ":" + p.PropertyType.Name));
			}
		}

		private void PunchTick(PhysicsRig rig)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0021: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)rig.leftHand).transform.position;
			Vector3 position2 = ((Component)rig.rightHand).transform.position;
			float deltaTime = Time.deltaTime;
			if (_punchFling && _haveLastHands && deltaTime > 0f && Time.time - _lastFlingSent > 0.35f)
			{
				TryPunch(position, (position - _lastLeftHand) / deltaTime);
				TryPunch(position2, (position2 - _lastRightHand) / deltaTime);
			}
			_lastLeftHand = position;
			_lastRightHand = position2;
			_haveLastHands = true;
		}

		private void SetPunchInfo(string text)
		{
			_punchInfo = "Punch: " + text;
			if ((Object)(object)_infoPunch != (Object)null)
			{
				_infoPunch.text = _punchInfo;
			}
		}

		private void TryPunch(Vector3 handPos, Vector3 handVelocity)
		{
			//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_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: 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_009c: 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_009f: 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_00b0: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			float magnitude = ((Vector3)(ref handVelocity)).magnitude;
			if (magnitude < 3.5f || Time.time - _lastFlingSent < 0.35f)
			{
				return;
			}
			Vector3 val = handVelocity / magnitude;
			if (Time.time > _nextRigScan)
			{
				_nextRigScan = Time.time + 1f;
				_remoteRigs = ((IEnumerable<RigManager>)Object.FindObjectsOfType<RigManager>()).ToArray();
			}
			RigManager rigManager = Player.RigManager;
			bool flag = false;
			RigManager[] remoteRigs = _remoteRigs;
			foreach (RigManager val2 in remoteRigs)
			{
				if ((Object)(object)val2 == (Object)null || (Object)(object)val2 == (Object)(object)rigManager)
				{
					continue;
				}
				flag = true;
				Vector3 val3 = BodyCenter(val2);
				if (!(Vector3.Distance(handPos, val3) > 0.5f) || !(Vector3.Distance(handPos, val3 + Vector3.up * 0.35f) > 0.5f) || !(Vector3.Distance(handPos, val3 - Vector3.up * 0.3f) > 0.5f))
				{
					if (FlingBroadcast == null)
					{
						SetPunchInfo("hit a player, but Fusion sync is not loaded");
						break;
					}
					if (Time.time - _lastPlayerFling < 0.7f)
					{
						return;
					}
					Vector3 arg = (val * 10f + Vector3.up * 4f) * _flingPower;
					try
					{
						FlingBroadcast(val3, arg, 0);
						_flingSent++;
						_lastPlayerFling = Time.time;
						_lastFlingSent = Time.time;
						SetPunchInfo("sent to a player (they need this mod)");
						Say("Punch!");
						return;
					}
					catch (Exception ex)
					{
						SetPunchInfo("send failed: " + Trunc(ex.Message, 30));
						MelonLogger.Warning("Fling send failed: " + ex.Message);
						return;
					}
				}
			}
			if (FlingObject(handPos, handVelocity, val))
			{
				SetPunchInfo("hit an object");
			}
			else
			{
				SetPunchInfo(flag ? "missed (no player in reach)" : "no other player bodies found");
			}
		}

		private bool FlingObject(Vector3 handPos, Vector3 handVelocity, Vector3 dir)
		{
			//IL_0008: 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_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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_0051: 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_005b: 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_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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			Rigidbody val = null;
			float num = float.MaxValue;
			foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(handPos, 0.3f))
			{
				Rigidbody attachedRigidbody = item.attachedRigidbody;
				if ((Object)(object)attachedRigidbody == (Object)null || attachedRigidbody.isKinematic || (Object)(object)((Component)item).GetComponentInParent<RigManager>() != (Object)null)
				{
					continue;
				}
				Vector3 val2 = handVelocity - attachedRigidbody.velocity;
				if (!(((Vector3)(ref val2)).magnitude < 2.45f))
				{
					val2 = attachedRigidbody.worldCenterOfMass - handPos;
					float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						val = attachedRigidbody;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Vector3 val3 = dir * 9f * _flingPower + Vector3.up * 2f;
			val.velocity += val3;
			_lastFlingSent = Time.time;
			_flingSent++;
			Say("Whack!");
			try
			{
				if (FlingBroadcast != null)
				{
					FlingBroadcast(val.worldCenterOfMass, val3, 1);
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("Object fling send failed: " + ex.Message);
			}
			return true;
		}

		public static void OnRemoteFling(string sender, Vector3 targetPos, Vector3 velocity, int kind)
		{
			//IL_008f: 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_009a: 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_006c: 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_0077: 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_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			_flingRecv++;
			_lastRecvTime = Time.time;
			switch (kind)
			{
			case 2:
				_pendingSay = "Test ping received from another player!";
				return;
			case 4:
			{
				if (!_peeSources.TryGetValue(sender, out var value))
				{
					if (_peeSources.Count >= 16)
					{
						return;
					}
					value = new PeeSource
					{
						NextEmit = Time.time
					};
					_peeSources[sender] = value;
				}
				value.Pos = targetPos;
				value.Vel = Vector3.ClampMagnitude(velocity, 6f);
				value.Until = Time.time + 0.4f;
				return;
			}
			}
			try
			{
				velocity = Vector3.ClampMagnitude(velocity, 45f);
				if (kind == 1)
				{
					if (Time.time - _lastObjectFlingStatic < 0.15f)
					{
						return;
					}
					_lastObjectFlingStatic = Time.time;
					{
						foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(targetPos, 0.4f))
						{
							Rigidbody attachedRigidbody = item.attachedRigidbody;
							if (!((Object)(object)attachedRigidbody == (Object)null) && !attachedRigidbody.isKinematic && !((Object)(object)((Component)item).GetComponentInParent<RigManager>() != (Object)null))
							{
								attachedRigidbody.velocity += velocity;
								break;
							}
						}
						return;
					}
				}
				if (!AllowFlungByOthers || Time.time - _lastFlingReceived < 0.5f)
				{
					return;
				}
				RigManager rigManager = Player.RigManager;
				PhysicsRig physicsRig = Player.PhysicsRig;
				if ((Object)(object)rigManager == (Object)null || (Object)(object)physicsRig == (Object)null || Vector3.Distance(BodyCenter(rigManager), targetPos) > 1.5f)
				{
					return;
				}
				_lastFlingReceived = Time.time;
				_flingHit++;
				foreach (Rigidbody componentsInChild in ((Component)physicsRig).GetComponentsInChildren<Rigidbody>())
				{
					componentsInChild.velocity += velocity * 0.5f;
				}
				_boostVelocity = velocity;
				_boostUntil = Time.time + 0.15f;
				_pendingSay = "You got punched!";
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("Fling failed: " + ex.Message);
			}
		}

		private Rigidbody[] GetBodyRbs(PhysicsRig rig)
		{
			if (Time.time > _nextBodyScan)
			{
				_nextBodyScan = Time.time + 1f;
				_bodyRbs = ((IEnumerable<Rigidbody>)((Component)rig).GetComponentsInChildren<Rigidbody>()).ToArray();
			}
			return _bodyRbs;
		}

		public override void OnFixedUpdate()
		{
			//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_0060: 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_0070: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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)
			PhysicsRig physicsRig = Player.PhysicsRig;
			if ((Object)(object)physicsRig == (Object)null)
			{
				return;
			}
			DriveClaw(_clawL);
			DriveClaw(_clawR);
			bool flag = _gravity < 0.999f;
			bool flag2 = Time.time < _boostUntil;
			if (!flag && !flag2)
			{
				return;
			}
			Vector3 val = -Physics.gravity * (1f - _gravity);
			Vector3 val2 = (flag2 ? (_boostVelocity * 3.3333333f) : Vector3.zero);
			Rigidbody[] bodyRbs = GetBodyRbs(physicsRig);
			foreach (Rigidbody val3 in bodyRbs)
			{
				if (!((Object)(object)val3 == (Object)null) && !val3.isKinematic)
				{
					if (flag)
					{
						val3.AddForce(val, (ForceMode)5);
					}
					if (flag2)
					{
						val3.AddForce(val2, (ForceMode)5);
					}
				}
			}
		}

		private float FlapStroke(Vector3 now, Vector3 prev, float dt, float bodyVy, ref float lastFlap)
		{
			//IL_0000: 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)
			float num = (now.y - prev.y) / dt - bodyVy;
			if (num > -1.6f || Time.time - lastFlap < 0.12f)
			{
				return 0f;
			}
			lastFlap = Time.time;
			return Mathf.Min((0f - num) * 0.8f, 4f);
		}

		private void FlapTick(PhysicsRig rig)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)rig.leftHand).transform.position;
			Vector3 position2 = ((Component)rig.rightHand).transform.position;
			float deltaTime = Time.deltaTime;
			if (_flap && _flapHavePrev && deltaTime > 0f)
			{
				Rigidbody val = (((Object)(object)((Rig)rig).m_pelvis != (Object)null) ? ((Component)((Rig)rig).m_pelvis).GetComponent<Rigidbody>() : null);
				float num = (((Object)(object)val != (Object)null) ? val.velocity.y : 0f);
				if (num < 7f)
				{
					float num2 = FlapStroke(position, _flapPrevL, deltaTime, num, ref _lastFlapL) + FlapStroke(position2, _flapPrevR, deltaTime, num, ref _lastFlapR);
					if (num2 > 0f)
					{
						num2 *= _flapPower;
						Rigidbody[] bodyRbs = GetBodyRbs(rig);
						foreach (Rigidbody val2 in bodyRbs)
						{
							if ((Object)(object)val2 != (Object)null && !val2.isKinematic)
							{
								val2.AddForce(Vector3.up * num2, (ForceMode)2);
							}
						}
					}
				}
			}
			_flapPrevL = position;
			_flapPrevR = position2;
			_flapHavePrev = true;
		}

		private List<CatItem> GetSwords()
		{
			EnsureCatalog();
			List<CatItem> list = _spawnItems.Where((CatItem i) => (i.Title ?? "").IndexOf("sword", StringComparison.OrdinalIgnoreCase) >= 0).ToList();
			if (list.Count == 0)
			{
				list = _spawnItems.Where((CatItem i) => i.Melee).ToList();
			}
			return list;
		}

		private string CurrentSwordName()
		{
			List<CatItem> swords = GetSwords();
			if (swords.Count != 0)
			{
				return Trunc(swords[_swordIdx % swords.Count].Title, 20);
			}
			return "none found";
		}

		private static MethodInfo FindGrip(object controller, out PropertyInfo prop)
		{
			prop = null;
			if (controller == null)
			{
				return null;
			}
			Type type = controller.GetType();
			MethodInfo methodInfo = type.GetMethods(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo x) => x.ReturnType == typeof(float) && x.GetParameters().Length == 0 && x.Name.IndexOf("grip", StringComparison.OrdinalIgnoreCase) >= 0);
			if (methodInfo != null)
			{
				return methodInfo;
			}
			prop = type.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((PropertyInfo x) => x.PropertyType == typeof(float) && x.CanRead && x.GetIndexParameters().Length == 0 && x.Name.IndexOf("grip", StringComparison.OrdinalIgnoreCase) >= 0);
			return null;
		}

		private float FistAmount(bool left)
		{
			if (!_gripSearched)
			{
				_gripSearched = true;
				_gripMethodL = FindGrip(Player.LeftController, out _gripPropL);
				_gripMethodR = FindGrip(Player.RightController, out _gripPropR);
			}
			object obj = (left ? Player.LeftController : Player.RightController);
			MethodInfo methodInfo = (left ? _gripMethodL : _gripMethodR);
			PropertyInfo propertyInfo = (left ? _gripPropL : _gripPropR);
			try
			{
				if (obj != null && methodInfo != null)
				{
					_fistSource = "controller grip";
					return (float)methodInfo.Invoke(obj, null);
				}
				if (obj != null && propertyInfo != null)
				{
					_fistSource = "controller grip";
					return (float)propertyInfo.GetValue(obj);
				}
			}
			catch
			{
			}
			return FingerCurl(left);
		}

		private float FingerCurl(bool left)
		{
			//IL_0070: 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_0089: 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)
			Animator avatarAnimator = GetAvatarAnimator();
			if ((Object)(object)avatarAnimator == (Object)null)
			{
				return -1f;
			}
			Transform boneTransform = avatarAnimator.GetBoneTransform((HumanBodyBones)(left ? 17 : 18));
			if ((Object)(object)boneTransform == (Object)null)
			{
				return -1f;
			}
			HumanBodyBones[] array;
			if (!left)
			{
				array = new HumanBodyBones[4];
				RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			}
			else
			{
				array = new HumanBodyBones[4];
				RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			}
			float num = 0f;
			int num2 = 0;
			HumanBodyBones[] array2 = (HumanBodyBones[])(object)array;
			foreach (HumanBodyBones val in array2)
			{
				Transform boneTransform2 = avatarAnimator.GetBoneTransform(val);
				if (!((Object)(object)boneTransform2 == (Object)null))
				{
					num += Vector3.Distance(boneTransform2.position, boneTransform.position);
					num2++;
				}
			}
			if (num2 == 0)
			{
				return -1f;
			}
			float num3 = num / (float)num2;
			if (left)
			{
				_openDistL = Mathf.Max(_openDistL * 0.9995f, num3);
			}
			else
			{
				_openDistR = Mathf.Max(_openDistR * 0.9995f, num3);
			}
			float num4 = (left ? _openDistL : _openDistR);
			_fistSource = "finger bones";
			return Mathf.Clamp01((1f - num3 / num4) / 0.4f);
		}

		private bool HoldingSomething(Vector3 handPos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(handPos, 0.13f))
			{
				if (!((Object)(object)item.attachedRigidbody == (Object)null) && !((Object)(object)((Component)item).GetComponentInParent<RigManager>() != (Object)null))
				{
					return true;
				}
			}
			return false;
		}

		private void SetSwordInfo(string text)
		{
			_swordInfo = "Sword fist: " + text;
			if ((Object)(object)_infoSword != (Object)null)
			{
				_infoSword.text = _swordInfo;
			}
		}

		private void ShootSword(Transform hand)
		{
			//IL_0040: 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_004b: 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_0054: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//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_0070: 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_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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			Transform head = Player.Head;
			if ((Object)(object)head == (Object)null)
			{
				return;
			}
			List<CatItem> swords = GetSwords();
			if (swords.Count == 0)
			{
				SetSwordInfo("no sword found in your game");
				return;
			}
			CatItem catItem = swords[_swordIdx % swords.Count];
			Vector3 val = hand.position - head.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 val2 = hand.position + normalized * 0.35f;
			Quaternion val3 = Quaternion.LookRotation(normalized);
			HashSet<int> hashSet = new HashSet<int>();
			foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(val2, 1f))
			{
				Rigidbody attachedRigidbody = item.attachedRigidbody;
				if ((Object)(object)attachedRigidbody != (Object)null)
				{
					hashSet.Add(((Object)attachedRigidbody).GetInstanceID());
				}
			}
			string why;
			bool flag = FusionBridge.TrySpawnNetworked(catItem.Barcode, val2, val3, out why);
			if (!flag)
			{
				HelperMethods.SpawnCrate(catItem.Barcode, val2, val3, Vector3.one, false, (Action<GameObject>)null, (Action<GameObject>)null);
			}
			if (_launches.Count < 8)
			{
				_launches.Add(new PendingLaunch
				{
					Pos = val2,
					Vel = normalized * 18f * _flingPower,
					Before = hashSet,
					Due = Time.time + 0.2f,
					Expire = Time.time + 2f
				});
			}
			_lastSword = Time.time;
			SetSwordInfo(Trunc(catItem.Title, 16) + (flag ? " (synced)" : ((why == "offline") ? "" : (" - LOCAL ONLY: " + Trunc(why, 14)))) + " via " + _fistSource);
		}

		private void ProcessLaunches()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			for (int num = _launches.Count - 1; num >= 0; num--)
			{
				PendingLaunch pendingLaunch = _launches[num];
				if (Time.time > pendingLaunch.Expire)
				{
					_launches.RemoveAt(num);
				}
				else if (!(Time.time < pendingLaunch.Due))
				{
					Rigidbody val = null;
					float num2 = float.MaxValue;
					foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(pendingLaunch.Pos, 1f))
					{
						Rigidbody attachedRigidbody = item.attachedRigidbody;
						if (!((Object)(object)attachedRigidbody == (Object)null) && !attachedRigidbody.isKinematic && !pendingLaunch.Before.Contains(((Object)attachedRigidbody).GetInstanceID()) && !((Object)(object)((Component)item).GetComponentInParent<RigManager>() != (Object)null))
						{
							Vector3 val2 = attachedRigidbody.worldCenterOfMass - pendingLaunch.Pos;
							float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
							if (sqrMagnitude < num2)
							{
								num2 = sqrMagnitude;
								val = attachedRigidbody;
							}
						}
					}
					if (!((Object)(object)val == (Object)null))
					{
						val.velocity = pendingLaunch.Vel;
						_launches.RemoveAt(num);
					}
				}
			}
		}

		private void SwordTick(PhysicsRig rig)
		{
			ProcessLaunches();
			if (!_swordFist)
			{
				_fistL = false;
				_fistR = false;
			}
			else
			{
				SwordHand(left: true, ((Component)rig.leftHand).transform);
				SwordHand(left: false, ((Component)rig.rightHand).transform);
			}
		}

		private void SwordHand(bool left, Transform hand)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			float num = FistAmount(left);
			if (num < 0f)
			{
				SetSwordInfo("cannot read your hand (no grip or finger data)");
				return;
			}
			bool flag = num >= 0.8f;
			bool flag2 = (left ? _fistL : _fistR);
			if (left)
			{
				_fistL = flag;
			}
			else
			{
				_fistR = flag;
			}
			if (flag && (!flag2 || !(Time.time - _lastSword < 0.6f)) && !(Time.time - _lastSword < 0.25f) && !HoldingSomething(hand.position))
			{
				ShootSword(hand);
			}
		}

		private static bool InFusionLobby()
		{
			if (!FusionBridge.IsLoaded)
			{
				return false;
			}
			return FusionBridge.InLobby() != "no";
		}

		private void StartSpawnJob(CatItem item)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00cf: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			Transform head = Player.Head;
			if ((Object)(object)head == (Object)null)
			{
				return;
			}
			int amount = Amount;
			if (amount == 1)
			{
				SpawnCrateAt(item.Barcode, item.Title);
				return;
			}
			bool flag = InFusionLobby();
			int num = (flag ? Math.Min(amount, 25) : Math.Min(amount, MaxOfflineSpawn));
			Vector3 forward = head.forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.01f)
			{
				forward = Vector3.forward;
			}
			((Vector3)(ref forward)).Normalize();
			_job = new SpawnJob
			{
				Item = item,
				Total = num,
				Online = flag,
				Capped = (num < amount),
				Next = 0f,
				Origin = head.position + forward * 1.5f + Vector3.down * 0.3f,
				Right = Vector3.Cross(Vector3.up, forward),
				Forward = forward
			};
			Say("Spawning " + num + (_job.Capped ? " (limit)" : "") + ": " + Trunc(item.Title, 14));
		}

		private void StopSpawnJob()
		{
			_job = null;
			Say("Stopped spawning");
		}

		private void SpawnJobTick()
		{
			//IL_005d: 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)
			//IL_0069: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0099: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			SpawnJob job = _job;
			if (job == null || Time.time < job.Next)
			{
				return;
			}
			int num = (job.Online ? 1 : 8);
			for (int i = 0; i < num; i++)
			{
				if (job.Done >= job.Total)
				{
					break;
				}
				int num2 = job.Done++;
				float num3 = (float)(num2 % 10) - 4.5f;
				float num4 = num2 / 10 % 10;
				float num5 = num2 / 100;
				Vector3 val = job.Origin + job.Right * num3 * 0.3f + Vector3.up * num4 * 0.3f + job.Forward * num5 * 0.3f;
				try
				{
					if (!job.Online || !FusionBridge.TrySpawnNetworked(job.Item.Barcode, val, Quaternion.identity, out var _))
					{
						HelperMethods.SpawnCrate(job.Item.Barcode, val, Quaternion.identity, Vector3.one, false, (Action<GameObject>)null, (Action<GameObject>)null);
					}
				}
				catch (Exception ex)
				{
					MelonLogger.Warning("Bulk spawn failed: " + ex.Message);
					_job = null;
					Say("Spawning stopped (error)");
					return;
				}
			}
			job.Next = Time.time + (job.Online ? 0.15f : 0.05f);
			if (job.Done >= job.Total)
			{
				Say("Spawned " + job.Total + (job.Capped ? " (limit)" : "") + ": " + Trunc(job.Item.Title, 14));
				_job = null;
			}
			else
			{
				Say("Spawning " + job.Done + "/" + job.Total);
			}
		}

		private List<CatItem> GetBlades()
		{
			EnsureCatalog();
			string[] words = new string[8] { "dagger", "knife", "sword", "blade", "katana", "machete", "saber", "sabre" };
			List<CatItem> list = _spawnItems.Where((CatItem i) => words.Any((string w) => (i.Title ?? "").IndexOf(w, StringComparison.OrdinalIgnoreCase) >= 0)).ToList();
			if (list.Count == 0)
			{
				list = _spawnItems.Where((CatItem i) => i.Melee).ToList();
			}
			return list;
		}

		private string CurrentBladeName()
		{
			List<CatItem> blades = GetBlades();
			if (blades.Count != 0)
			{
				return Trunc(blades[_bladeIdx % blades.Count].Title, 20);
			}
			return "none found";
		}

		private string ClawHandName()
		{
			if (_clawHands != 0)
			{
				if (_clawHands != 1)
				{
					return "right";
				}
				return "left";
			}
			return "both";
		}

		private void SetClawInfo(string text)
		{
			_clawInfo = "Claws: " + text;
			if ((Object)(object)_infoClaw != (Object)null)
			{
				_infoClaw.text = _clawInfo;
			}
		}

		private Vector3 ForearmDir(bool left, Transform hand, out Vector3 handPos)
		{
			//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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			handPos = hand.position;
			Animator avatarAnimator = GetAvatarAnimator();
			if ((Object)(object)avatarAnimator != (Object)null)
			{
				Transform boneTransform = avatarAnimator.GetBoneTransform((HumanBodyBones)(left ? 17 : 18));
				Transform boneTransform2 = avatarAnimator.GetBoneTransform((HumanBodyBones)(left ? 15 : 16));
				if ((Object)(object)boneTransform != (Object)null && (Object)(object)boneTransform2 != (Object)null)
				{
					Vector3 val = boneTransform.position - boneTransform2.position;
					if (((Vector3)(ref val)).sqrMagnitude > 1E-06f)
					{
						handPos = boneTransform.position;
						val = boneTransform.position - boneTransform2.position;
						return ((Vector3)(ref val)).normalized;
					}
				}
			}
			Vector3 val2 = (((Object)(object)hand.parent != (Object)null) ? (hand.position - hand.parent.position) : hand.forward);
			if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f)
			{
				val2 = hand.forward;
			}
			return ((Vector3)(ref val2)).normalized;
		}

		private static bool BladeShape(GameObject go, out Vector3 axisLocal, out Vector3 hiltLocal)
		{
			//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_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_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_0025: 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_005e: 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)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_00f6: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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)
			axisLocal = Vector3.up;
			hiltLocal = Vector3.zero;
			Transform transform = go.transform;
			bool flag = false;
			Vector3 val = Vector3.zero;
			Vector3 val2 = Vector3.zero;
			foreach (MeshFilter componentsInChild in go.GetComponentsInChildren<MeshFilter>())
			{
				Mesh sharedMesh = componentsInChild.sharedMesh;
				if ((Object)(object)sharedMesh == (Object)null)
				{
					continue;
				}
				Bounds bounds = sharedMesh.bounds;
				for (int i = 0; i < 8; i++)
				{
					Vector3 val3 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3(((i & 1) == 0) ? (-1f) : 1f, ((i & 2) == 0) ? (-1f) : 1f, ((i & 4) == 0) ? (-1f) : 1f));
					Vector3 val4 = transform.InverseTransformPoint(((Component)componentsInChild).transform.TransformPoint(val3));
					if (!flag)
					{
						val = val4;
						val2 = val4;
						flag = true;
					}
					else
					{
						val = Vector3.Min(val, val4);
						val2 = Vector3.Max(val2, val4);
					}
				}
			}
			if (!flag)
			{
				return false;
			}
			Vector3 val5 = val2 - val;
			int num = ((!(val5.x >= val5.y) || !(val5.x >= val5.z)) ? ((val5.y >= val5.z) ? 1 : 2) : 0);
			Vector3 val6 = (val + val2) * 0.5f;
			float num2 = ((Mathf.Abs(((Vector3)(ref val6))[num]) > 0.05f * ((Vector3)(ref val5))[num]) ? Mathf.Sign(((Vector3)(ref val6))[num]) : 1f);
			axisLocal = Vector3.zero;
			((Vector3)(ref axisLocal))[num] = num2;
			Vector3 val7 = val6;
			((Vector3)(ref val7))[num] = ((num2 > 0f) ? ((Vector3)(ref val))[num] : ((Vector3)(ref val2))[num]);
			hiltLocal = val7;
			return true;
		}

		private bool DespawnObject(GameObject go)
		{
			try
			{
				if (_pooleeType == null)
				{
					_pooleeType = (from a in AppDomain.CurrentDomain.GetAssemblies()
						where a.GetName().Name.StartsWith("Il2CppSLZ")
						select a).SelectMany(delegate(Assembly a)
					{
						try
						{
							return a.GetTypes();
						}
						catch
						{
							return new Type[0];
						}
					}).FirstOrDefault((Type t) => t.Name == "Poolee");
				}
				if (_pooleeType != null)
				{
					Component componentInParent = go.GetComponentInParent(Il2CppType.From(_pooleeType));
					MethodInfo methodInfo = _pooleeType.GetMethods(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo x) => x.Name == "Despawn" && x.GetParameters().Length == 0);
					if ((Object)(object)componentInParent != (Object)null && methodInfo != null)
					{
						object obj = typeof(Il2CppObjectBase).GetMethod("TryCast").MakeGenericMethod(_pooleeType).Invoke(componentInParent, null);
						if (obj != null)
						{
							methodInfo.Invoke(obj, null);
							return true;
						}
					}
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("Despawn failed: " + (ex.InnerException ?? ex).Message);
			}
			Object.Destroy((Object)(object)go);
			return false;
		}

		private void ExtendClaw(Claw c, Transform hand)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00fc: 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_00e1: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			List<CatItem> blades = GetBlades();
			if (blades.Count == 0)
			{
				SetClawInfo("no blade found in your game");
				c.Fist = false;
				return;
			}
			CatItem catItem = blades[_bladeIdx % blades.Count];
			Vector3 handPos;
			Vector3 val = ForearmDir(c.Left, hand, out handPos);
			Vector3 val2 = handPos + val * 0.1f;
			c.Before = new HashSet<int>();
			foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(val2, 1f))
			{
				Rigidbody attachedRigidbody = item.attachedRigidbody;
				if ((Object)(object)attachedRigidbody != (Object)null)
				{
					c.Before.Add(((Object)attachedRigidbody).GetInstanceID());
				}
			}
			string why;
			bool flag = FusionBridge.TrySpawnNetworked(catItem.Barcode, val2, Quaternion.FromToRotation(Vector3.up, val), out why);
			if (!flag)
			{
				HelperMethods.SpawnCrate(catItem.Barcode, val2, Quaternion.FromToRotation(Vector3.up, val), Vector3.one, false, (Action<GameObject>)null, (Action<GameObject>)null);
			}
			c.SpawnPos = val2;
			c.Pending = true;
			c.Due = Time.time + 0.15f;
			c.Expire = Time.time + 2.5f;
			SetClawInfo(Trunc(catItem.Title, 16) + (flag ? " (synced)" : ((why == "offline") ? "" : (" - LOCAL ONLY: " + Trunc(why, 14)))));
		}

		private void TryAttachClaw(Claw c)
		{
			//IL_0037: 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_013d: 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_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time > c.Expire)
			{
				c.Pending = false;
				SetClawInfo("blade did not appear");
			}
			else
			{
				if (Time.time < c.Due)
				{
					return;
				}
				Rigidbody val = null;
				float num = float.MaxValue;
				foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(c.SpawnPos, 1f))
				{
					Rigidbody attachedRigidbody = item.attachedRigidbody;
					if (!((Object)(object)attachedRigidbody == (Object)null) && !attachedRigidbody.isKinematic && !c.Before.Contains(((Object)attachedRigidbody).GetInstanceID()) && !((Object)(object)((Component)item).GetComponentInParent<RigManager>() != (Object)null))
					{
						Vector3 val2 = attachedRigidbody.worldCenterOfMass - c.SpawnPos;
						float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
						if (sqrMagnitude < num)
						{
							num = sqrMagnitude;
							val = attachedRigidbody;
						}
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				c.Body = val;
				c.Go = ((Component)val).gameObject;
				c.Pending = false;
				val.useGravity = false;
				if (!BladeShape(c.Go, out c.AxisLocal, out c.HiltLocal))
				{
					c.AxisLocal = Vector3.up;
					c.HiltLocal = Vector3.zero;
				}
				c.HiltLocal = Vector3.Scale(c.HiltLocal, c.Go.transform.lossyScale);
				PhysicsRig physicsRig = Player.PhysicsRig;
				if (!((Object)(object)physicsRig != (Object)null))
				{
					return;
				}
				foreach (Collider componentsInChild in c.Go.GetComponentsInChildren<Collider>())
				{
					foreach (Collider componentsInChild2 in ((Component)physicsRig).GetComponentsInChildren<Collider>())
					{
						Physics.IgnoreCollision(componentsInChild, componentsInChild2, true);
					}
				}
			}
		}

		private void RetractClaw(Claw c)
		{
			bool num = (Object)(object)c.Go != (Object)null || c.Pending;
			c.Pending = false;
			if ((Object)(object)c.Go != (Object)null)
			{
				DespawnObject(c.Go);
			}
			c.Go = null;
			c.Body = null;
			c.Fist = false;
			if (num)
			{
				SetClawInfo("retracted");
			}
		}

		private void ClawHand(Claw c, Transform hand, bool allowed)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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)
			if (!allowed)
			{
				if ((Object)(object)c.Go != (Object)null || c.Pending || c.Fist)
				{
					RetractClaw(c);
				}
				return;
			}
			float num = FistAmount(c.Left);
			if (num < 0f)
			{
				SetClawInfo("cannot read your hand (no grip or finger data)");
				return;
			}
			bool flag = (c.Fist ? (num >= 0.6f) : (num >= 0.9f));
			if (flag != c.Fist && Time.time - c.LastChange > 0.4f)
			{
				if (flag)
				{
					if (!HoldingSomething(hand.position))
					{
						c.Fist = true;
						c.LastChange = Time.time;
						ExtendClaw(c, hand);
					}
				}
				else
				{
					c.LastChange = Time.time;
					RetractClaw(c);
				}
			}
			if (c.Pending)
			{
				TryAttachClaw(c);
			}
			if (c.Fist && !c.Pending && (Object)(object)c.Body == (Object)null && Time.time - c.LastChange > 1f)
			{
				c.Fist = false;
			}
			if ((Object)(object)c.Body != (Object)null)
			{
				Vector3 handPos;
				Vector3 val = ForearmDir(c.Left, hand, out handPos);
				Quaternion val2 = (c.TargetRot = Quaternion.FromToRotation(c.AxisLocal, val));
				c.TargetPos = handPos + val * 0.03f - val2 * c.HiltLocal;
			}
		}

		private void ClawTick(PhysicsRig rig)
		{
			ClawHand(_clawL, ((Component)rig.leftHand).transform, _claws && _clawHands != 2);
			ClawHand(_clawR, ((Component)rig.rightHand).transform, _claws && _clawHands != 1);
		}

		private void DriveClaw(Claw c)
		{
			//IL_0019: 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_002a: 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_003f: 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_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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			Rigidbody body = c.Body;
			if (!((Object)(object)body == (Object)null))
			{
				float fixedDeltaTime = Time.fixedDeltaTime;
				body.velocity = Vector3.ClampMagnitude((c.TargetPos - body.position) / fixedDeltaTime, 60f);
				Quaternion val = c.TargetRot * Quaternion.Inverse(body.rotation);
				float num = default(float);
				Vector3 val2 = default(Vector3);
				((Quaternion)(ref val)).ToAngleAxis(ref num, ref val2);
				if (num > 180f)
				{
					num -= 360f;
				}
				if (((Vector3)(ref val2)).sqrMagnitude > 1E-06f && !float.IsNaN(val2.x))
				{
					body.angularVelocity = Vector3.ClampMagnitude(val2 * (num * ((float)Math.PI / 180f) / fixedDeltaTime), 60f);
				}
			}
		}

		private static bool Has(string name, string word)
		{
			return (name ?? "").IndexOf(word, StringComparison.OrdinalIgnoreCase) >= 0;
		}

		private static void FindTrigger(object controller, out MethodInfo floatM, out PropertyInfo floatP, out MethodInfo boolM)
		{
			floatM = null;
			floatP = null;
			boolM = null;
			if (controller == null)
			{
				return;
			}
			Type type = controller.GetType();
			List<MethodInfo> source = (from x in type.GetMethods(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
				where x.GetParameters().Length == 0
				select x).ToList();
			floatM = source.FirstOrDefault((MethodInfo x) => x.ReturnType == typeof(float) && Has(x.Name, "trigger") && !Has(x.Name, "grip"));
			if (floatM != null)
			{
				return;
			}
			floatP = type.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((PropertyInfo x) => x.PropertyType == typeof(float) && x.CanRead && x.GetIndexParameters().Length == 0 && Has(x.Name, "trigger") && !Has(x.Name, "grip"));
			if (!(floatP != null))
			{
				boolM = source.FirstOrDefault((MethodInfo x) => x.ReturnType == typeof(bool) && (Has(x.Name, "trigger") || Has(x.Name, "primaryinteraction")));
			}
		}

		private float TriggerAmount(bool left)
		{
			if (!_trigSearched)
			{
				_trigSearched = true;
				FindTrigger(Player.LeftController, out _trigFloatL, out _trigPropL, out _trigBoolL);
				FindTrigger(Player.RightController, out _trigFloatR, out _trigPropR, out _trigBoolR);
			}
			object obj = (left ? Player.LeftController : Player.RightController);
			MethodInfo methodInfo = (left ? _trigFloatL : _trigFloatR);
			PropertyInfo propertyInfo = (left ? _trigPropL : _trigPropR);
			MethodInfo methodInfo2 = (left ? _trigBoolL : _trigBoolR);
			try
			{
				if (obj != null && methodInfo != null)
				{
					_trigSource = methodInfo.Name;
					return (float)methodInfo.Invoke(obj, null);
				}
				if (obj != null && propertyInfo != null)
				{
					_trigSource = propertyInfo.Name;
					return (float)propertyInfo.GetValue(obj);
				}
				if (obj != null && methodInfo2 != null)
				{
					_trigSource = methodInfo2.Name;
					return ((bool)methodInfo2.Invoke(obj, null)) ? 1f : 0f;
				}
			}
			catch
			{
			}
			return -1f;
		}

		private static int VoidScore(CatItem i)
		{
			string name = i.Title + " " + i.Barcode;
			if (!Has(name, "projectile") && !Has(name, "energy") && ((!Has(name, "void") && !Has(name, "null")) || (!Has(name, "ball") && !Has(name, "orb"))))
			{
				return 0;
			}
			int num = 1;
			if (Has(name, "projectile"))
			{
				num += 3;
			}
			if (Has(name, "void"))
			{
				num += 3;
			}
			if (Has(name, "energy"))
			{
				num += 2;
			}
			if (Has(name, "null"))
			{
				num += 2;
			}
			if (Has(name, "corrupt"))
			{
				num += 2;
			}
			return num;
		}

		private List<CatItem> GetVoidCandidates()
		{
			EnsureCatalog();
			if (_voidCandidates != null)
			{
				return _voidCandidates;
			}
			_voidCandidates = (from k in (from i in _spawnItems.Concat(_hiddenItems)
					select new KeyValuePair<int, CatItem>(VoidScore(i), i) into k
					where k.Key > 0
					orderby k.Key descending, k.Value.Title ?? ""
					select k).Take(25)
				select k.Value).ToList();
			foreach (CatItem voidCandidate in _voidCandidates)
			{
				MelonLogger.Msg("Void projectile candidate: " + voidCandidate.Title + "  [" + voidCandidate.Barcode + "]");
			}
			if (_voidCandidates.Count == 0)
			{
				MelonLogger.Warning("No Void Energy projectile candidates found in the game's spawnables.");
			}
			return _voidCandidates;
		}

		private string CurrentVoidName()
		{
			List<CatItem> voidCandidates = GetVoidCandidates();
			if (voidCandidates.Count != 0)
			{
				return Trunc(voidCandidates[_voidIdx % voidCandidates.Count].Title, 20);
			}
			return "none found";
		}

		private void SetVoidInfo(string text)
		{
			_voidInfo = "Void: " + text;
			if ((Object)(object)_infoVoid != (Object)null)
			{
				_infoVoid.text = _voidInfo;
			}
		}

		private static int BodyId(Collider col)
		{
			Rigidbody attachedRigidbody = col.attachedRigidbody;
			if (!((Object)(object)attachedRigidbody != (Object)null))
			{
				return ((Object)((Component)col).transform.root).GetInstanceID();
			}
			return ((Object)attachedRigidbody).GetInstanceID();
		}

		private void FireVoid(bool left, Transform hand)
		{
			//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_003a: 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_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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			List<CatItem> voidCandidates = GetVoidCandidates();
			if (voidCandidates.Count == 0)
			{
				SetVoidInfo("projectile not found in your game (see Latest.log)");
				return;
			}
			CatItem catItem = voidCandidates[_voidIdx % voidCandidates.Count];
			Vector3 handPos;
			Vector3 val = ForearmDir(left, hand, out handPos);
			Vector3 val2 = handPos + val * 0.3f;
			Quaternion val3 = Quaternion.LookRotation(val);
			HashSet<int> hashSet = new HashSet<int>();
			foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(val2, 1.2f))
			{
				hashSet.Add(BodyId(item));
			}
			string why;
			bool flag = FusionBridge.TrySpawnNetworked(catItem.Barcode, val2, val3, out why);
			if (!flag)
			{
				HelperMethods.SpawnCrate(catItem.Barcode, val2, val3, Vector3.one, false, (Action<GameObject>)null, (Action<GameObject>)null);
			}
			if (_voidPending.Count < 8)
			{
				_voidPending.Add(new VoidPending
				{
					Pos = val2,
					Vel = val * 22f * _flingPower,
					Before = hashSet,
					Due = Time.time + 0.15f,
					Expire = Time.time + 2.5f
				});
			}
			_lastVoid = Time.time;
			SetVoidInfo(Trunc(catItem.Title, 18) + (flag ? " (synced)" : ((why == "offline") ? "" : (" - LOCAL ONLY: " + Trunc(why, 14)))));
		}

		private void ProcessVoid()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			for (int num = _voidPending.Count - 1; num >= 0; num--)
			{
				VoidPending voidPending = _voidPending[num];
				if (Time.time > voidPending.Expire)
				{
					_voidPending.RemoveAt(num);
				}
				else if (!(Time.time < voidPending.Due))
				{
					Transform val = null;
					Rigidbody val2 = null;
					float num2 = float.MaxValue;
					foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(voidPending.Pos, 1.2f))
					{
						if (!voidPending.Before.Contains(BodyId(item)) && !((Object)(object)((Component)item).GetComponentInParent<RigManager>() != (Object)null))
						{
							Rigidbody attachedRigidbody = item.attachedRigidbody;
							Transform val3 = (((Object)(object)attachedRigidbody != (Object)null) ? ((Component)attachedRigidbody).transform : ((Component)item).transform.root);
							Vector3 val4 = val3.position - voidPending.Pos;
							float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude;
							if (sqrMagnitude < num2)
							{
								num2 = sqrMagnitude;
								val = val3;
								val2 = attachedRigidbody;
							}
						}
					}
					if (!((Object)(object)val == (Object)null))
					{
						_voidPending.RemoveAt(num);
						_voidFlying.Add(new VoidFlying
						{
							T = val,
							Rb = val2,
							Vel = voidPending.Vel,
							Until = Time.time + 4f
						});
						if ((Object)(object)val2 != (Object)null && !val2.isKinematic)
						{
							val2.useGravity = false;
							val2.velocity = voidPending.Vel;
						}
					}
				}
			}
			float deltaTime = Time.deltaTime;
			for (int num3 = _voidFlying.Count - 1; num3 >= 0; num3--)
			{
				VoidFlying voidFlying = _voidFlying[num3];
				if ((Object)(object)voidFlying.T == (Object)null || Time.time > voidFlying.Until)
				{
					_voidFlying.RemoveAt(num3);
				}
				else if ((Object)(object)voidFlying.Rb == (Object)null || voidFlying.Rb.isKinematic)
				{
					voidFlying.T.position = voidFlying.T.position + voidFlying.Vel * deltaTime;
				}
			}
		}

		private void VoidHand(bool left, Transform hand)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			float num = TriggerAmount(left);
			if (num < 0f)
			{
				SetVoidInfo("cannot read your trigger");
				return;
			}
			bool flag = num >= 0.8f;
			bool flag2 = (left ? _voidTrigL : _voidTrigR);
			if (left)
			{
				_voidTrigL = flag;
			}
			else
			{
				_voidTrigR = flag;
			}
			if (flag && (!flag2 || !(Time.time - _lastVoid < 0.5f)) && !(Time.time - _lastVoid < 0.25f) && !HoldingSomething(hand.position))
			{
				FireVoid(left, hand);
			}
		}

		private void VoidTick(PhysicsRig rig)
		{
			ProcessVoid();
			if (!_void)
			{
				_voidTrigL = false;
				_voidTrigR = false;
			}
			else
			{
				VoidHand(left: true, ((Component)rig.leftHand).transform);
				VoidHand(left: false, ((Component)rig.rightHand).transform);
			}
		}

		private int ReadBButton()
		{
			if (!_peeSearched)
			{
				_peeSearched = true;
				Type type = (((Object)(object)Player.RightController != (Object)null) ? ((object)Player.RightController).GetType() : null);
				string[] words = new string[3] { "bbutton", "secondaryinteraction", "secondary" };
				if (type != null)
				{
					_peeBtnMethod = type.GetMethods(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo x) => x.ReturnType == typeof(bool) && x.GetParameters().Length == 0 && words.Any((string w) => Has(x.Name, w)));
					if (_peeBtnMethod == null)
					{
						_peeBtnProp = type.GetProperties(BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((PropertyInfo x) => x.PropertyType == typeof(bool) && x.CanRead && x.GetIndexParameters().Length == 0 && words.Any((string w) => Has(x.Name, w)));
					}
				}
				MelonLogger.Msg("B button read through: " + ((_peeBtnMethod != null) ? _peeBtnMethod.Name : ((_peeBtnProp != null) ? _peeBtnProp.Name : "nothing found")));
			}
			object rightController = Player.RightController;
			try
			{
				if (rightController != null && _peeBtnMethod != null)
				{
					return ((bool)_peeBtnMethod.Invoke(rightController, null)) ? 1 : 0;
				}
				if (rightController != null && _peeBtnProp != null)
				{
					return ((bool)_peeBtnProp.GetValue(rightController)) ? 1 : 0;
				}
			}
			catch
			{
			}
			return -1;
		}

		private Drop GetDrop()
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			for (int num = _drops.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)_drops[num].Go == (Object)null)
				{
					_drops.RemoveAt(num);
				}
			}
			foreach (Drop drop2 in _drops)
			{
				if (!drop2.Alive)
				{
					return drop2;
				}
			}
			if (_drops.Count >= 120)
			{
				return null;
			}
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			Collider component = val.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			val.transform.localScale = new Vector3(0.025f, 0.04f, 0.025f);
			try
			{
				Renderer component2 = val.GetComponent<Renderer>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.material.color = new Color(0.95f, 0.85f, 0.2f, 1f);
				}
			}
			catch
			{
			}
			val.SetActive(false);
			Drop drop = new Drop
			{
				Go = val
			};
			_drops.Add(drop);
			return drop;
		}

		private void EmitDrop(Vector3 pos, Vector3 vel)
		{
			//IL_0016: 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_001e: 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_002d: 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)
			Drop drop = GetDrop();
			if (drop != null)
			{
				drop.Go.transform.position = pos;
				drop.Vel = vel + Random.insideUnitSphere * 0.15f;
				drop.Born = Time.time;
				drop.Alive = true;
				drop.Go.SetActive(true);
			}
		}

		private void UpdateDrops()
		{
			//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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_0098: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = Time.deltaTime;
			RaycastHit val2 = default(RaycastHit);
			foreach (Drop drop in _drops)
			{
				if (!drop.Alive)
				{
					continue;
				}
				if ((Object)(object)drop.Go == (Object)null || Time.time - drop.Born > 1.5f)
				{
					if ((Object)(object)drop.Go != (Object)null)
					{
						drop.Go.SetActive(false);
					}
					drop.Alive = false;
					continue;
				}
				drop.Vel += Vector3.down * 9.8f * deltaTime;
				Vector3 val = drop.Vel * deltaTime;
				Vector3 position = drop.Go.transform.position;
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (magnitude > 1E-05f && Physics.Raycast(position, val / magnitude, ref val2, magnitude))
				{
					drop.Go.SetActive(false);
					drop.Alive = false;
				}
				else
				{
					drop.Go.transform.position = position + val;
				}
			}
		}

		private void EmitRemotePee()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (_peeSources.Count == 0)
			{
				return;
			}
			List<string> list = null;
			foreach (KeyValuePair<string, PeeSource> peeSource in _peeSources)
			{
				PeeSource value = peeSource.Value;
				if (Time.time > value.Until)
				{
					if (list == null)
					{
						list = new List<string>();
					}
					list.Add(peeSource.Key);
					continue;
				}
				int num = 0;
				while (Time.time >= value.NextEmit && num++ < 3)
				{
					EmitDrop(value.Pos, value.Vel);
					value.NextEmit += 0.025f;
				}
				if (value.NextEmit < Time.time - 0.2f)
				{
					value.NextEmit = Time.time;
				}
			}
			if (list == null)
			{
				return;
			}
			foreach (string item in list)
			{
				_peeSources.Remove(item);
			}
		}

		private void P