Decompiled source of FlatPlayer v2.2.1

Mods/FlatPlayer.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using FlatPlayer;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Input;
using Il2CppSLZ.Marrow.Utilities;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using Unity.XR.MockHMD;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.XR;
using UnityEngine.XR.Management;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FlatPlayer")]
[assembly: AssemblyDescription("Play BONELAB without a VR headset (or with a 3Dof one idk) (Patch 6 Edition)")]
[assembly: AssemblyCompany("Cat boys & Dog girls \ud83c\udff3\ufe0f\u200d⚧\ufe0f")]
[assembly: AssemblyProduct("FlatPlayer")]
[assembly: AssemblyCopyright("Developed by LlamasHere")]
[assembly: AssemblyTrademark("Cat boys & Dog girls \ud83c\udff3\ufe0f\u200d⚧\ufe0f")]
[assembly: AssemblyFileVersion("2.2.1")]
[assembly: MelonInfo(typeof(FlatBooter), "FlatPlayer", "2.2.1", "LlamasHere", "https://thunderstore.io/c/bonelab/p/LlamasHere/FlatPlayer/")]
[assembly: MelonColor(255, 252, 186, 3)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("2.2.1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FlatPlayer
{
	public class FlatBooter : MelonMod
	{
		public static FlatBooter Instance;

		private MelonPreferences_Entry<float> cameraSpeed;

		private MelonPreferences_Entry<float> scrollSpeed;

		private MelonPreferences_Entry<float> smoothTurnSpeed;

		private MelonPreferences_Entry<bool> mockHmd;

		private MelonPreferences_Entry<bool> trueVR;

		private MelonPreferences_Entry<GameViewRenderMode> trueVRMode;

		private MelonPreferences_Entry<float> defaultFOV;

		private MelonPreferences_Category saveFile;

		public static HmdActionMap XRHmd;

		public static LeftControllerActionMap LeftController;

		public static RightControllerActionMap RightController;

		public static HandActionMap LeftHand;

		public static HandActionMap RightHand;

		public static Camera MainCamera;

		public static bool IsReady = false;

		private static readonly string InputFileName = "Flat Player Input.inputactions";

		private InputActionAsset actionAsset;

		private InputActionMap actionMap;

		private InputAction action_Jump;

		private InputAction action_SlowMo;

		private InputAction action_RadialMenuLeft;

		private InputAction action_RadialMenuRight;

		private InputAction action_ShootLeft;

		private InputAction action_ShootRight;

		private InputAction action_HoldItemLeft;

		private InputAction action_HoldItemRight;

		private InputAction action_ExtendArms;

		private InputAction action_Crouch;

		private InputAction action_StandUp;

		private InputAction action_Look;

		private InputAction action_Move;

		private InputAction action_ArmsEditLeft;

		private InputAction action_ArmsEditRight;

		private InputAction action_Unmount;

		private Vector2 cameraLastRotation = Vector2.zero;

		private Vector2 cameraLastRotationBackup = Vector2.zero;

		private Quaternion leftHandDef = Quaternion.Euler(new Vector3(327.5f, 353f, 0f));

		private Quaternion rightHandDef = Quaternion.Euler(new Vector3(327.5f, 7f, 0f));

		private bool leftHandIsRotate = false;

		private bool rightHandIsRotate = false;

		private Vector2 armsExtend = Vector2.zero;

		private Vector3 leftHandPos = Vector3.zero;

		private Vector3 rightHandPos = Vector3.zero;

		private Quaternion leftHandRot = Quaternion.Euler(new Vector3(327.5f, 353f, 0f));

		private Quaternion rightHandRot = Quaternion.Euler(new Vector3(327.5f, 7f, 0f));

		public override void OnInitializeMelon()
		{
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Expected O, but got Unknown
			((MelonBase)this).LoggerInstance.Msg("Booting up FlatPlayer");
			Instance = this;
			saveFile = MelonPreferences.CreateCategory("FlatPlayer");
			cameraSpeed = saveFile.CreateEntry<float>("CameraSensitivity", 72f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			scrollSpeed = saveFile.CreateEntry<float>("HandsExtendSensitivity", 0.1f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			smoothTurnSpeed = saveFile.CreateEntry<float>("CameraSmoothness", 0.3f, (string)null, "How smooth the player turns. Lerp 0..1 with 1 being asap", false, false, (ValueValidator)null, (string)null);
			defaultFOV = saveFile.CreateEntry<float>("CameraFOV", 90f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			mockHmd = saveFile.CreateEntry<bool>("UseMockHMD", true, (string)null, "In case you are 'everythingonarm' and want use a 3DOF Headset. Disables MockHMD but can still control the player", false, false, (ValueValidator)null, (string)null);
			trueVR = saveFile.CreateEntry<bool>("AccurateVR", false, (string)null, "Treat the In-Game Camera as an actual VR Camera. Useful for VR Only Effects. Applies only when UseMockHMD is enabled", false, false, (ValueValidator)null, (string)null);
			trueVRMode = saveFile.CreateEntry<GameViewRenderMode>("AccurateVRMode", (GameViewRenderMode)1, (string)null, "How to render the game when AccurateVR is enabled. None, LeftEye, RightEye, BothEyes, OcclusionMesh", false, false, (ValueValidator)null, (string)null);
			smoothTurnSpeed.Value = Math.Clamp(smoothTurnSpeed.Value, 0f, 1f);
			saveFile.SaveToFile(true);
			((MelonBase)this).LoggerInstance.Msg("Loaded and saved preferences");
			Harmony val = new Harmony("MelonLoader");
			val.PatchAll();
			if (mockHmd.Value)
			{
				List<XRLoader> loaders = XRGeneralSettings.Instance.Manager.loaders;
				MockHMDLoader val2 = ScriptableObject.CreateInstance<MockHMDLoader>();
				loaders.Clear();
				loaders.Add((XRLoader)(object)val2);
				((MelonBase)this).LoggerInstance.Msg("Kanged MockHMD");
			}
			else
			{
				((MelonBase)this).LoggerInstance.Msg("Skip MochHMD Kang but we are good to go");
			}
			InputSettings settings = InputSystem.settings;
			List<string> list = new List<string>();
			Enumerator<string> enumerator = settings.supportedDevices.GetEnumerator();
			while (enumerator.MoveNext())
			{
				string current = enumerator.Current;
				list.Add(current);
			}
			list.Add("Gamepad");
			list.Add("Mouse");
			list.Add("Keyboard");
			list.Add("Joystick");
			settings.supportedDevices = new ReadOnlyArray<string>((Il2CppArrayBase<string>)new Il2CppStringArray(list.ToArray()));
			((MelonBase)this).LoggerInstance.Msg("Added more items to the supported list of inputs: " + string.Join(", ", list));
		}

		public override void OnLateUpdate()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			if (!IsReady)
			{
				return;
			}
			if ((int)Cursor.lockState == 1)
			{
				GamepadFlow();
			}
			if (Keyboard.current == null || Mouse.current == null)
			{
				return;
			}
			if (((ButtonControl)Keyboard.current.escapeKey).wasPressedThisFrame)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
			if (Mouse.current.leftButton.wasPressedThisFrame && (int)Cursor.lockState != 1)
			{
				Cursor.lockState = (CursorLockMode)1;
				Cursor.visible = false;
			}
			if (((ButtonControl)Keyboard.current.numpadEqualsKey).isPressed || ((ButtonControl)Keyboard.current.equalsKey).isPressed)
			{
				MelonPreferences_Entry<float> obj = cameraSpeed;
				obj.Value += 0.3f;
				saveFile.SaveToFile(true);
			}
			if (((ButtonControl)Keyboard.current.minusKey).isPressed)
			{
				cameraSpeed.Value = Mathf.Clamp(cameraSpeed.Value - 0.3f, 0f, float.MaxValue);
				saveFile.SaveToFile(true);
			}
			if (((ButtonControl)Keyboard.current.enterKey).wasPressedThisFrame)
			{
				ResetPositions();
			}
			if (!((ButtonControl)Keyboard.current.jKey).wasPressedThisFrame)
			{
				return;
			}
			SetupControls();
			ReloadConfig();
			TutorialRig instance = TutorialRig.Instance;
			if (instance != null)
			{
				HeadTitles headTitles = instance.headTitles;
				if (headTitles != null)
				{
					headTitles.CUSTOMDISPLAY("Flat Player", "Controls reloaded", (Sprite)null, 0.5f, (AudioClip)null, false, (Sprite)null, (Sprite)null, (Sprite)null, (Sprite)null);
				}
			}
		}

		private void GamepadFlow()
		{
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: 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_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Unknown result type (might be due to invalid IL or missing references)
			//IL_063d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0642: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_0659: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Unknown result type (might be due to invalid IL or missing references)
			//IL_0676: Unknown result type (might be due to invalid IL or missing references)
			//IL_069f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0755: Unknown result type (might be due to invalid IL or missing references)
			//IL_075a: Unknown result type (might be due to invalid IL or missing references)
			//IL_075f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0764: Unknown result type (might be due to invalid IL or missing references)
			//IL_076e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_0786: Unknown result type (might be due to invalid IL or missing references)
			//IL_0789: Unknown result type (might be due to invalid IL or missing references)
			//IL_078e: Unknown result type (might be due to invalid IL or missing references)
			if (action_ArmsEditLeft.WasReleasedThisFrame())
			{
				leftHandIsRotate = !leftHandIsRotate;
				TutorialRig instance = TutorialRig.Instance;
				if (instance != null)
				{
					HeadTitles headTitles = instance.headTitles;
					if (headTitles != null)
					{
						headTitles.CUSTOMDISPLAY("Flat Player", (leftHandIsRotate ? "Enabled" : "Disabled") + " Left Hand Rotation", (Sprite)null, 0.5f, (AudioClip)null, false, (Sprite)null, (Sprite)null, (Sprite)null, (Sprite)null);
					}
				}
			}
			if (action_ArmsEditRight.WasReleasedThisFrame())
			{
				rightHandIsRotate = !rightHandIsRotate;
				TutorialRig instance2 = TutorialRig.Instance;
				if (instance2 != null)
				{
					HeadTitles headTitles2 = instance2.headTitles;
					if (headTitles2 != null)
					{
						headTitles2.CUSTOMDISPLAY("Flat Player", (rightHandIsRotate ? "Enabled" : "Disabled") + " Right Hand Rotation", (Sprite)null, 0.5f, (AudioClip)null, false, (Sprite)null, (Sprite)null, (Sprite)null, (Sprite)null);
					}
				}
			}
			bool flag = rightHandIsRotate || leftHandIsRotate;
			((XRController)RightController).AButton = !flag && action_Jump.IsPressed();
			((XRController)RightController).AButtonDown = !flag && action_Jump.WasPressedThisFrame();
			((XRController)RightController).AButtonUp = !flag && action_Jump.WasReleasedThisFrame();
			((XRController)LeftController).AButton = action_SlowMo.IsPressed();
			((XRController)LeftController).AButtonDown = action_SlowMo.WasPressedThisFrame();
			((XRController)LeftController).AButtonUp = action_SlowMo.WasReleasedThisFrame();
			((XRController)LeftController).BButton = action_RadialMenuLeft.IsPressed();
			((XRController)LeftController).BButtonDown = action_RadialMenuLeft.WasPressedThisFrame();
			((XRController)LeftController).BButtonUp = action_RadialMenuLeft.WasReleasedThisFrame();
			((XRController)RightController).BButton = action_RadialMenuRight.IsPressed();
			((XRController)RightController).BButtonDown = action_RadialMenuRight.WasPressedThisFrame();
			((XRController)RightController).BButtonUp = action_RadialMenuRight.WasReleasedThisFrame();
			float num = action_ShootLeft.ReadValue<float>();
			float num2 = action_ShootRight.ReadValue<float>();
			((XRController)LeftController).Grip = num;
			((XRController)LeftController).GripButton = action_ShootLeft.IsPressed();
			((XRController)LeftController).GripButtonDown = action_ShootLeft.WasPressedThisFrame();
			((XRController)LeftController).GripButtonUp = action_ShootLeft.WasReleasedThisFrame();
			((XRController)LeftController).GripForce = num;
			((XRController)RightController).Grip = num2;
			((XRController)RightController).GripButton = action_ShootRight.IsPressed();
			((XRController)RightController).GripButtonDown = action_ShootRight.WasPressedThisFrame();
			((XRController)RightController).GripButtonUp = action_ShootRight.WasReleasedThisFrame();
			((XRController)RightController).GripForce = num2;
			((XRController)LeftController).Trigger = action_HoldItemLeft.ReadValue<float>();
			((XRController)RightController).Trigger = action_HoldItemRight.ReadValue<float>();
			float num3 = action_ExtendArms.ReadValue<float>();
			if (!flag)
			{
				leftHandPos.z = Math.Clamp(leftHandPos.z + num3 * scrollSpeed.Value * Time.deltaTime, 0f, 1f);
				rightHandPos.z = Math.Clamp(rightHandPos.z + num3 * scrollSpeed.Value * Time.deltaTime, 0f, 1f);
			}
			((XRController)RightController).Joystick2DAxis = new Vector2(0f, (!flag) ? (action_StandUp.ReadValue<float>() - action_Crouch.ReadValue<float>()) : 0f);
			((XRController)RightController).JoystickButton = action_Unmount.IsPressed();
			((XRController)RightController).JoystickButtonDown = action_Unmount.WasPressedThisFrame();
			((XRController)RightController).JoystickButtonUp = action_Unmount.WasReleasedThisFrame();
			Vector2 val = action_Look.ReadValue<Vector2>();
			Quaternion val2 = XRHmd._rotation;
			if (!flag)
			{
				cameraLastRotation += val * cameraSpeed.Value * Time.deltaTime;
				cameraLastRotation.y = Mathf.Clamp(cameraLastRotation.y, -87f, 87f);
				if (mockHmd.Value)
				{
					Quaternion val3 = Quaternion.AngleAxis(cameraLastRotation.x, Vector3.up);
					Quaternion val4 = Quaternion.AngleAxis(cameraLastRotation.y, Vector3.left);
					val2 = val3 * val4;
				}
				XRHmd._rotation = val2;
				((ControllerActionMap)LeftController)._position = val2 * leftHandPos;
				((ControllerActionMap)RightController)._position = val2 * rightHandPos;
				((ControllerActionMap)LeftController)._rotation = val2 * leftHandRot;
				((ControllerActionMap)RightController)._rotation = val2 * rightHandRot;
			}
			Vector2 val5 = action_Move.ReadValue<Vector2>();
			if (!flag)
			{
				((XRController)LeftController).Joystick2DAxis = val5;
			}
			if (leftHandIsRotate)
			{
				((XRController)LeftController).Joystick2DAxis = Vector2.zero;
				leftHandPos.x += val5.x * cameraSpeed.Value / 100f * Time.deltaTime;
				leftHandPos.z += val5.y * cameraSpeed.Value / 100f * Time.deltaTime;
				leftHandPos.y += (action_Jump.ReadValue<float>() - action_Crouch.ReadValue<float>()) * cameraSpeed.Value / 100f * Time.deltaTime;
				float num4 = action_ExtendArms.ReadValue<float>();
				leftHandRot = Quaternion.Euler(((Quaternion)(ref leftHandRot)).eulerAngles + new Vector3(val.y, val.x, num4));
				((ControllerActionMap)LeftController)._position = val2 * leftHandPos;
				((ControllerActionMap)LeftController)._rotation = val2 * leftHandRot;
			}
			if (rightHandIsRotate)
			{
				rightHandPos.x += val5.x * cameraSpeed.Value / 100f * Time.deltaTime;
				rightHandPos.z += val5.y * cameraSpeed.Value / 100f * Time.deltaTime;
				rightHandPos.y += (action_Jump.ReadValue<float>() - action_Crouch.ReadValue<float>()) * cameraSpeed.Value / 100f * Time.deltaTime;
				float num5 = action_ExtendArms.ReadValue<float>();
				rightHandRot = Quaternion.Euler(((Quaternion)(ref rightHandRot)).eulerAngles + new Vector3(val.y, val.x, num5));
				((ControllerActionMap)RightController)._position = val2 * rightHandPos;
				((ControllerActionMap)RightController)._rotation = val2 * rightHandRot;
			}
		}

		public void ResetPositions()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			leftHandIsRotate = false;
			rightHandIsRotate = false;
			float num = (mockHmd.Value ? (-0.2f) : 1.2f);
			leftHandPos = new Vector3(-0.2f, num, 0.3f);
			rightHandPos = new Vector3(0.2f, num, 0.3f);
			armsExtend = new Vector2(0.3f, 0.3f);
			leftHandRot = leftHandDef;
			rightHandRot = rightHandDef;
			if ((Object)(object)TutorialRig.Instance != (Object)null && (Object)(object)TutorialRig.Instance.headTitles != (Object)null)
			{
				TutorialRig.Instance.headTitles.CUSTOMDISPLAY("Flat Player", "Hands have been reset", (Sprite)null, 0.5f, (AudioClip)null, false, (Sprite)null, (Sprite)null, (Sprite)null, (Sprite)null);
			}
		}

		public void SetupControls()
		{
			string path = Path.Combine(MelonEnvironment.UserDataDirectory, InputFileName);
			if (!File.Exists(path))
			{
				Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("FlatPlayer.Player." + InputFileName);
				FileStream fileStream = File.Create(path);
				manifestResourceStream.CopyTo(fileStream);
				fileStream.Close();
			}
			if ((Object)(object)actionAsset == (Object)null)
			{
				((MelonBase)this).LoggerInstance.Msg("Creating new Input Action Map");
				actionAsset = InputActionAsset.FromJson(File.ReadAllText(path));
			}
			else
			{
				((MelonBase)this).LoggerInstance.Msg("Reloading Input Action Map");
				actionAsset.LoadFromJson(File.ReadAllText(path));
			}
			actionMap = actionAsset.FindActionMap("Default", true);
			action_Jump = actionMap.FindAction("Jump", true);
			action_SlowMo = actionMap.FindAction("Slow Mo", true);
			action_RadialMenuLeft = actionMap.FindAction("Radial Menu Left", true);
			action_RadialMenuRight = actionMap.FindAction("Radial Menu Right", true);
			action_ShootLeft = actionMap.FindAction("Shoot Left", true);
			action_ShootRight = actionMap.FindAction("Shoot Right", true);
			action_HoldItemLeft = actionMap.FindAction("Hold Item Left", true);
			action_HoldItemRight = actionMap.FindAction("Hold Item Right", true);
			action_ExtendArms = actionMap.FindAction("Extend Arms", true);
			action_Crouch = actionMap.FindAction("Crouch", true);
			action_StandUp = actionMap.FindAction("Stand Up", true);
			action_Look = actionMap.FindAction("Look", true);
			action_Move = actionMap.FindAction("Move", true);
			action_ArmsEditLeft = actionMap.FindAction("Arm Edit Left", true);
			action_ArmsEditRight = actionMap.FindAction("Arm Edit Right", true);
			action_Unmount = actionMap.FindAction("Unmount", true);
			actionAsset.Enable();
			actionMap.Enable();
		}

		public void ReloadConfig()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			saveFile.LoadFromFile(true);
			smoothTurnSpeed.Value = Math.Clamp(smoothTurnSpeed.Value, 0f, 1f);
			if (mockHmd.Value)
			{
				MainCamera.cameraType = (CameraType)2;
				MainCamera.fieldOfView = defaultFOV.Value;
				if (trueVR.Value)
				{
					MainCamera.cameraType = (CameraType)8;
					XRSettings.gameViewRenderMode = trueVRMode.Value;
				}
			}
		}
	}
	[HarmonyPatch(typeof(OpenControllerRig))]
	[HarmonyPatch("OnMarrowReady")]
	internal static class RigManagerStart
	{
		[HarmonyPostfix]
		private static void Postfix(OpenControllerRig __instance)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_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_010a: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: 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)
			Camera main = Camera.main;
			if (!((Object)(object)((Component)__instance).transform.root != (Object)(object)((Component)main).transform.root))
			{
				((MelonBase)FlatBooter.Instance).LoggerInstance.Msg("Stealing virtual controllers to manipulate in nefarious ways. Triggered by " + ((Object)((Component)__instance).transform.root).name);
				FlatBooter.MainCamera = main;
				FlatBooter.Instance.ReloadConfig();
				XRApi xr = MarrowGame.xr;
				FlatBooter.XRHmd = ((Il2CppObjectBase)xr.HMD).Cast<HmdActionMap>();
				FlatBooter.LeftController = ((Il2CppObjectBase)xr.LeftController).Cast<LeftControllerActionMap>();
				FlatBooter.RightController = ((Il2CppObjectBase)xr.RightController).Cast<RightControllerActionMap>();
				FlatBooter.LeftHand = ((Il2CppObjectBase)xr.LeftHand).Cast<HandActionMap>();
				FlatBooter.RightHand = ((Il2CppObjectBase)xr.RightHand).Cast<HandActionMap>();
				InputDevice xrDevice = ((XRDevice)FlatBooter.LeftController)._xrDevice;
				xrDevice.m_Initialized = true;
				((XRDevice)FlatBooter.LeftController)._xrDevice = xrDevice;
				xrDevice = ((XRDevice)FlatBooter.RightController)._xrDevice;
				xrDevice.m_Initialized = true;
				((XRDevice)FlatBooter.RightController)._xrDevice = xrDevice;
				InputDeviceCharacteristics val = (InputDeviceCharacteristics)96;
				((XRDevice)FlatBooter.LeftController)._Characteristics_k__BackingField = (InputDeviceCharacteristics)(val | 0x100);
				((XRDevice)FlatBooter.RightController)._Characteristics_k__BackingField = (InputDeviceCharacteristics)(val | 0x200);
				((XRController)FlatBooter.LeftController).Type = (XRControllerType)0;
				((XRController)FlatBooter.RightController).Type = (XRControllerType)0;
				((XRDevice)FlatBooter.LeftController)._IsConnected_k__BackingField = true;
				((XRDevice)FlatBooter.RightController)._IsConnected_k__BackingField = true;
				((ControllerActionMap)FlatBooter.LeftController)._position = Vector3.zero;
				((ControllerActionMap)FlatBooter.RightController)._position = Vector3.zero;
				((ControllerActionMap)FlatBooter.LeftController)._rotation = Quaternion.identity;
				((ControllerActionMap)FlatBooter.RightController)._rotation = Quaternion.identity;
				((XRDevice)FlatBooter.LeftController).Refresh();
				((XRDevice)FlatBooter.RightController).Refresh();
				FlatBooter.Instance.SetupControls();
				FlatBooter.Instance.ResetPositions();
				FlatBooter.IsReady = true;
			}
		}
	}
	[HarmonyPatch(typeof(RigManager))]
	[HarmonyPatch("OnDestroy")]
	internal static class OpenControllerDestroy
	{
		[HarmonyPrefix]
		private static bool Prefix(RigManager __instance)
		{
			Camera main = Camera.main;
			if ((Object)(object)main != (Object)null && (Object)(object)((Component)__instance).transform.root != (Object)(object)((Component)main).transform.root)
			{
				return true;
			}
			FlatBooter.IsReady = false;
			return true;
		}
	}
	[HarmonyPatch(typeof(__c__DisplayClass60_0))]
	[HarmonyPatch("_InitializeXRLoader_b__0")]
	internal static class XRApi_InitializeXRLoader
	{
		[HarmonyPrefix]
		private static bool Prefix(ref bool __result)
		{
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(InputDevice))]
	[HarmonyPatch("TryGetFeatureValue")]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal static class XRDevice_IsPresent
	{
		[HarmonyPrefix]
		private static bool Prefix(InputFeatureUsage<bool> usage, out bool value, ref bool __result)
		{
			value = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(XRDevice))]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal static class XRDevice_IsTracking
	{
		[HarmonyPrefix]
		private static bool Prefix(ref bool __result)
		{
			__result = true;
			return false;
		}
	}
	public static class BuildInfo
	{
		internal const string Name = "FlatPlayer";

		internal const string Description = "Play BONELAB without a VR headset (or with a 3Dof one idk) (Patch 6 Edition)";

		internal const string Author = "LlamasHere";

		internal const string Company = "Cat boys & Dog girls \ud83c\udff3\ufe0f\u200d⚧\ufe0f";

		internal const string Version = "2.2.1";

		internal const string DownloadLink = "https://thunderstore.io/c/bonelab/p/LlamasHere/FlatPlayer/";
	}
}