Decompiled source of AtlyssPlayerCollision v1.0.3

AtlyssPlayerCollision.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AtlyssCommandLib.API;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CodeTalker;
using CodeTalker.Networking;
using CodeTalker.Packets;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using Nessie.ATLYSS.EasySettings;
using Nessie.ATLYSS.EasySettings.UIElements;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AtlyssPlayerCollision")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AtlyssPlayerCollision")]
[assembly: AssemblyTitle("AtlyssPlayerCollision")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 AtlyssPlayerCollision
{
	internal sealed class CollisionBody
	{
		private readonly GameObject _bodyObject;

		private readonly Rigidbody _rigidbody;

		private readonly BoxCollider _debugBox;

		private readonly BoxCollider _solidBody;

		private readonly BoxCollider _standingPlatform;

		private readonly LineRenderer _bodyWireframe;

		private readonly LineRenderer _platformWireframe;

		private readonly CollisionConfig _config;

		private bool _hasAppliedShape;

		private Vector3 _lastLocalScale;

		private Vector3 _lastBodyCenter;

		private Vector3 _lastBodySize;

		private Vector3 _lastPlatformCenter;

		private Vector3 _lastPlatformSize;

		private bool _lastBodySolidEnabled;

		private bool _lastPlatformEnabled;

		private bool _lastBodyWireVisible;

		private bool _lastPlatformWireVisible;

		private static Material? _sharedLineMaterial;

		internal bool IsAlive => (Object)(object)_bodyObject != (Object)null;

		internal bool IsObjectActive => (Object)(object)_bodyObject != (Object)null && _bodyObject.activeInHierarchy;

		internal bool IsSolidBodyActive => (Object)(object)_solidBody != (Object)null && ((Collider)_solidBody).enabled && IsObjectActive;

		internal bool IsPlatformActive => (Object)(object)_standingPlatform != (Object)null && ((Collider)_standingPlatform).enabled && IsObjectActive;

		internal bool IsAnyWireVisible => (((Object)(object)_bodyWireframe != (Object)null && ((Renderer)_bodyWireframe).enabled) || ((Object)(object)_platformWireframe != (Object)null && ((Renderer)_platformWireframe).enabled)) && IsObjectActive;

		internal CollisionBody(CollisionPlayerState state, CollisionConfig config)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0177: Unknown result type (might be due to invalid IL or missing references)
			_config = config;
			_bodyObject = new GameObject("PlayerCollisionBody");
			_bodyObject.transform.SetParent(state.Root, false);
			_bodyObject.transform.localPosition = Vector3.zero;
			_bodyObject.transform.localRotation = Quaternion.identity;
			_bodyObject.transform.localScale = Vector3.one;
			_rigidbody = _bodyObject.AddComponent<Rigidbody>();
			_rigidbody.isKinematic = true;
			_rigidbody.useGravity = false;
			_rigidbody.detectCollisions = true;
			_debugBox = _bodyObject.AddComponent<BoxCollider>();
			((Collider)_debugBox).isTrigger = true;
			((Collider)_debugBox).enabled = false;
			_solidBody = _bodyObject.AddComponent<BoxCollider>();
			((Collider)_solidBody).isTrigger = false;
			((Collider)_solidBody).enabled = false;
			_standingPlatform = _bodyObject.AddComponent<BoxCollider>();
			((Collider)_standingPlatform).isTrigger = false;
			((Collider)_standingPlatform).enabled = false;
			_bodyWireframe = CreateWireframe("BodyWire", new Color(0.3f, 1f, 0.3f, 0.95f));
			_platformWireframe = CreateWireframe("PlatformWire", new Color(1f, 0.85f, 0.2f, 0.95f));
		}

		private LineRenderer CreateWireframe(string name, Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(_bodyObject.transform, false);
			val.transform.localPosition = Vector3.zero;
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one;
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			val2.useWorldSpace = false;
			val2.positionCount = 16;
			val2.startWidth = 0.03f;
			val2.endWidth = 0.03f;
			val2.numCapVertices = 0;
			val2.numCornerVertices = 0;
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val2).receiveShadows = false;
			val2.alignment = (LineAlignment)0;
			((Renderer)val2).sharedMaterial = GetLineMaterial();
			val2.startColor = color;
			val2.endColor = color;
			((Renderer)val2).enabled = false;
			return val2;
		}

		private static Material GetLineMaterial()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			if ((Object)(object)_sharedLineMaterial != (Object)null)
			{
				return _sharedLineMaterial;
			}
			Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Standard");
			_sharedLineMaterial = new Material(val);
			return _sharedLineMaterial;
		}

		internal bool UpdateShape(float width, float depth, float height, float centerY, float headWidth, float headDepth, float headThickness, float headCenterY, Vector3 platformLocalCenter, bool bodySolidEnabled, bool platformEnabled, bool debugVisible, bool chestBoxMode)
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_0129: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_bodyObject == (Object)null || (Object)(object)_debugBox == (Object)null || (Object)(object)_solidBody == (Object)null || (Object)(object)_standingPlatform == (Object)null)
			{
				return false;
			}
			if (!_bodyObject.activeSelf)
			{
				_bodyObject.SetActive(true);
			}
			Transform parent = _bodyObject.transform.parent;
			Vector3 one = default(Vector3);
			if ((Object)(object)parent != (Object)null)
			{
				Vector3 lossyScale = parent.lossyScale;
				((Vector3)(ref one))..ctor((Mathf.Abs(lossyScale.x) > 0.0001f) ? (1f / lossyScale.x) : 1f, (Mathf.Abs(lossyScale.y) > 0.0001f) ? (1f / lossyScale.y) : 1f, (Mathf.Abs(lossyScale.z) > 0.0001f) ? (1f / lossyScale.z) : 1f);
			}
			else
			{
				one = Vector3.one;
			}
			if (!_hasAppliedShape || !Approximately(_lastLocalScale, one))
			{
				_bodyObject.transform.localScale = one;
				_lastLocalScale = one;
			}
			if (_bodyObject.transform.localPosition != Vector3.zero)
			{
				_bodyObject.transform.localPosition = Vector3.zero;
			}
			if (_bodyObject.transform.localRotation != Quaternion.identity)
			{
				_bodyObject.transform.localRotation = Quaternion.identity;
			}
			float num = Mathf.Max(0.01f, width);
			float num2 = Mathf.Max(0.01f, depth);
			float num3 = Mathf.Max(0.01f, height);
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0f, centerY, 0f);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(num, num3, num2);
			float num4 = Mathf.Clamp(headThickness, 0.02f, 0.75f);
			Vector3 val3 = platformLocalCenter;
			val3.y = headCenterY;
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(Mathf.Max(0.01f, headWidth), num4, Mathf.Max(0.01f, headDepth));
			bool flag = bodySolidEnabled && !chestBoxMode && _config.SolidRemoteBodyEnabled.Value;
			bool flag2 = platformEnabled && (chestBoxMode || _config.StandingPlatformEnabled.Value);
			bool flag3 = debugVisible && flag;
			bool flag4 = debugVisible && flag2;
			bool flag5 = !_hasAppliedShape || !Approximately(_lastBodyCenter, val) || !Approximately(_lastBodySize, val2) || _lastBodySolidEnabled != flag;
			bool flag6 = !_hasAppliedShape || !Approximately(_lastPlatformCenter, val3) || !Approximately(_lastPlatformSize, val4) || _lastPlatformEnabled != flag2;
			bool flag7 = flag5 || _lastBodyWireVisible != flag3 || ((Object)(object)_bodyWireframe != (Object)null && ((Renderer)_bodyWireframe).enabled != flag3);
			bool flag8 = flag6 || _lastPlatformWireVisible != flag4 || ((Object)(object)_platformWireframe != (Object)null && ((Renderer)_platformWireframe).enabled != flag4);
			bool flag9 = !_rigidbody.isKinematic || _rigidbody.useGravity || !_rigidbody.detectCollisions;
			if (!flag5 && !flag6 && !flag7 && !flag8 && !flag9)
			{
				return true;
			}
			if (flag5)
			{
				_debugBox.center = val;
				_debugBox.size = val2;
				((Collider)_debugBox).enabled = false;
				_solidBody.center = val;
				_solidBody.size = val2;
				((Collider)_solidBody).enabled = flag;
			}
			else if (((Collider)_solidBody).enabled != flag)
			{
				((Collider)_solidBody).enabled = flag;
			}
			if (flag6)
			{
				_standingPlatform.center = val3;
				_standingPlatform.size = val4;
				((Collider)_standingPlatform).enabled = flag2;
			}
			else if (((Collider)_standingPlatform).enabled != flag2)
			{
				((Collider)_standingPlatform).enabled = flag2;
			}
			if (flag7)
			{
				UpdateWireframe(_bodyWireframe, val, val2, flag3);
			}
			if (flag8)
			{
				UpdateWireframe(_platformWireframe, val3, val4, flag4);
			}
			if (flag9)
			{
				_rigidbody.isKinematic = true;
				_rigidbody.useGravity = false;
				_rigidbody.detectCollisions = true;
			}
			_hasAppliedShape = true;
			_lastBodyCenter = val;
			_lastBodySize = val2;
			_lastPlatformCenter = val3;
			_lastPlatformSize = val4;
			_lastBodySolidEnabled = flag;
			_lastPlatformEnabled = flag2;
			_lastBodyWireVisible = flag3;
			_lastPlatformWireVisible = flag4;
			return true;
		}

		private static bool Approximately(Vector3 a, Vector3 b)
		{
			//IL_0001: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			return Mathf.Abs(a.x - b.x) <= 0.0005f && Mathf.Abs(a.y - b.y) <= 0.0005f && Mathf.Abs(a.z - b.z) <= 0.0005f;
		}

		private static void UpdateWireframe(LineRenderer? lr, Vector3 center, Vector3 size, bool visible)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0091: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00c2: 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_00d5: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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_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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)lr == (Object)null))
			{
				if (!visible)
				{
					((Renderer)lr).enabled = false;
					return;
				}
				float num = size.x * 0.5f;
				float num2 = size.y * 0.5f;
				float num3 = size.z * 0.5f;
				lr.SetPosition(0, center + new Vector3(0f - num, 0f - num2, 0f - num3));
				lr.SetPosition(1, center + new Vector3(num, 0f - num2, 0f - num3));
				lr.SetPosition(2, center + new Vector3(num, 0f - num2, num3));
				lr.SetPosition(3, center + new Vector3(0f - num, 0f - num2, num3));
				lr.SetPosition(4, center + new Vector3(0f - num, 0f - num2, 0f - num3));
				lr.SetPosition(5, center + new Vector3(0f - num, num2, 0f - num3));
				lr.SetPosition(6, center + new Vector3(num, num2, 0f - num3));
				lr.SetPosition(7, center + new Vector3(num, 0f - num2, 0f - num3));
				lr.SetPosition(8, center + new Vector3(num, num2, 0f - num3));
				lr.SetPosition(9, center + new Vector3(num, num2, num3));
				lr.SetPosition(10, center + new Vector3(num, 0f - num2, num3));
				lr.SetPosition(11, center + new Vector3(num, num2, num3));
				lr.SetPosition(12, center + new Vector3(0f - num, num2, num3));
				lr.SetPosition(13, center + new Vector3(0f - num, 0f - num2, num3));
				lr.SetPosition(14, center + new Vector3(0f - num, num2, num3));
				lr.SetPosition(15, center + new Vector3(0f - num, num2, 0f - num3));
				((Renderer)lr).enabled = true;
			}
		}

		internal void Hide()
		{
			if ((Object)(object)_solidBody != (Object)null)
			{
				((Collider)_solidBody).enabled = false;
			}
			if ((Object)(object)_standingPlatform != (Object)null)
			{
				((Collider)_standingPlatform).enabled = false;
			}
			if ((Object)(object)_bodyWireframe != (Object)null)
			{
				((Renderer)_bodyWireframe).enabled = false;
			}
			if ((Object)(object)_platformWireframe != (Object)null)
			{
				((Renderer)_platformWireframe).enabled = false;
			}
		}

		internal void Destroy()
		{
			if ((Object)(object)_bodyObject != (Object)null)
			{
				Object.Destroy((Object)(object)_bodyObject);
			}
		}
	}
	internal sealed class LocalCollisionResolver
	{
		private const float StackedDistance = 0.001f;

		private const float AnchorActiveDeadzone = 0.025f;

		private const float AnchorPoseDeadzone = 0.25f;

		private const float AnchorVerticalLiftTolerance = 0.1f;

		private const float AnchorVerticalCorrectionTolerance = 0.03f;

		private const float AnchorVerticalSlackHorizontalTolerance = 0.35f;

		private const float AnchorPlatformHorizontalSlack = 0.25f;

		private const float AnchorCarrierVerticalMoveTolerance = 0.05f;

		private const float AnchorRiderDownwardTolerance = 0.005f;

		private const float UnsafeAnchorPoseDeadzone = 0.45f;

		private const float UnsafeAnchorReleaseMargin = 1.25f;

		private const float UnsafeAnchorHardReleaseMargin = 2.5f;

		private const float UnsafeAnchorMaxHorizontalStep = 0.06f;

		private const float UnsafeAnchorPoseGraceSeconds = 2f;

		private static readonly FieldInfo? PlayerIsSittingField = typeof(Player).GetField("_isSitting", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly FieldInfo? MovementLockTypeField = typeof(PlayerMove).GetField("_movementLockType", BindingFlags.Instance | BindingFlags.NonPublic);

		private readonly CollisionPlayerRegistry _registry;

		private readonly CollisionConfig _config;

		internal LocalCollisionResolver(CollisionPlayerRegistry registry, CollisionConfig config)
		{
			_registry = registry;
			_config = config;
		}

		internal void Tick()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00de: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			if (!_config.ModEnabled.Value || !PlayerCollisionPlugin.Instance.LocalCollisionEnabled)
			{
				return;
			}
			CollisionPlayerState localPlayer = _registry.LocalPlayer;
			if (localPlayer == null || !CanUsePlayer(localPlayer) || !localPlayer.HasBounds)
			{
				return;
			}
			Vector3 val = Vector3.zero;
			Player player = localPlayer.Player;
			CollisionPlayerState collisionPlayerState = null;
			bool flag = localPlayer.IsStandingOnPlatform || localPlayer.AnchoredToInstanceId != 0;
			Vector3 val2 = default(Vector3);
			foreach (CollisionPlayerState player2 in _registry.Players)
			{
				if (player2 == localPlayer || !CanCollide(localPlayer, player2, player))
				{
					continue;
				}
				Bounds bounds = localPlayer.Bounds;
				float x = ((Bounds)(ref bounds)).min.x;
				bounds = localPlayer.Bounds;
				float x2 = ((Bounds)(ref bounds)).max.x;
				bounds = localPlayer.Bounds;
				float y = ((Bounds)(ref bounds)).min.y;
				bounds = localPlayer.Bounds;
				float y2 = ((Bounds)(ref bounds)).max.y;
				bounds = localPlayer.Bounds;
				float z = ((Bounds)(ref bounds)).min.z;
				bounds = localPlayer.Bounds;
				float z2 = ((Bounds)(ref bounds)).max.z;
				bounds = player2.Bounds;
				float x3 = ((Bounds)(ref bounds)).min.x;
				bounds = player2.Bounds;
				float x4 = ((Bounds)(ref bounds)).max.x;
				bounds = player2.Bounds;
				float y3 = ((Bounds)(ref bounds)).min.y;
				bounds = player2.Bounds;
				float y4 = ((Bounds)(ref bounds)).max.y;
				bounds = player2.Bounds;
				float z3 = ((Bounds)(ref bounds)).min.z;
				bounds = player2.Bounds;
				float z4 = ((Bounds)(ref bounds)).max.z;
				float headBoxTopY = player2.HeadBoxTopY;
				bool flag2 = localPlayer.AnchoredToInstanceId == player2.InstanceId;
				bool feetNearPlatform;
				bool rootNearPlatform;
				bool flag3 = CollisionPlayerRegistry.TryGetHeadPlatformContact(player2, localPlayer, out feetNearPlatform, out rootNearPlatform);
				float num = y - headBoxTopY;
				bool flag4 = flag3 && (feetNearPlatform || rootNearPlatform);
				bool flag5 = flag2 || (flag3 && feetNearPlatform);
				if (flag4)
				{
					if (flag5)
					{
						localPlayer.StandingOnInstanceId = player2.InstanceId;
						localPlayer.StandingOnUntil = Time.time + 0.25f;
						flag = true;
					}
					if (collisionPlayerState == null || player2.HeadBoxTopY > collisionPlayerState.HeadBoxTopY)
					{
						collisionPlayerState = player2;
					}
				}
				else
				{
					if (!player2.ExpectsSolidBody || x2 <= x3 || x >= x4 || y2 <= y3 || y >= y4 || z2 <= z3 || z >= z4)
					{
						continue;
					}
					if (num > -0.45f || flag2 || localPlayer.StandingOnInstanceId == player2.InstanceId)
					{
						flag = true;
						continue;
					}
					float num2 = Mathf.Min(x2 - x3, x4 - x);
					float num3 = Mathf.Min(z2 - z3, z4 - z);
					if (num2 < num3)
					{
						bounds = localPlayer.Bounds;
						float x5 = ((Bounds)(ref bounds)).center.x;
						bounds = player2.Bounds;
						float num4 = ((x5 >= ((Bounds)(ref bounds)).center.x) ? 1f : (-1f));
						((Vector3)(ref val2))..ctor(num4 * num2, 0f, 0f);
					}
					else
					{
						bounds = localPlayer.Bounds;
						float z5 = ((Bounds)(ref bounds)).center.z;
						bounds = player2.Bounds;
						float num5 = ((z5 >= ((Bounds)(ref bounds)).center.z) ? 1f : (-1f));
						((Vector3)(ref val2))..ctor(0f, 0f, num5 * num3);
					}
					if (((Vector3)(ref val2)).sqrMagnitude < 1.0000001E-06f)
					{
						val2 = FallbackDirection(localPlayer, player2) * Mathf.Max(num2, num3);
					}
					val2 *= Mathf.Max(0f, _config.PushStrength.Value) * Time.deltaTime;
					val += val2;
				}
			}
			if (flag)
			{
				val = Vector3.zero;
			}
			val.y = 0f;
			val = Vector3.ClampMagnitude(val, Mathf.Max(0f, _config.MaxPushPerFrame.Value));
			if (((Vector3)(ref val)).sqrMagnitude > 1E-06f)
			{
				MoveLocalPlayer(localPlayer, val);
			}
			ApplyAnchor(localPlayer, collisionPlayerState);
		}

		private void ApplyAnchor(CollisionPlayerState me, CollisionPlayerState? newCandidate)
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			if (!_config.AnchorRiderToCarrier.Value)
			{
				ClearAnchor(me);
				return;
			}
			bool flag = me.AnchoredToInstanceId != 0;
			bool flag2 = false;
			CollisionPlayerState collisionPlayerState = null;
			if (flag)
			{
				collisionPlayerState = _registry.TryGetByInstanceId(me.AnchoredToInstanceId);
				if (collisionPlayerState == null || (Object)(object)collisionPlayerState.Player == (Object)null || (Object)(object)collisionPlayerState.Root == (Object)null || !collisionPlayerState.HasBounds)
				{
					ClearAnchor(me);
					collisionPlayerState = null;
					flag = false;
				}
			}
			if (collisionPlayerState == null)
			{
				if (newCandidate == null || (Object)(object)newCandidate.Player == (Object)null || (Object)(object)newCandidate.Root == (Object)null || !newCandidate.HasBounds)
				{
					return;
				}
				collisionPlayerState = newCandidate;
				AttachAnchor(me, collisionPlayerState);
				flag2 = true;
			}
			bool flag3 = !me.IsActivePlayer();
			bool flag4 = _config.IsStrictStickMode();
			bool flag5 = !flag4 && _config.IsUnsafeStickMode();
			bool flag6 = flag || flag2;
			Vector3 val = collisionPlayerState.Root.TransformPoint(me.AnchorOffsetLocal);
			float headBoxTopY = collisionPlayerState.HeadBoxTopY;
			float num = (me.HasBounds ? me.BottomOffsetY : 0f);
			float num2 = me.Root.position.y + num;
			Vector2 val2 = new Vector2(val.x - me.Root.position.x, val.z - me.Root.position.z);
			float magnitude = ((Vector2)(ref val2)).magnitude;
			bool flag7 = me.HasAnchorSample && me.AnchoredToInstanceId == collisionPlayerState.InstanceId;
			float num3 = (flag7 ? (headBoxTopY - me.LastAnchorCarrierHeadTopY) : 0f);
			float num4 = (flag7 ? (me.Root.position.y - me.LastAnchorRiderRootY) : 0f);
			bool flag8 = !flag7 || Mathf.Abs(num3) <= 0.05f;
			bool flag9 = flag7 && num4 < -0.005f;
			bool flag10 = IsRiderSitting(me) || IsMovementLocked(me) || flag3 || flag9;
			if (flag10)
			{
				me.AnchorPoseSlackUntil = Time.time + 2f;
			}
			bool flag11 = flag10 || Time.time <= me.AnchorPoseSlackUntil;
			if (flag5 && flag11 && (flag6 || IsStaticHeadCarrier(collisionPlayerState)))
			{
				ApplyUnsafePoseAnchor(me, collisionPlayerState, val);
				return;
			}
			bool flag12 = !flag4 && flag6 && flag8 && magnitude <= 0.35f && IsWithinHeadPlatformHorizontalSlack(me, collisionPlayerState) && flag11;
			float num5 = me.Root.position.y;
			if (!flag12 && !flag3 && num2 < headBoxTopY - 0.1f)
			{
				num5 = Mathf.Max(num5, headBoxTopY + 0.03f - num);
			}
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(val.x, num5, val.z);
			float num6 = Mathf.Max(0.5f, _config.AnchorBreakSafetyDistance.Value);
			float num7 = Mathf.Max(num6 * 3f, num6 + 20f);
			Vector3 val4 = val3 - me.Root.position;
			val2 = new Vector2(val4.x, val4.z);
			float magnitude2 = ((Vector2)(ref val2)).magnitude;
			float num8 = ((flag3 || flag12) ? 0f : Mathf.Max(0f, headBoxTopY - num2));
			float num9 = Mathf.Max(magnitude2, num8);
			if (num9 > num7)
			{
				ClearAnchor(me);
				return;
			}
			if (num9 > num6)
			{
				if (flag5 && flag11)
				{
					ApplyUnsafePoseAnchor(me, collisionPlayerState, val);
					return;
				}
				Vector3 val5 = BuildAnchorRecoveryPosition(me, collisionPlayerState);
				SetLocalPlayerPosition(me, val5);
				RefreshAnchorOffset(me, collisionPlayerState, val5);
				RememberAnchorSample(me, collisionPlayerState);
				ApplyCarrierRotationDelta(me, collisionPlayerState);
				return;
			}
			Vector3 val6 = val4;
			val2 = new Vector2(val6.x, val6.z);
			float magnitude3 = ((Vector2)(ref val2)).magnitude;
			float num10 = (flag3 ? 0.25f : 0.025f);
			if (magnitude3 > num10 || (!flag12 && !flag3 && val6.y > 0.03f))
			{
				if (flag3)
				{
					Vector3 val7 = Vector3.Lerp(me.Root.position, val3, 0.35f);
					SetLocalPlayerPosition(me, val7);
					me.AnchorOffsetLocal = collisionPlayerState.Root.InverseTransformPoint(val7);
				}
				else
				{
					SetLocalPlayerPosition(me, val3);
				}
			}
			else if (flag3)
			{
				me.AnchorOffsetLocal = collisionPlayerState.Root.InverseTransformPoint(me.Root.position);
			}
			RememberAnchorSample(me, collisionPlayerState);
			ApplyCarrierRotationDelta(me, collisionPlayerState);
		}

		private static void AttachAnchor(CollisionPlayerState rider, CollisionPlayerState carrier)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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)
			rider.AnchoredToInstanceId = carrier.InstanceId;
			Vector3 position = rider.Root.position;
			RefreshAnchorOffset(rider, carrier, position);
			rider.AnchorCarrierRotation = carrier.Root.rotation;
			rider.HasAnchorCarrierRotation = true;
		}

		private static void RefreshAnchorOffset(CollisionPlayerState rider, CollisionPlayerState carrier, Vector3 worldRiderPos)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			rider.AnchorOffsetLocal = carrier.Root.InverseTransformPoint(worldRiderPos);
			rider.AnchorHeightOffset = worldRiderPos.y - carrier.HeadBoxTopY;
		}

		private void ApplyUnsafePoseAnchor(CollisionPlayerState rider, CollisionPlayerState carrier, Vector3 carrierWorldOffset)
		{
			//IL_000d: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_009e: 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_00d1: 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_00f2: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_0163: 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_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: 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)
			Vector3 val = carrier.Root.InverseTransformPoint(rider.Root.position) - carrier.PlatformLocalCenter;
			float num = Mathf.Max(0.05f, carrier.HeadBoxWidth * 0.5f + 1.25f);
			float num2 = Mathf.Max(0.05f, carrier.HeadBoxDepth * 0.5f + 1.25f);
			float num3 = Mathf.Max(num, carrier.HeadBoxWidth * 0.5f + 2.5f);
			float num4 = Mathf.Max(num2, carrier.HeadBoxDepth * 0.5f + 2.5f);
			if (Mathf.Abs(val.x) > num3 || Mathf.Abs(val.z) > num4)
			{
				ClearAnchor(rider);
				return;
			}
			bool flag = Mathf.Abs(val.x) > num || Mathf.Abs(val.z) > num2;
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(carrierWorldOffset.x, rider.Root.position.y, carrierWorldOffset.z);
			Vector3 val3 = val2 - rider.Root.position;
			val3.y = 0f;
			float magnitude = ((Vector3)(ref val3)).magnitude;
			if (magnitude > 0.45f)
			{
				float num5 = (flag ? 0.105f : 0.06f);
				Vector3 val4 = Vector3.ClampMagnitude(val3, num5);
				Vector3 val5 = rider.Root.position + val4;
				SetLocalPlayerPosition(rider, val5);
				rider.AnchorOffsetLocal = carrier.Root.InverseTransformPoint(val5);
			}
			else
			{
				rider.AnchorOffsetLocal = carrier.Root.InverseTransformPoint(rider.Root.position);
			}
			RememberAnchorSample(rider, carrier);
			ApplyCarrierRotationDelta(rider, carrier);
		}

		private static Vector3 BuildAnchorRecoveryPosition(CollisionPlayerState rider, CollisionPlayerState carrier)
		{
			//IL_000d: 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_0017: 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_0058: 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_0061: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_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_00e0: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = carrier.Root.InverseTransformPoint(rider.Root.position);
			float num = Mathf.Max(0.05f, carrier.HeadBoxWidth * 0.5f - 0.05f);
			float num2 = Mathf.Max(0.05f, carrier.HeadBoxDepth * 0.5f - 0.05f);
			Vector3 platformLocalCenter = carrier.PlatformLocalCenter;
			val.x = Mathf.Clamp(val.x, platformLocalCenter.x - num, platformLocalCenter.x + num);
			val.z = Mathf.Clamp(val.z, platformLocalCenter.z - num2, platformLocalCenter.z + num2);
			val.y = platformLocalCenter.y;
			Vector3 val2 = carrier.Root.TransformPoint(val);
			float num3 = (rider.HasBounds ? rider.BottomOffsetY : 0f);
			float num4 = carrier.HeadBoxTopY + 0.03f - num3;
			return new Vector3(val2.x, num4, val2.z);
		}

		private static void ClearAnchor(CollisionPlayerState me)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			me.AnchoredToInstanceId = 0;
			me.AnchorOffsetLocal = Vector3.zero;
			me.AnchorHeightOffset = 0f;
			me.AnchorCarrierRotation = Quaternion.identity;
			me.HasAnchorCarrierRotation = false;
			me.LastAnchorCarrierHeadTopY = 0f;
			me.LastAnchorRiderRootY = 0f;
			me.AnchorPoseSlackUntil = 0f;
			me.HasAnchorSample = false;
		}

		private static void RememberAnchorSample(CollisionPlayerState rider, CollisionPlayerState carrier)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			rider.LastAnchorCarrierHeadTopY = carrier.HeadBoxTopY;
			rider.LastAnchorRiderRootY = rider.Root.position.y;
			rider.HasAnchorSample = true;
		}

		private static bool IsWithinHeadPlatformHorizontalSlack(CollisionPlayerState rider, CollisionPlayerState carrier)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rider.Root == (Object)null || (Object)(object)carrier.Root == (Object)null)
			{
				return false;
			}
			Vector3 val = carrier.Root.InverseTransformPoint(rider.Root.position) - carrier.PlatformLocalCenter;
			float num = Mathf.Max(0.05f, carrier.HeadBoxWidth * 0.5f + 0.25f);
			float num2 = Mathf.Max(0.05f, carrier.HeadBoxDepth * 0.5f + 0.25f);
			return Mathf.Abs(val.x) <= num && Mathf.Abs(val.z) <= num2;
		}

		private static bool IsStaticHeadCarrier(CollisionPlayerState carrier)
		{
			return !carrier.ChestBoxActive && string.Equals(carrier.BoxSizingMode, "static", StringComparison.Ordinal);
		}

		private static bool IsRiderSitting(CollisionPlayerState rider)
		{
			try
			{
				object obj = PlayerIsSittingField?.GetValue(rider.Player);
				bool flag = default(bool);
				int num;
				if (obj is bool)
				{
					flag = (bool)obj;
					num = 1;
				}
				else
				{
					num = 0;
				}
				return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
			}
			catch
			{
				return false;
			}
		}

		private static bool IsMovementLocked(CollisionPlayerState rider)
		{
			try
			{
				PlayerMove pMove = rider.Player._pMove;
				if ((Object)(object)pMove == (Object)null || MovementLockTypeField == null)
				{
					return false;
				}
				string a = MovementLockTypeField.GetValue(pMove)?.ToString() ?? string.Empty;
				return !string.Equals(a, "NONE", StringComparison.Ordinal);
			}
			catch
			{
				return false;
			}
		}

		private bool CanCollide(CollisionPlayerState me, CollisionPlayerState other, Player localPlayer)
		{
			if (!CanUsePlayer(other))
			{
				return false;
			}
			if (!other.HasBounds)
			{
				return false;
			}
			if (!other.IsNearLocalPlayer)
			{
				return false;
			}
			if (!other.IsWithinRenderDistance || !other.IsRenderCapSelected)
			{
				return false;
			}
			if (!other.ExpectsSolidBody && !other.ExpectsPlatform)
			{
				return false;
			}
			if (!me.CollisionEnabled || !other.CollisionEnabled)
			{
				return false;
			}
			if (_registry.IsInGracePeriod(me) || _registry.IsInGracePeriod(other))
			{
				return false;
			}
			if (!PlayerIdentity.IsSameMapAsLocal(other.Player, localPlayer))
			{
				return false;
			}
			if (!other.IsWhitelisted)
			{
				return false;
			}
			float value = _config.TinyDisableThreshold.Value;
			if (value > 0f)
			{
				if (me.TinyScale > 0f && me.TinyScale <= value)
				{
					return false;
				}
				if (other.TinyScale > 0f && other.TinyScale <= value)
				{
					return false;
				}
			}
			return true;
		}

		private static bool CanUsePlayer(CollisionPlayerState state)
		{
			return (Object)(object)state.Player != (Object)null && (Object)(object)state.Root != (Object)null;
		}

		private void ApplyCarrierRotationDelta(CollisionPlayerState me, CollisionPlayerState carrier)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (!_config.AnchorRotateWithCarrier.Value)
			{
				me.AnchorCarrierRotation = carrier.Root.rotation;
				me.HasAnchorCarrierRotation = true;
				return;
			}
			if (!me.HasAnchorCarrierRotation)
			{
				me.AnchorCarrierRotation = carrier.Root.rotation;
				me.HasAnchorCarrierRotation = true;
				return;
			}
			Quaternion val = carrier.Root.rotation * Quaternion.Inverse(me.AnchorCarrierRotation);
			me.AnchorCarrierRotation = carrier.Root.rotation;
			if (Quaternion.Angle(val, Quaternion.identity) < 0.05f)
			{
				return;
			}
			try
			{
				me.Root.rotation = val * me.Root.rotation;
			}
			catch
			{
			}
		}

		private static Vector3 FallbackDirection(CollisionPlayerState me, CollisionPlayerState other)
		{
			//IL_003d: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			int num = me.InstanceId ^ (other.InstanceId << 3);
			float num2 = (float)(num & 0x3FF) / 1024f * MathF.PI * 2f;
			return new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2));
		}

		private void MoveLocalPlayer(CollisionPlayerState me, Vector3 push)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			CharacterController val = TryGetController(me);
			if ((Object)(object)val != (Object)null && ((Collider)val).enabled)
			{
				try
				{
					val.Move(push);
					return;
				}
				catch
				{
				}
			}
			if (_config.AllowTransformFallback.Value)
			{
				try
				{
					Transform root = me.Root;
					root.position += push;
				}
				catch
				{
				}
			}
		}

		private static void HardSetLocalPlayerPosition(CollisionPlayerState me, Vector3 worldPosition)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			CharacterController val = TryGetController(me);
			bool flag = false;
			try
			{
				if ((Object)(object)val != (Object)null && ((Collider)val).enabled)
				{
					((Collider)val).enabled = false;
					flag = true;
				}
				me.Root.position = worldPosition;
			}
			catch
			{
			}
			finally
			{
				if ((Object)(object)val != (Object)null && flag)
				{
					try
					{
						((Collider)val).enabled = true;
					}
					catch
					{
					}
				}
			}
		}

		private static void SetLocalPlayerPosition(CollisionPlayerState me, Vector3 worldPosition)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				me.Root.position = worldPosition;
			}
			catch
			{
			}
		}

		private static CharacterController? TryGetController(CollisionPlayerState me)
		{
			CharacterController val = null;
			try
			{
				PlayerMove pMove = me.Player._pMove;
				if ((Object)(object)pMove != (Object)null)
				{
					val = pMove._playerController;
				}
			}
			catch
			{
			}
			if ((Object)(object)val == (Object)null)
			{
				try
				{
					val = ((Component)me.Player).GetComponent<CharacterController>();
				}
				catch
				{
				}
			}
			return val;
		}
	}
	[HarmonyPatch(typeof(ChatBehaviour), "Send_ChatMessage")]
	internal static class CollisionCommands
	{
		private static readonly string[] CommandPrefixes = new string[21]
		{
			"/collider", "/collision", "/pcollision", "/col", "/anchor", "/stick", "/ca", "/boxwhitelist", "/boxwl", "/cwl",
			"/wl", "/boxallow", "/boxdeny", "/boxlist", "/boxsave", "/boxload", "/boxdel", "/boxpresets", "/save", "/load",
			"/remove"
		};

		private static readonly FieldInfo? MaxOnscreenField = typeof(ChatBehaviour).GetField("maxOnscreenMessages", BindingFlags.Instance | BindingFlags.NonPublic) ?? typeof(ChatBehaviour).GetField("_maxOnscreenMessages", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPrefix]
		private static bool Prefix(ChatBehaviour __instance, string _message)
		{
			try
			{
				if (string.IsNullOrWhiteSpace(_message))
				{
					return true;
				}
				string text = _message.Trim();
				string text2 = null;
				string[] commandPrefixes = CommandPrefixes;
				foreach (string text3 in commandPrefixes)
				{
					if (text.StartsWith(text3, StringComparison.OrdinalIgnoreCase) && (text.Length == text3.Length || char.IsWhiteSpace(text[text3.Length])))
					{
						text2 = text3;
						break;
					}
				}
				if (text2 == null)
				{
					return true;
				}
				string text4 = text.Substring(text2.Length).Trim();
				string args;
				if (IsAnchorPrefix(text2))
				{
					args = (string.IsNullOrEmpty(text4) ? "anchor toggle" : ("anchor " + text4));
				}
				else if (text2.Equals("/boxallow", StringComparison.OrdinalIgnoreCase))
				{
					args = (string.IsNullOrEmpty(text4) ? "boxallow" : ("boxallow " + text4));
				}
				else if (text2.Equals("/boxdeny", StringComparison.OrdinalIgnoreCase))
				{
					args = (string.IsNullOrEmpty(text4) ? "boxdeny" : ("boxdeny " + text4));
				}
				else if (text2.Equals("/boxlist", StringComparison.OrdinalIgnoreCase))
				{
					args = "boxlist";
				}
				else if (text2.Equals("/boxsave", StringComparison.OrdinalIgnoreCase))
				{
					args = (string.IsNullOrEmpty(text4) ? "preset save" : ("preset save " + text4));
				}
				else if (text2.Equals("/boxload", StringComparison.OrdinalIgnoreCase))
				{
					args = (string.IsNullOrEmpty(text4) ? "preset load" : ("preset load " + text4));
				}
				else if (text2.Equals("/boxdel", StringComparison.OrdinalIgnoreCase))
				{
					args = (string.IsNullOrEmpty(text4) ? "preset delete" : ("preset delete " + text4));
				}
				else if (text2.Equals("/boxpresets", StringComparison.OrdinalIgnoreCase))
				{
					args = "preset list";
				}
				else if (text2.Equals("/save", StringComparison.OrdinalIgnoreCase))
				{
					if (!TryParseBoxPresetRoot(text4, out string slot))
					{
						return true;
					}
					args = "preset save " + slot;
				}
				else if (!text2.Equals("/load", StringComparison.OrdinalIgnoreCase))
				{
					args = (text2.Equals("/remove", StringComparison.OrdinalIgnoreCase) ? (string.IsNullOrEmpty(text4) ? "remove" : ("remove " + text4)) : ((!IsWhitelistPrefix(text2)) ? (string.IsNullOrEmpty(text4) ? "status" : text4) : (string.IsNullOrEmpty(text4) ? "whitelist toggle" : ("whitelist " + text4))));
				}
				else
				{
					if (!TryParseBoxPresetRoot(text4, out string slot2))
					{
						return true;
					}
					args = "preset load " + slot2;
				}
				HandleCommand(__instance, args);
				SetChatFocusFalse(__instance);
				return false;
			}
			catch (Exception ex)
			{
				PlayerCollisionPlugin.Log.LogError((object)("[Commands] Collider command failed: " + ex.Message));
				return false;
			}
		}

		private static bool TryParseBoxPresetRoot(string rest, out string slot)
		{
			slot = string.Empty;
			if (string.IsNullOrWhiteSpace(rest))
			{
				return false;
			}
			string[] array = rest.Trim().Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length != 2)
			{
				return false;
			}
			if (!array[0].Equals("boxpreset", StringComparison.OrdinalIgnoreCase))
			{
				return false;
			}
			slot = array[1];
			return true;
		}

		private static bool IsAnchorPrefix(string prefix)
		{
			return prefix.Equals("/anchor", StringComparison.OrdinalIgnoreCase) || prefix.Equals("/stick", StringComparison.OrdinalIgnoreCase) || prefix.Equals("/ca", StringComparison.OrdinalIgnoreCase);
		}

		private static bool IsWhitelistPrefix(string prefix)
		{
			return prefix.Equals("/boxwhitelist", StringComparison.OrdinalIgnoreCase) || prefix.Equals("/boxwl", StringComparison.OrdinalIgnoreCase) || prefix.Equals("/cwl", StringComparison.OrdinalIgnoreCase) || prefix.Equals("/wl", StringComparison.OrdinalIgnoreCase);
		}

		private static void HandleCommand(ChatBehaviour chat, string args)
		{
			PlayerCollisionPlugin instance = PlayerCollisionPlugin.Instance;
			if (string.IsNullOrWhiteSpace(args))
			{
				args = "status";
			}
			string[] array = args.Trim().Split(new char[2] { ' ', '\t' }, 2);
			string text = array[0].ToLowerInvariant();
			string text2 = ((array.Length > 1) ? array[1].Trim() : string.Empty);
			switch (text)
			{
			case "on":
			case "enable":
				instance.SetLocalCollisionEnabled(enabled: true);
				SendLocalMessage(chat, "<color=#80FF80>[Collider]</color> Mod and local collision enabled.");
				break;
			case "off":
			case "disable":
				instance.SetLocalCollisionEnabled(enabled: false);
				SendLocalMessage(chat, "<color=#FF8080>[Collider]</color> Local collision disabled.");
				break;
			case "toggle":
				instance.SetLocalCollisionEnabled(!instance.EffectiveCollisionEnabled);
				SendLocalMessage(chat, instance.EffectiveCollisionEnabled ? "<color=#80FF80>[Collider]</color> Mod and local collision enabled." : "<color=#FF8080>[Collider]</color> Local collision disabled.");
				break;
			case "panic":
				instance.PanicLocal();
				SendLocalMessage(chat, "<color=#FF8080>[Collider]</color> Panic used. Local collision disabled and grace reset.");
				break;
			case "debug":
			{
				bool flag = !PlayerCollisionPlugin.ModConfig.DebugCollidersEnabled.Value;
				PlayerCollisionPlugin.ModConfig.DebugCollidersEnabled.Value = flag;
				SendLocalMessage(chat, "<color=#80C8FF>[Collider]</color> Debug colliders " + (flag ? "enabled" : "disabled") + ".");
				break;
			}
			case "reset":
			case "resetbody":
			case "resetbox":
				ResetBoxDefaults();
				SendLocalMessage(chat, "<color=#80C8FF>[Collider]</color> Box dimensions reset to defaults. New size will apply within ~0.1s.");
				break;
			case "anchor":
			case "stick":
			case "a":
				HandleAnchorCommand(chat, text2);
				break;
			case "whitelist":
			case "boxwhitelist":
			case "boxwl":
			case "cwl":
			case "wl":
				HandleWhitelistCommand(chat, text2);
				break;
			case "allow":
			case "boxallow":
				HandleAllow(chat, text2, removeInstead: false);
				break;
			case "deny":
			case "boxdeny":
				HandleAllow(chat, text2, removeInstead: true);
				break;
			case "list":
			case "boxlist":
			{
				HashSet<string> whitelistSet = PlayerCollisionPlugin.ModConfig.GetWhitelistSet();
				bool value = PlayerCollisionPlugin.ModConfig.WhitelistEnabled.Value;
				if (whitelistSet.Count == 0)
				{
					SendLocalMessage(chat, value ? "<color=#80C8FF>[Collider]</color> Whitelist is ON but empty. No remote player boxes are active until you add someone." : "<color=#80C8FF>[Collider]</color> Whitelist is empty (and currently off). All remote players can collide normally.");
					break;
				}
				SendLocalMessage(chat, string.Format("<color=#80C8FF>[Collider]</color> Whitelist ({0} entries, mode={1}):", whitelistSet.Count, value ? "on" : "off"));
				{
					foreach (string item in whitelistSet)
					{
						SendLocalMessage(chat, "  " + item);
					}
					break;
				}
			}
			case "preset":
			case "presets":
				HandlePresetCommand(chat, text2);
				break;
			case "remove":
				HandleRemove(chat, text2);
				break;
			case "status":
				SendStatus(chat, IsAllToken(text2));
				break;
			case "scan":
			case "players":
			case "server":
				SendStatus(chat, includeAllPlayers: true);
				break;
			case "help":
			case "?":
				SendHelp(chat);
				break;
			default:
				SendLocalMessage(chat, "<color=#FF8080>[Collider]</color> Unknown command. Use /collider help for the list.");
				break;
			}
		}

		private static void HandleRemove(ChatBehaviour chat, string nameArg)
		{
			string message;
			string text = (PlayerCollisionPlugin.Registry.TryRemoveHeadRider(nameArg, out message) ? "#80FF80" : (string.IsNullOrWhiteSpace(nameArg) ? "#80C8FF" : "#FFFF80"));
			SendLocalMessage(chat, "<color=" + text + ">[Collider]</color> " + message);
		}

		private static void HandlePresetCommand(ChatBehaviour chat, string args)
		{
			string[] array = (string.IsNullOrWhiteSpace(args) ? Array.Empty<string>() : args.Trim().Split(new char[2] { ' ', '\t' }, 2));
			string text = ((array.Length != 0) ? array[0].ToLowerInvariant() : "list");
			string text2 = ((array.Length > 1) ? array[1].Trim() : string.Empty);
			PlayerCollisionPlugin instance = PlayerCollisionPlugin.Instance;
			switch (text)
			{
			case "save":
			case "s":
			{
				string presetName2;
				string error2;
				if (string.IsNullOrWhiteSpace(text2))
				{
					SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> Usage: /save boxpreset 1  (slots: 1, 2, 3)");
				}
				else if (instance.SaveBoxPreset(text2, out presetName2, out error2))
				{
					SendLocalMessage(chat, "<color=#80FF80>[Collider]</color> Saved box preset " + presetName2 + ". Load it with /load boxpreset " + presetName2 + ".");
				}
				else
				{
					SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> " + error2);
				}
				break;
			}
			case "load":
			case "l":
			{
				string presetName;
				string error;
				if (string.IsNullOrWhiteSpace(text2))
				{
					SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> Usage: /load boxpreset 1  (slots: 1, 2, 3)");
				}
				else if (instance.LoadBoxPreset(text2, out presetName, out error))
				{
					SendLocalMessage(chat, "<color=#80FF80>[Collider]</color> Loaded box preset " + presetName + ".");
				}
				else
				{
					SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> " + error);
				}
				break;
			}
			case "delete":
			case "del":
			case "remove":
			{
				string presetName3;
				if (string.IsNullOrWhiteSpace(text2))
				{
					SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> Usage: /collider preset delete 1  (slots: 1, 2, 3)");
				}
				else if (instance.DeleteBoxPreset(text2, out presetName3))
				{
					SendLocalMessage(chat, "<color=#FFC080>[Collider]</color> Deleted box preset " + presetName3 + ".");
				}
				else
				{
					SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> Box preset " + text2 + " was not found.");
				}
				break;
			}
			case "list":
			case "ls":
			{
				string[] boxPresetNames = PlayerCollisionPlugin.ModConfig.GetBoxPresetNames();
				SendLocalMessage(chat, (boxPresetNames.Length == 0) ? "<color=#80C8FF>[Collider]</color> No box presets saved yet. Use /save boxpreset 1." : ("<color=#80C8FF>[Collider]</color> Saved box preset slots: " + string.Join(", ", boxPresetNames)));
				break;
			}
			default:
				SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> Usage: /save boxpreset 1 or /load boxpreset 1  (slots: 1, 2, 3)");
				break;
			}
		}

		private static void HandleAnchorCommand(ChatBehaviour chat, string action)
		{
			string text = (string.IsNullOrWhiteSpace(action) ? "toggle" : action.Trim().ToLowerInvariant());
			if (text.StartsWith("rotate", StringComparison.OrdinalIgnoreCase))
			{
				string[] array = text.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
				HandleAnchorRotateCommand(chat, (array.Length > 1) ? array[1] : "toggle");
				return;
			}
			ConfigEntry<bool> anchorRiderToCarrier = PlayerCollisionPlugin.ModConfig.AnchorRiderToCarrier;
			switch (text)
			{
			case "on":
			case "enable":
			case "enabled":
			case "true":
			case "1":
				anchorRiderToCarrier.Value = true;
				SendAnchorState(chat);
				break;
			case "off":
			case "disable":
			case "disabled":
			case "false":
			case "0":
				anchorRiderToCarrier.Value = false;
				SendAnchorState(chat);
				break;
			case "toggle":
			case "t":
				anchorRiderToCarrier.Value = !anchorRiderToCarrier.Value;
				SendAnchorState(chat);
				break;
			case "status":
			case "state":
			case "s":
				SendAnchorState(chat);
				break;
			default:
				SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> Usage: /anchor [on|off|toggle|status] or /anchor rotate [on|off|status]");
				break;
			}
		}

		private static void HandleAnchorRotateCommand(ChatBehaviour chat, string action)
		{
			string text = (string.IsNullOrWhiteSpace(action) ? "toggle" : action.Trim().ToLowerInvariant());
			ConfigEntry<bool> anchorRotateWithCarrier = PlayerCollisionPlugin.ModConfig.AnchorRotateWithCarrier;
			switch (text)
			{
			case "on":
			case "enable":
			case "enabled":
			case "true":
			case "1":
				anchorRotateWithCarrier.Value = true;
				SendAnchorRotateState(chat);
				break;
			case "off":
			case "disable":
			case "disabled":
			case "false":
			case "0":
				anchorRotateWithCarrier.Value = false;
				SendAnchorRotateState(chat);
				break;
			case "toggle":
			case "t":
				anchorRotateWithCarrier.Value = !anchorRotateWithCarrier.Value;
				SendAnchorRotateState(chat);
				break;
			case "status":
			case "state":
			case "s":
				SendAnchorRotateState(chat);
				break;
			default:
				SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> Usage: /anchor rotate [on|off|toggle|status]");
				break;
			}
		}

		private static void SendAnchorState(ChatBehaviour chat)
		{
			bool value = PlayerCollisionPlugin.ModConfig.AnchorRiderToCarrier.Value;
			SendLocalMessage(chat, value ? "<color=#80FF80>[Collider]</color> Anchor mode ON. Shortcuts: /anchor off, /stick off, /ca off." : "<color=#FF8080>[Collider]</color> Anchor mode OFF. Shortcuts: /anchor on, /stick on, /ca on.");
		}

		private static void SendAnchorRotateState(ChatBehaviour chat)
		{
			bool value = PlayerCollisionPlugin.ModConfig.AnchorRotateWithCarrier.Value;
			SendLocalMessage(chat, value ? "<color=#80FF80>[Collider]</color> Stick rotation ON. Rider turns with carrier rotation but can still turn locally." : "<color=#FFC080>[Collider]</color> Stick rotation OFF. Rider facing is fully free while stuck.");
		}

		private static void HandleWhitelistCommand(ChatBehaviour chat, string action)
		{
			string text = (string.IsNullOrWhiteSpace(action) ? "toggle" : action.Trim().ToLowerInvariant());
			ConfigEntry<bool> whitelistEnabled = PlayerCollisionPlugin.ModConfig.WhitelistEnabled;
			switch (text)
			{
			case "on":
			case "enable":
			case "enabled":
			case "true":
			case "1":
				whitelistEnabled.Value = true;
				SendWhitelistState(chat);
				break;
			case "off":
			case "disable":
			case "disabled":
			case "false":
			case "0":
				whitelistEnabled.Value = false;
				SendWhitelistState(chat);
				break;
			case "toggle":
			case "t":
				whitelistEnabled.Value = !whitelistEnabled.Value;
				SendWhitelistState(chat);
				break;
			case "status":
			case "state":
			case "s":
				SendWhitelistState(chat);
				break;
			default:
				SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> Usage: /boxwhitelist [on|off|toggle|status]  Aliases: /boxwl, /cwl, /wl");
				break;
			}
		}

		private static void SendWhitelistState(ChatBehaviour chat)
		{
			bool value = PlayerCollisionPlugin.ModConfig.WhitelistEnabled.Value;
			int count = PlayerCollisionPlugin.ModConfig.GetWhitelistSet().Count;
			SendLocalMessage(chat, value ? $"<color=#80FF80>[Collider]</color> Whitelist mode ON. Listed remote players get boxes on your client; compatible clients also hide your box unless listed. {count} player(s) listed. /boxallow <name> to add." : $"<color=#FFC080>[Collider]</color> Whitelist mode OFF. All remote players collide normally on your client. {count} player(s) saved in the whitelist.");
		}

		private static void HandleAllow(ChatBehaviour chat, string nameArg, bool removeInstead)
		{
			if (string.IsNullOrWhiteSpace(nameArg))
			{
				SendLocalMessage(chat, removeInstead ? "<color=#FFFF80>[Collider]</color> Usage: /collider deny <player name>" : "<color=#FFFF80>[Collider]</color> Usage: /collider allow <player name>");
				return;
			}
			string text = nameArg.Trim().ToLowerInvariant();
			Player[] array = Object.FindObjectsOfType<Player>();
			Player val = null;
			Player val2 = null;
			Player val3 = null;
			string text2 = string.Empty;
			Player[] array2 = array;
			foreach (Player val4 in array2)
			{
				if ((Object)(object)val4 == (Object)null)
				{
					continue;
				}
				string text3 = PlayerIdentity.GetDisplayName(val4) ?? string.Empty;
				string text4 = text3.ToLowerInvariant();
				if (text4 == text)
				{
					val = val4;
					text2 = text3;
					break;
				}
				if (text4.StartsWith(text) && (Object)(object)val2 == (Object)null)
				{
					val2 = val4;
					if (text2.Length == 0)
					{
						text2 = text3;
					}
				}
				else if (text4.Contains(text) && (Object)(object)val3 == (Object)null)
				{
					val3 = val4;
					if (text2.Length == 0)
					{
						text2 = text3;
					}
				}
			}
			Player val5 = val ?? val2 ?? val3;
			if ((Object)(object)val5 == (Object)null)
			{
				SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> No player named '" + nameArg + "' found in this server.");
				return;
			}
			string text5 = PlayerIdentity.GetSteamId(val5) ?? "0";
			if (text5 == "0")
			{
				SendLocalMessage(chat, "<color=#FFFF80>[Collider]</color> Found '" + text2 + "' but steam id not available yet.");
			}
			else if (removeInstead)
			{
				bool flag = PlayerCollisionPlugin.ModConfig.RemoveFromWhitelist(text5);
				SendLocalMessage(chat, flag ? ("<color=#FFC080>[Collider]</color> Removed '" + text2 + "' (" + text5 + ") from whitelist.") : ("<color=#FFFF80>[Collider]</color> '" + text2 + "' (" + text5 + ") was not on the whitelist."));
			}
			else
			{
				bool flag2 = PlayerCollisionPlugin.ModConfig.AddToWhitelist(text5);
				SendLocalMessage(chat, flag2 ? ("<color=#80FF80>[Collider]</color> Whitelisted '" + text2 + "' (" + text5 + ").") : ("<color=#80C8FF>[Collider]</color> '" + text2 + "' (" + text5 + ") was already whitelisted."));
			}
		}

		private static void ResetBoxDefaults()
		{
			CollisionConfig modConfig = PlayerCollisionPlugin.ModConfig;
			modConfig.ResetSessionBoxDimensions();
			modConfig.MinDimension.Value = (float)((ConfigEntryBase)modConfig.MinDimension).DefaultValue;
			modConfig.MaxDimension.Value = (float)((ConfigEntryBase)modConfig.MaxDimension).DefaultValue;
			modConfig.TinyDisableThreshold.Value = (float)((ConfigEntryBase)modConfig.TinyDisableThreshold).DefaultValue;
			modConfig.PlatformExtraWidth.Value = (float)((ConfigEntryBase)modConfig.PlatformExtraWidth).DefaultValue;
			modConfig.PlatformExtraDepth.Value = (float)((ConfigEntryBase)modConfig.PlatformExtraDepth).DefaultValue;
			modConfig.PlatformThickness.Value = (float)((ConfigEntryBase)modConfig.PlatformThickness).DefaultValue;
			modConfig.PlatformTopOffset.Value = (float)((ConfigEntryBase)modConfig.PlatformTopOffset).DefaultValue;
			modConfig.HeadBoneTopOffset.Value = (float)((ConfigEntryBase)modConfig.HeadBoneTopOffset).DefaultValue;
			modConfig.BodyHeadClearance.Value = (float)((ConfigEntryBase)modConfig.BodyHeadClearance).DefaultValue;
			modConfig.BodyWidthAdjustment.Value = (float)((ConfigEntryBase)modConfig.BodyWidthAdjustment).DefaultValue;
			modConfig.BodyDepthAdjustment.Value = (float)((ConfigEntryBase)modConfig.BodyDepthAdjustment).DefaultValue;
			modConfig.BodyHeightAdjustment.Value = (float)((ConfigEntryBase)modConfig.BodyHeightAdjustment).DefaultValue;
			modConfig.HeadWidthAdjustment.Value = (float)((ConfigEntryBase)modConfig.HeadWidthAdjustment).DefaultValue;
			modConfig.HeadDepthAdjustment.Value = (float)((ConfigEntryBase)modConfig.HeadDepthAdjustment).DefaultValue;
			modConfig.HeadHeightAdjustment.Value = (float)((ConfigEntryBase)modConfig.HeadHeightAdjustment).DefaultValue;
			modConfig.ChestBoxHeightRatio.Value = (float)((ConfigEntryBase)modConfig.ChestBoxHeightRatio).DefaultValue;
			modConfig.ChestBoxWidthMultiplier.Value = (float)((ConfigEntryBase)modConfig.ChestBoxWidthMultiplier).DefaultValue;
			modConfig.ChestBoxDepthMultiplier.Value = (float)((ConfigEntryBase)modConfig.ChestBoxDepthMultiplier).DefaultValue;
			modConfig.ChestBoxThickness.Value = (float)((ConfigEntryBase)modConfig.ChestBoxThickness).DefaultValue;
			modConfig.ChestBoxForwardOffset.Value = (float)((ConfigEntryBase)modConfig.ChestBoxForwardOffset).DefaultValue;
			modConfig.VisualBoundsLerpSpeed.Value = (float)((ConfigEntryBase)modConfig.VisualBoundsLerpSpeed).DefaultValue;
			modConfig.PoseMeasureIntervalSeconds.Value = (float)((ConfigEntryBase)modConfig.PoseMeasureIntervalSeconds).DefaultValue;
			modConfig.PushStrength.Value = (float)((ConfigEntryBase)modConfig.PushStrength).DefaultValue;
			modConfig.MaxPushPerFrame.Value = (float)((ConfigEntryBase)modConfig.MaxPushPerFrame).DefaultValue;
			modConfig.UseBakedPoseBounds.Value = false;
			modConfig.UseBodyMeshForSize.Value = true;
			modConfig.VisualBoundsEnabled.Value = true;
			modConfig.IncludeAccessoriesInBounds.Value = false;
			modConfig.StaticBoxesEnabled.Value = true;
			modConfig.DynamicBoxesEnabled.Value = false;
			modConfig.UnsafeStickEnabled.Value = true;
			modConfig.StrictStickEnabled.Value = false;
			modConfig.ChestBoxEnabled.Value = false;
			modConfig.NormalizeBoxMode(preferStatic: true);
			modConfig.NormalizeStickMode(preferUnsafe: true);
		}

		private static void SendHelp(ChatBehaviour chat)
		{
			SendLocalMessage(chat, "<color=#80C8FF>[Collider]</color> Available commands:");
			SendLocalMessage(chat, "  /collider on        - Enable local player collision");
			SendLocalMessage(chat, "  /collider off       - Disable local player collision");
			SendLocalMessage(chat, "  /collider toggle    - Flip the enable/disable state");
			SendLocalMessage(chat, "  /collider debug     - Toggle visible green wireframe boxes");
			SendLocalMessage(chat, "  /anchor on|off      - Shortcut for stick-to-carrier mode");
			SendLocalMessage(chat, "  /anchor rotate on|off - Rotate rider with carrier while stick is active");
			SendLocalMessage(chat, "  /stick              - Toggle anchor mode; alias: /ca");
			SendLocalMessage(chat, "  /collider anchor on|off|status - Full anchor command");
			SendLocalMessage(chat, "  /collider reset     - Reset box dimensions and platform settings to defaults");
			SendLocalMessage(chat, "  /collider status    - Print local player bounds + diagnostics");
			SendLocalMessage(chat, "  /collider status all - Print scale and box diagnostics for every tracked player");
			SendLocalMessage(chat, "  /remove <name>      - Remove a detected rider from your head box");
			SendLocalMessage(chat, "  /collider panic     - Emergency disable + reset grace period");
			SendLocalMessage(chat, "  /collider whitelist on|off|status - Set or check whitelist-only mode");
			SendLocalMessage(chat, "  /boxwl on|off|status - Short whitelist command; aliases: /cwl, /wl");
			SendLocalMessage(chat, "  /collider allow <name> - Add player to the whitelist");
			SendLocalMessage(chat, "  /collider deny <name>  - Remove player from the whitelist");
			SendLocalMessage(chat, "  /collider list      - Show every steam id on the whitelist");
			SendLocalMessage(chat, "  /save boxpreset 1  - Save box tuning to slot 1 (slots 1-3)");
			SendLocalMessage(chat, "  /load boxpreset 1  - Load box tuning from slot 1");
			SendLocalMessage(chat, "  /boxsave 1, /boxload 1, /boxpresets - Preset shortcuts");
			SendLocalMessage(chat, "  /collider help      - Show this list");
			SendLocalMessage(chat, "<color=#80C8FF>Aliases:</color> /col, /collision, /pcollision");
		}

		private static void SendStatus(ChatBehaviour chat, bool includeAllPlayers = false)
		{
			//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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00c5: 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_00dd: 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_0102: 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)
			CollisionPlayerState localPlayer = PlayerCollisionPlugin.Registry.LocalPlayer;
			int count = PlayerCollisionPlugin.Registry.Players.Count;
			string text;
			if (localPlayer == null)
			{
				text = "local player not found yet";
			}
			else if (!localPlayer.HasBounds)
			{
				text = $"local={localPlayer.DisplayName}, steam={localPlayer.SteamId}, bounds=NONE, grace={localPlayer.IsInGracePeriod}";
			}
			else
			{
				Bounds bounds = localPlayer.Bounds;
				Vector3 size = ((Bounds)(ref bounds)).size;
				bounds = localPlayer.Bounds;
				Vector3 center = ((Bounds)(ref bounds)).center;
				text = "local=" + localPlayer.DisplayName + ", steam=" + localPlayer.SteamId + ", " + $"size=({size.x:F2},{size.y:F2},{size.z:F2}), " + $"center=({center.x:F2},{center.y:F2},{center.z:F2}), " + $"renderers={localPlayer.CachedRenderers.Length}, grace={localPlayer.IsInGracePeriod}";
			}
			CollisionConfig modConfig = PlayerCollisionPlugin.ModConfig;
			string text2 = (modConfig.IsDynamicBoxMode() ? "dynamic" : "static");
			string text3 = (modConfig.IsStrictStickMode() ? "oldStrict" : "emote");
			SendLocalMessage(chat, $"<color=#80C8FF>[Collider]</color> modEnabled={modConfig.ModEnabled.Value}, localCollision={PlayerCollisionPlugin.Instance.LocalCollisionEnabled}, effective={PlayerCollisionPlugin.Instance.EffectiveCollisionEnabled}, boxMode={text2}, stickSafety={text3}, chestBox={modConfig.ChestBoxEnabled.Value}, players={count}, {text}");
			if (!includeAllPlayers)
			{
				return;
			}
			foreach (CollisionPlayerState player in PlayerCollisionPlugin.Registry.Players)
			{
				SendLocalMessage(chat, FormatPlayerDiagnostics(player));
			}
		}

		private static bool IsAllToken(string token)
		{
			if (string.IsNullOrWhiteSpace(token))
			{
				return false;
			}
			return token.Equals("all", StringComparison.OrdinalIgnoreCase) || token.Equals("players", StringComparison.OrdinalIgnoreCase) || token.Equals("server", StringComparison.OrdinalIgnoreCase);
		}

		private static string FormatPlayerDiagnostics(CollisionPlayerState state)
		{
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			if (state == null)
			{
				return "<color=#80C8FF>[Collider]</color> <null player state>";
			}
			if (!state.HasBounds)
			{
				return "<color=#80C8FF>[Collider]</color> " + state.DisplayName + ": steam=" + state.SteamId + ", bounds=NONE, " + $"scale=({state.EffectiveScale.x:F2},{state.EffectiveScale.y:F2}), tiny={state.TinyScale:F3}, " + $"boxMode={state.BoxSizingMode}, measure={state.MeasurementMode}, chest={state.ChestBoxActive}, poseLowered={state.StaticPoseLowered}, remotePose={state.HasRemotePoseState}/{state.RemotePoseLowered}/{state.RemotePoseSitting}/{state.RemotePoseEmoting}, " + $"map={state.IsSameMapAsLocal}, near={state.IsNearLocalPlayer}, debugNear={state.ShouldRenderDebug}, " + $"localWhitelist={state.IsLocalWhitelisted}, remoteWhitelist={state.IsRemoteWhitelisted}/{state.HasRemoteWhitelistPolicy}, " + $"boxObj={state.BodyObjectActive}, solid={state.SolidBodyActive}/{state.ExpectsSolidBody}, platform={state.PlatformActive}/{state.ExpectsPlatform}, reason={state.LastHideReason}, " + $"renderers={state.CachedRenderers.Length}, grace={state.IsInGracePeriod}";
			}
			return "<color=#80C8FF>[Collider]</color> " + state.DisplayName + ": steam=" + state.SteamId + ", " + $"scale=({state.EffectiveScale.x:F2},{state.EffectiveScale.y:F2}), " + $"tiny={state.TinyScale:F3}, " + $"boxMode={state.BoxSizingMode}, measure={state.MeasurementMode}, chest={state.ChestBoxActive}, poseLowered={state.StaticPoseLowered}, remotePose={state.HasRemotePoseState}/{state.RemotePoseLowered}/{state.RemotePoseSitting}/{state.RemotePoseEmoting}, " + $"body=({state.BoxWidth:F2},{state.BoxHeight:F2},{state.BoxDepth:F2}), " + $"head=({state.HeadBoxWidth:F2},{state.HeadBoxThickness:F2},{state.HeadBoxDepth:F2}), " + $"bodyTop={state.TopOffsetY:F2}, headTop={state.HeadBoxTopOffsetY:F2}, headTracked={(Object)(object)state.CachedHeadTransform != (Object)null}, whitelisted={state.IsWhitelisted}, " + $"localWhitelist={state.IsLocalWhitelisted}, remoteWhitelist={state.IsRemoteWhitelisted}/{state.HasRemoteWhitelistPolicy}, " + $"map={state.IsSameMapAsLocal}, near={state.IsNearLocalPlayer}, debugNear={state.ShouldRenderDebug}, " + $"boxObj={state.BodyObjectActive}, solid={state.SolidBodyActive}/{state.ExpectsSolidBody}, platform={state.PlatformActive}/{state.ExpectsPlatform}, wire={state.WireVisible}, reason={state.LastHideReason}, " + $"renderers={state.CachedRenderers.Length}, grace={state.IsInGracePeriod}";
		}

		private static void SendLocalMessage(ChatBehaviour chat, string message)
		{
			try
			{
				try
				{
					MaxOnscreenField?.SetValue(chat, 50);
				}
				catch
				{
				}
				chat.Init_GameLogicMessage(message);
			}
			catch (Exception ex)
			{
				PlayerCollisionPlugin.Log.LogError((object)("[Commands] Failed to send local message: " + ex.Message));
			}
		}

		private static void SetChatFocusFalse(ChatBehaviour chat)
		{
			try
			{
				string[] array = new string[5] { "Init_ChatFocusFalse", "Set_ChatFocusFalse", "Close_Chat", "Deactivate_Chat", "Exit_Chat" };
				Type type = ((object)chat).GetType();
				string[] array2 = array;
				foreach (string name in array2)
				{
					MethodInfo method = type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (!(method == null))
					{
						method.Invoke(chat, null);
						return;
					}
				}
				type.GetField("_focusedInChat", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(chat, false);
			}
			catch
			{
			}
		}
	}
	internal static class CommandLibBinding
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static CommandCallback <0>__Handle;

			public static CommandCallback <1>__HandleAnchorShortcut;

			public static CommandCallback <2>__HandleBoxAllow;

			public static CommandCallback <3>__HandleBoxDeny;

			public static CommandCallback <4>__HandleBoxList;

			public static CommandCallback <5>__HandleBoxWhitelist;

			public static CommandCallback <6>__HandleRemoveRider;

			public static CommandCallback <7>__HandleBoxSavePreset;

			public static CommandCallback <8>__HandleBoxLoadPreset;

			public static CommandCallback <9>__HandleBoxDeletePreset;

			public static CommandCallback <10>__HandleBoxListPresets;

			public static CommandCallback <11>__HandleRootSave;

			public static CommandCallback <12>__HandleRootLoad;
		}

		internal static void Register()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Expected O, but got Unknown
			//IL_008f: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Expected O, but got Unknown
			//IL_014f: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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_0186: Expected O, but got Unknown
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Expected O, but got Unknown
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Expected O, but got Unknown
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Expected O, but got Unknown
			try
			{
				CommandOptions value = default(CommandOptions);
				((CommandOptions)(ref value))..ctor((ChatCommandType)1);
				object obj = <>O.<0>__Handle;
				if (obj == null)
				{
					CommandCallback val = Handle;
					<>O.<0>__Handle = val;
					obj = (object)val;
				}
				ModCommand val2 = Utils.RegisterCommand("collider", "Manage the player collider mod. Args: on, off, toggle, status, debug, panic, anchor, reset, whitelist, allow, deny, list, remove, preset", "Examples: /collider on  |  /save boxpreset 1  |  /remove PlayerName", (CommandCallback)obj, (CommandOptions?)value);
				Utils.RegisterAlias(new string[3] { "col", "collision", "pcollision" }, val2);
				object obj2 = <>O.<1>__HandleAnchorShortcut;
				if (obj2 == null)
				{
					CommandCallback val3 = HandleAnchorShortcut;
					<>O.<1>__HandleAnchorShortcut = val3;
					obj2 = (object)val3;
				}
				ModCommand val4 = Utils.RegisterCommand("anchor", "Toggle or set stick-to-carrier mode. /anchor [on|off|toggle|status]", "Examples: /anchor  |  /anchor on  |  /stick off  |  /ca status", (CommandCallback)obj2, (CommandOptions?)value);
				Utils.RegisterAlias(new string[2] { "stick", "ca" }, val4);
				object obj3 = <>O.<2>__HandleBoxAllow;
				if (obj3 == null)
				{
					CommandCallback val5 = HandleBoxAllow;
					<>O.<2>__HandleBoxAllow = val5;
					obj3 = (object)val5;
				}
				ModCommand val6 = Utils.RegisterCommand("boxallow", "Add a player to the collision whitelist by display name. /boxallow <name>", "Looks up the remote player's steam id and adds it to the whitelist. Only meaningful when /boxwhitelist is on.", (CommandCallback)obj3, (CommandOptions?)value);
				object obj4 = <>O.<3>__HandleBoxDeny;
				if (obj4 == null)
				{
					CommandCallback val7 = HandleBoxDeny;
					<>O.<3>__HandleBoxDeny = val7;
					obj4 = (object)val7;
				}
				ModCommand val8 = Utils.RegisterCommand("boxdeny", "Remove a player from the collision whitelist by display name. /boxdeny <name>", "Removes the player's steam id from the whitelist.", (CommandCallback)obj4, (CommandOptions?)value);
				object obj5 = <>O.<4>__HandleBoxList;
				if (obj5 == null)
				{
					CommandCallback val9 = HandleBoxList;
					<>O.<4>__HandleBoxList = val9;
					obj5 = (object)val9;
				}
				ModCommand val10 = Utils.RegisterCommand("boxlist", "List every steam id currently in the collision whitelist.", "Shows the names that match each id if those players are nearby.", (CommandCallback)obj5, (CommandOptions?)value);
				object obj6 = <>O.<5>__HandleBoxWhitelist;
				if (obj6 == null)
				{
					CommandCallback val11 = HandleBoxWhitelist;
					<>O.<5>__HandleBoxWhitelist = val11;
					obj6 = (object)val11;
				}
				ModCommand val12 = Utils.RegisterCommand("boxwhitelist", "Toggle whitelist-only collision mode. /boxwhitelist [on|off|toggle|status]", "When ON, only listed remote players have solid colliders on your client. Default: off.", (CommandCallback)obj6, (CommandOptions?)value);
				Utils.RegisterAlias(new string[3] { "boxwl", "cwl", "wl" }, val12);
				try
				{
					object obj7 = <>O.<6>__HandleRemoveRider;
					if (obj7 == null)
					{
						CommandCallback val13 = HandleRemoveRider;
						<>O.<6>__HandleRemoveRider = val13;
						obj7 = (object)val13;
					}
					Utils.RegisterCommand("remove", "Remove a detected rider from your head box. /remove [player name]", "Use /remove to list detected riders, or /remove <name> to remove one.", (CommandCallback)obj7, (CommandOptions?)value);
				}
				catch (Exception ex)
				{
					PlayerCollisionPlugin.Log.LogWarning((object)("[CommandLib] Could not register /remove shortcut: " + ex.Message));
				}
				object obj8 = <>O.<7>__HandleBoxSavePreset;
				if (obj8 == null)
				{
					CommandCallback val14 = HandleBoxSavePreset;
					<>O.<7>__HandleBoxSavePreset = val14;
					obj8 = (object)val14;
				}
				ModCommand val15 = Utils.RegisterCommand("boxsave", "Save current collider sizing settings to preset slot 1-3. /boxsave <slot>", "Example: /boxsave 1", (CommandCallback)obj8, (CommandOptions?)value);
				object obj9 = <>O.<8>__HandleBoxLoadPreset;
				if (obj9 == null)
				{
					CommandCallback val16 = HandleBoxLoadPreset;
					<>O.<8>__HandleBoxLoadPreset = val16;
					obj9 = (object)val16;
				}
				ModCommand val17 = Utils.RegisterCommand("boxload", "Load collider sizing settings from preset slot 1-3. /boxload <slot>", "Example: /boxload 1", (CommandCallback)obj9, (CommandOptions?)value);
				object obj10 = <>O.<9>__HandleBoxDeletePreset;
				if (obj10 == null)
				{
					CommandCallback val18 = HandleBoxDeletePreset;
					<>O.<9>__HandleBoxDeletePreset = val18;
					obj10 = (object)val18;
				}
				ModCommand val19 = Utils.RegisterCommand("boxdel", "Delete collider sizing preset slot 1-3. /boxdel <slot>", "Example: /boxdel 1", (CommandCallback)obj10, (CommandOptions?)value);
				object obj11 = <>O.<10>__HandleBoxListPresets;
				if (obj11 == null)
				{
					CommandCallback val20 = HandleBoxListPresets;
					<>O.<10>__HandleBoxListPresets = val20;
					obj11 = (object)val20;
				}
				ModCommand val21 = Utils.RegisterCommand("boxpresets", "List saved collider sizing presets.", "Example: /boxpresets", (CommandCallback)obj11, (CommandOptions?)value);
				try
				{
					object obj12 = <>O.<11>__HandleRootSave;
					if (obj12 == null)
					{
						CommandCallback val22 = HandleRootSave;
						<>O.<11>__HandleRootSave = val22;
						obj12 = (object)val22;
					}
					Utils.RegisterCommand("save", "Save a numbered box preset. Usage: /save boxpreset <1-3>", "Example: /save boxpreset 1", (CommandCallback)obj12, (CommandOptions?)value);
					object obj13 = <>O.<12>__HandleRootLoad;
					if (obj13 == null)
					{
						CommandCallback val23 = HandleRootLoad;
						<>O.<12>__HandleRootLoad = val23;
						obj13 = (object)val23;
					}
					Utils.RegisterCommand("load", "Load a numbered box preset. Usage: /load boxpreset <1-3>", "Example: /load boxpreset 1", (CommandCallback)obj13, (CommandOptions?)value);
				}
				catch (Exception ex2)
				{
					PlayerCollisionPlugin.Log.LogWarning((object)("[CommandLib] Could not register /save or /load preset shortcuts: " + ex2.Message));
				}
				PlayerCollisionPlugin.Log.LogInfo((object)"[CommandLib] Registered /collider, /anchor, /stick, /ca + whitelist, remove, and preset commands.");
			}
			catch (Exception ex3)
			{
				PlayerCollisionPlugin.Log.LogError((object)("[CommandLib] Registration failed: " + ex3.Message));
			}
		}

		private static bool Handle(Caller caller, string[] args)
		{
			//IL_0786: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Unknown result type (might be due to invalid IL or missing references)
			//IL_0586: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to inval