Decompiled source of BoneHunt v0.2.0

BONELAB/BonelabPropHunt.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using BonelabPropHunt;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Interaction;
using Il2CppSLZ.Marrow.Pool;
using LabFusion.Entities;
using LabFusion.Network;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Main), "BoneHunt", "0.1.0", "CrispyDev", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BonelabPropHunt")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BonelabPropHunt")]
[assembly: AssemblyTitle("BonelabPropHunt")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BonelabPropHunt
{
	public class Main : MelonMod
	{
		public static Instance Log;

		public override void OnInitializeMelon()
		{
			Log = ((MelonBase)this).LoggerInstance;
			Log.Msg("BonelabPropHunt loading...");
			PropSelector.Init();
			PropifyController.Init();
			Log.Msg("BonelabPropHunt ready.");
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			Log.Msg("[PropHunt] Scene loaded ('" + sceneName + "') - refreshing prop list.");
			if (PropifyController.IsActive)
			{
				Log.Msg("[PropHunt] Level changed while possessing a prop - ejecting.");
				PropifyController.EndPossession();
			}
			PropSelector.RefreshMenu();
		}

		public override void OnUpdate()
		{
			PropifyController.Tick();
		}

		public override void OnLateUpdate()
		{
			PropifyController.LateTick();
		}

		public override void OnFixedUpdate()
		{
			PropifyController.FixedTick();
			TouchPossess.FixedTick();
		}
	}
	public static class PropifyController
	{
		private static Rigidbody _possessed;

		private static bool _active;

		private static float _lastJumpTime;

		private static float _lastBTapTime;

		private static Vector3 _lastKnownPos;

		private static NetworkEntity _currentEntity;

		private static Transform _camTransform;

		private const float CamDistance = 2.5f;

		private const float CamHeight = 1.2f;

		private const float MaxSpeed = 5f;

		private const float JumpVelocity = 5f;

		private const float JumpCooldown = 0.2f;

		private static bool _wantsToJump;

		private static bool _wantsToSnapUpright;

		private static readonly List<Rigidbody> _frozenRigBodies = new List<Rigidbody>();

		private static readonly List<Collider> _frozenColliders = new List<Collider>();

		private static readonly List<CharacterController> _frozenCharControllers = new List<CharacterController>();

		private static readonly Dictionary<Transform, Vector3> _originalScales = new Dictionary<Transform, Vector3>();

		public static bool IsActive => _active;

		public static void Init()
		{
		}

		private static void FreezePlayerRig(bool freeze)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			RigManager localRigManager = PropSelector.GetLocalRigManager();
			if ((Object)(object)localRigManager == (Object)null || (Object)(object)localRigManager.physicsRig == (Object)null)
			{
				return;
			}
			if (freeze)
			{
				_frozenRigBodies.Clear();
				_frozenColliders.Clear();
				_frozenCharControllers.Clear();
				foreach (Rigidbody componentsInChild in ((Component)localRigManager.physicsRig).GetComponentsInChildren<Rigidbody>())
				{
					if (!((Object)(object)componentsInChild == (Object)null) && !componentsInChild.isKinematic)
					{
						componentsInChild.velocity = Vector3.zero;
						componentsInChild.angularVelocity = Vector3.zero;
						componentsInChild.isKinematic = true;
						_frozenRigBodies.Add(componentsInChild);
					}
				}
				foreach (Collider componentsInChild2 in ((Component)localRigManager.physicsRig).GetComponentsInChildren<Collider>())
				{
					if (!((Object)(object)componentsInChild2 == (Object)null) && componentsInChild2.enabled)
					{
						componentsInChild2.enabled = false;
						_frozenColliders.Add(componentsInChild2);
					}
				}
				{
					foreach (CharacterController componentsInChild3 in ((Component)localRigManager).GetComponentsInChildren<CharacterController>())
					{
						if (!((Object)(object)componentsInChild3 == (Object)null) && ((Collider)componentsInChild3).enabled)
						{
							((Collider)componentsInChild3).enabled = false;
							_frozenCharControllers.Add(componentsInChild3);
						}
					}
					return;
				}
			}
			foreach (Rigidbody frozenRigBody in _frozenRigBodies)
			{
				if ((Object)(object)frozenRigBody != (Object)null)
				{
					frozenRigBody.isKinematic = false;
				}
			}
			_frozenRigBodies.Clear();
			foreach (Collider frozenCollider in _frozenColliders)
			{
				if ((Object)(object)frozenCollider != (Object)null)
				{
					frozenCollider.enabled = true;
				}
			}
			_frozenColliders.Clear();
			foreach (CharacterController frozenCharController in _frozenCharControllers)
			{
				if ((Object)(object)frozenCharController != (Object)null)
				{
					((Collider)frozenCharController).enabled = true;
				}
			}
			_frozenCharControllers.Clear();
		}

		private static void SetPlayerAvatarVisibility(bool hide)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			RigManager localRigManager = PropSelector.GetLocalRigManager();
			if ((Object)(object)localRigManager == (Object)null)
			{
				return;
			}
			foreach (Renderer componentsInChild in ((Component)((Component)localRigManager).transform).GetComponentsInChildren<Renderer>(true))
			{
				if (!((Object)(object)componentsInChild != (Object)null))
				{
					continue;
				}
				componentsInChild.enabled = !hide;
				Vector3 value;
				if (hide)
				{
					if (!_originalScales.ContainsKey(((Component)componentsInChild).transform))
					{
						_originalScales[((Component)componentsInChild).transform] = ((Component)componentsInChild).transform.localScale;
					}
					((Component)componentsInChild).transform.localScale = Vector3.zero;
				}
				else if (_originalScales.TryGetValue(((Component)componentsInChild).transform, out value))
				{
					((Component)componentsInChild).transform.localScale = value;
				}
				else
				{
					((Component)componentsInChild).transform.localScale = Vector3.one;
				}
			}
		}

		public static void BeginPossession(Rigidbody target)
		{
			//IL_0032: 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)
			if (_active || (Object)(object)target == (Object)null)
			{
				return;
			}
			_possessed = target;
			_possessed.isKinematic = false;
			_possessed.WakeUp();
			_lastKnownPos = _possessed.position;
			SetPlayerAvatarVisibility(hide: true);
			FreezePlayerRig(freeze: true);
			_active = true;
			if (NetworkInfo.HasServer)
			{
				MarrowEntity componentInParent = ((Component)_possessed).GetComponentInParent<MarrowEntity>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					NetworkProp component = ((Component)componentInParent).GetComponent<NetworkProp>();
					if (component != null)
					{
						_currentEntity = component.NetworkEntity;
						if (_currentEntity != null)
						{
							NetworkEntityManager.TakeOwnership(_currentEntity);
							Main.Log.Msg("[PropHunt] Claimed Fusion network ownership of '" + ((Object)((Component)_possessed).gameObject).name + "'.");
						}
					}
				}
			}
			Main.Log.Msg("[PropHunt] Rigidly attached to '" + ((Object)((Component)_possessed).gameObject).name + "'.");
		}

		public static void EndPossession()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (_active)
			{
				if (NetworkInfo.HasServer && _currentEntity != null)
				{
					_currentEntity.RemoveOwner();
					Main.Log.Msg("[PropHunt] Released Fusion network ownership.");
					_currentEntity = null;
				}
				RigManager localRigManager = PropSelector.GetLocalRigManager();
				if ((Object)(object)localRigManager != (Object)null)
				{
					Vector3 val = (((Object)(object)_possessed != (Object)null) ? _possessed.position : _lastKnownPos);
					((Component)localRigManager).transform.position = val + Vector3.up * 1.5f;
				}
				FreezePlayerRig(freeze: false);
				SetPlayerAvatarVisibility(hide: false);
				_active = false;
				_possessed = null;
				_wantsToJump = false;
				_wantsToSnapUpright = false;
				Main.Log.Msg("[PropHunt] Depropified.");
			}
		}

		public static void TeleportPropToPlayer()
		{
			//IL_0033: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0071: Unknown result type (might be due to invalid IL or missing references)
			if (_active && !((Object)(object)_possessed == (Object)null))
			{
				Vector3 val = (((Object)(object)PropSelector.GetLocalRigManager() != (Object)null) ? ((Component)PropSelector.GetLocalRigManager()).transform.position : Vector3.zero);
				_possessed.position = val + Vector3.forward * 1.5f + Vector3.up * 0.5f;
				_possessed.velocity = Vector3.zero;
			}
		}

		public static void TeleportPropToSpawn()
		{
			//IL_0029: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			if (_active && !((Object)(object)_possessed == (Object)null))
			{
				_possessed.position = new Vector3(0f, 1f, 0f);
				_possessed.velocity = Vector3.zero;
				_possessed.angularVelocity = Vector3.zero;
				Main.Log.Msg("[PropHunt] Teleported to spawn.");
			}
		}

		public static void Tick()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!_active)
			{
				return;
			}
			if ((Object)(object)_possessed == (Object)null)
			{
				EndPossession();
				return;
			}
			_lastKnownPos = _possessed.position;
			if (NetworkInfo.HasServer && _currentEntity != null && !_currentEntity.IsOwner)
			{
				NetworkEntityManager.TakeOwnership(_currentEntity);
			}
			if (Input.GetKeyDown((KeyCode)339) || Input.GetKeyDown((KeyCode)103))
			{
				EndPossession();
				return;
			}
			if (Input.GetKeyDown((KeyCode)331) || Input.GetKeyDown((KeyCode)98))
			{
				if (Time.time - _lastBTapTime < 0.4f)
				{
					TeleportPropToSpawn();
				}
				_lastBTapTime = Time.time;
			}
			if (Input.GetKeyDown((KeyCode)32) || Input.GetButtonDown("Jump") || Input.GetKeyDown((KeyCode)330) || Input.GetKeyDown((KeyCode)344))
			{
				_wantsToJump = true;
			}
			if (Input.GetKeyDown((KeyCode)338) || Input.GetKeyDown((KeyCode)114))
			{
				_wantsToSnapUpright = true;
			}
		}

		public static void LateTick()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			if (!_active || (Object)(object)_possessed == (Object)null)
			{
				return;
			}
			RigManager localRigManager = PropSelector.GetLocalRigManager();
			if ((Object)(object)localRigManager != (Object)null)
			{
				((Component)localRigManager).transform.position = _possessed.position + Vector3.down * 2.5f;
			}
			if ((Object)(object)_camTransform == (Object)null && (Object)(object)Camera.main != (Object)null)
			{
				_camTransform = ((Component)Camera.main).transform;
			}
			if ((Object)(object)_camTransform != (Object)null)
			{
				Vector3 val = _camTransform.forward;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
				{
					val = _camTransform.up;
				}
				((Vector3)(ref val)).Normalize();
				Vector3 val2 = -val * 2.5f + Vector3.up * 1.2f;
				_camTransform.position = _possessed.position + val2;
			}
		}

		public static void FixedTick()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			if (!_active || (Object)(object)_possessed == (Object)null || _possessed.isKinematic || (NetworkInfo.HasServer && _currentEntity != null && !_currentEntity.IsOwner))
			{
				return;
			}
			if (_wantsToSnapUpright)
			{
				Rigidbody possessed = _possessed;
				Quaternion rotation = _possessed.rotation;
				possessed.MoveRotation(Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f));
				_possessed.angularVelocity = Vector3.zero;
				_wantsToSnapUpright = false;
			}
			float axis = Input.GetAxis("Horizontal");
			float axis2 = Input.GetAxis("Vertical");
			Transform val = (((Object)(object)_camTransform != (Object)null) ? _camTransform : (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : null));
			Vector3 val2 = (((Object)(object)val != (Object)null) ? val.forward : Vector3.forward);
			Vector3 val3 = (((Object)(object)val != (Object)null) ? val.right : Vector3.right);
			val2.y = 0f;
			val3.y = 0f;
			((Vector3)(ref val2)).Normalize();
			((Vector3)(ref val3)).Normalize();
			Vector3 val4 = (val2 * axis2 + val3 * axis) * 5f - _possessed.velocity;
			val4.y = 0f;
			_possessed.AddForce(val4, (ForceMode)2);
			if (_wantsToJump)
			{
				if (Time.time - _lastJumpTime > 0.2f)
				{
					_possessed.velocity = new Vector3(_possessed.velocity.x, 0f, _possessed.velocity.z);
					_possessed.AddForce(Vector3.up * 5f, (ForceMode)2);
					_lastJumpTime = Time.time;
				}
				_wantsToJump = false;
			}
		}
	}
	public static class PropSelector
	{
		private static Page _rootPage;

		private static bool _debugMode = false;

		private const float ScanRadius = 15f;

		private const int MaxResults = 15;

		private static readonly List<FunctionElement> _dynamicElements = new List<FunctionElement>();

		public static void Init()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			_rootPage = Page.Root.CreatePage("Prop Hunt", Color.cyan, 20, true);
			_rootPage.CreateFunction("Depropify (Return to Player)", Color.red, (Action)delegate
			{
				Main.Log.Msg("[PropHunt] Manual depropify requested.");
				PropifyController.EndPossession();
			});
			_rootPage.CreateFunction("TP Prop to Me", Color.yellow, (Action)delegate
			{
				if (PropifyController.IsActive)
				{
					PropifyController.TeleportPropToPlayer();
				}
			});
			_rootPage.CreateFunction("TP Prop to Spawn", Color.green, (Action)delegate
			{
				if (PropifyController.IsActive)
				{
					PropifyController.TeleportPropToSpawn();
				}
			});
			TouchPossess.Init(_rootPage);
			_rootPage.CreateBool("Debug Mode (Show Prop List)", Color.yellow, false, (Action<bool>)delegate(bool enabled)
			{
				_debugMode = enabled;
				Main.Log.Msg("[PropHunt] Debug Mode: " + (_debugMode ? "ENABLED" : "DISABLED"));
				RefreshMenu();
			});
			Menu.OnPageOpened += OnAnyPageOpened;
			RefreshMenu();
		}

		private static void OnAnyPageOpened(Page opened)
		{
			if (opened == _rootPage)
			{
				RefreshMenu();
			}
		}

		public static void RefreshMenu()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			if (_rootPage == null)
			{
				return;
			}
			ClearPropEntries();
			if (!_debugMode)
			{
				Main.Log.Msg("[PropHunt] Debug Mode is OFF. Prop list hidden.");
				return;
			}
			List<Rigidbody> list = FindNearbyProps();
			Main.Log.Msg($"[PropHunt] Debug Mode ON. RefreshMenu found {list.Count} valid props.");
			foreach (Rigidbody rb in list)
			{
				string propName = ((Object)((Component)rb).gameObject).name;
				FunctionElement item = _rootPage.CreateFunction(propName, Color.white, (Action)delegate
				{
					Main.Log.Msg("[PropHunt] Selected prop: " + propName);
					PropifyController.BeginPossession(rb);
				});
				_dynamicElements.Add(item);
			}
		}

		private static void ClearPropEntries()
		{
			foreach (FunctionElement dynamicElement in _dynamicElements)
			{
				_rootPage.Remove((Element)(object)dynamicElement);
			}
			_dynamicElements.Clear();
		}

		public static List<Rigidbody> FindNearbyProps()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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)
			Vector3 origin = GetPlayerPosition();
			List<Rigidbody> list = new List<Rigidbody>();
			RigManager localRigManager = GetLocalRigManager();
			foreach (Poolee item in Object.FindObjectsOfType<Poolee>())
			{
				if (!((Object)(object)item == (Object)null))
				{
					Rigidbody componentInChildren = ((Component)item).GetComponentInChildren<Rigidbody>();
					if (IsValidProp(componentInChildren, origin, localRigManager))
					{
						list.Add(componentInChildren);
					}
				}
			}
			foreach (InteractableHost item2 in Object.FindObjectsOfType<InteractableHost>())
			{
				if (!((Object)(object)item2 == (Object)null))
				{
					Rigidbody componentInChildren2 = ((Component)item2).GetComponentInChildren<Rigidbody>();
					if (IsValidProp(componentInChildren2, origin, localRigManager) && !list.Contains(componentInChildren2))
					{
						list.Add(componentInChildren2);
					}
				}
			}
			return (from rb in list.Distinct()
				orderby Vector3.Distance(origin, rb.position)
				select rb).Take(15).ToList();
		}

		public static bool IsValidPropPublic(Rigidbody rb, Vector3 origin, RigManager rigManager)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return IsValidProp(rb, origin, rigManager);
		}

		private static bool IsValidProp(Rigidbody rb, Vector3 origin, RigManager rigManager)
		{
			//IL_0078: 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)
			if ((Object)(object)rb == (Object)null || rb.isKinematic)
			{
				return false;
			}
			if ((Object)(object)rigManager != (Object)null && ((Component)rb).transform.IsChildOf(((Component)rigManager).transform))
			{
				return false;
			}
			string text = ((Object)((Component)rb).gameObject).name.ToLower();
			if (text.Contains("avatar") || text.Contains("head") || text.Contains("hand") || text.Contains("foot"))
			{
				return false;
			}
			return Vector3.Distance(origin, rb.position) <= 15f;
		}

		public static RigManager GetLocalRigManager()
		{
			return Player.RigManager;
		}

		public static Vector3 GetPlayerPosition()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			RigManager localRigManager = GetLocalRigManager();
			if ((Object)(object)localRigManager != (Object)null && (Object)(object)localRigManager.physicsRig != (Object)null)
			{
				return ((Component)localRigManager.physicsRig).transform.position;
			}
			Camera main = Camera.main;
			if (!((Object)(object)main != (Object)null))
			{
				return Vector3.zero;
			}
			return ((Component)main).transform.position;
		}
	}
	public static class TouchPossess
	{
		private static bool _armed;

		private const float HandTouchRadius = 0.15f;

		public static void Init(Page parentPage)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			parentPage.CreateBool("Transform to Prop (Touch)", Color.cyan, false, (Action<bool>)OnToggled);
		}

		private static void OnToggled(bool enabled)
		{
			_armed = enabled;
			Main.Log.Msg("[PropHunt] Touch-to-possess mode: " + (enabled ? "ARMED" : "off"));
		}

		public static void FixedTick()
		{
			//IL_0043: 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)
			if (_armed && !PropifyController.IsActive && !((Object)(object)PropSelector.GetLocalRigManager() == (Object)null))
			{
				Hand leftHand = Player.LeftHand;
				Hand rightHand = Player.RightHand;
				if (!TryPossessNear(((Object)(object)leftHand != (Object)null) ? new Vector3?(((Component)leftHand).transform.position) : ((Vector3?)null)))
				{
					TryPossessNear(((Object)(object)rightHand != (Object)null) ? new Vector3?(((Component)rightHand).transform.position) : ((Vector3?)null));
				}
			}
		}

		private static bool TryPossessNear(Vector3? handPos)
		{
			//IL_000d: 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)
			if (!handPos.HasValue)
			{
				return false;
			}
			Il2CppReferenceArray<Collider> obj = Physics.OverlapSphere(handPos.Value, 0.15f);
			RigManager localRigManager = PropSelector.GetLocalRigManager();
			foreach (Collider item in (Il2CppArrayBase<Collider>)(object)obj)
			{
				Rigidbody attachedRigidbody = item.attachedRigidbody;
				if (!((Object)(object)attachedRigidbody == (Object)null) && PropSelector.IsValidPropPublic(attachedRigidbody, handPos.Value, localRigManager))
				{
					Main.Log.Msg("[PropHunt] Touch-possessed '" + ((Object)((Component)attachedRigidbody).gameObject).name + "'.");
					PropifyController.BeginPossession(attachedRigidbody);
					_armed = false;
					return true;
				}
			}
			return false;
		}
	}
}