Bonelab mods are targeting MelonLoader version 0.5.7. Newer versions will not work!, so double-check your MelonLoader version if you're having issues.
Decompiled source of FlatPlayer v1.0.1
Mods/FlatPlayer.dll
Decompiled 2 months agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using FlatPlayer; using HarmonyLib; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using MelonLoader; using MelonLoader.Preferences; using SLZ.Marrow.Input; using SLZ.Marrow.Utilities; using SLZ.Rig; using UnhollowerBaseLib; using Unity.XR.MockHMD; using UnityEngine; 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: MelonInfo(typeof(FlatBooter), "FlatPlayer", "1.0.0", "LlamasHere", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: AssemblyTitle("FlatPlayer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FlatPlayer")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("699efe63-5701-4dcf-aeaa-d50d57853404")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace FlatPlayer; public static class BuildInfo { public const string Name = "FlatPlayer"; public const string Author = "LlamasHere"; public const string Version = "1.0.0"; } public class FlatBooter : MelonMod { private static FlatBooter instance; private MelonPreferences_Entry<float> cameraSpeed; 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; private Vector2 cameraLastRotation = Vector2.zero; private Vector3 handsLastRotation = Vector3.zero; private Vector3 leftHandDefaultPos = new Vector3(-0.2f, -0.2f, 0.3f); private Vector3 rightHandDefaultPos = new Vector3(0.2f, -0.2f, 0.3f); private Quaternion leftHandDefaultRot = Quaternion.Euler(new Vector3(330f, 50f, 250f)); private Quaternion rightHandDefaultRot = Quaternion.Euler(new Vector3(330f, 310f, 110f)); private Quaternion leftHandAimtRot = Quaternion.Euler(new Vector3(290f, 355f, 0f)); private Quaternion rightHandAimtRot = Quaternion.Euler(new Vector3(290f, 355f, 0f)); private bool leftHandLocked = true; private bool rightHandLocked = true; private bool leftHandGrip = false; private bool righttHandGrip = false; private bool rotateMode = false; private bool aimModee = true; private Quaternion leftHandRot => aimModee ? leftHandAimtRot : leftHandDefaultRot; private Quaternion rightHandRot => aimModee ? rightHandAimtRot : rightHandDefaultRot; public override void OnInitializeMelon() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown instance = this; saveFile = MelonPreferences.CreateCategory("FlatPlayer"); cameraSpeed = saveFile.CreateEntry<float>("CameraSensitivity", 0.2f, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); Harmony val = new Harmony("FlatPlayer"); val.PatchAll(); 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"); } public override void OnLateUpdate() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 //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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00f8: 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) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0399: 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_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: 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_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: 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_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: 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_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0405: 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_0408: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_0426: 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_042e: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: 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_067b: Unknown result type (might be due to invalid IL or missing references) if (!isReady) { return; } if (Input.GetKey((KeyCode)27)) { Cursor.lockState = (CursorLockMode)0; } if (Input.GetMouseButton(0) && (int)Cursor.lockState != 1) { Cursor.lockState = (CursorLockMode)1; } if ((int)Cursor.lockState != 1) { return; } if (Input.GetKeyDown((KeyCode)43) || Input.GetKeyDown((KeyCode)61)) { MelonPreferences_Entry<float> obj = cameraSpeed; obj.Value += 0.05f; } if (Input.GetKeyDown((KeyCode)45)) { cameraSpeed.Value = Mathf.Clamp(cameraSpeed.Value - 0.05f, 0f, float.MaxValue); } Vector2 val = Vector2.zero; bool flag = false; Vector3 val2 = leftHandDefaultPos; Vector3 val3 = rightHandDefaultPos; if (Input.GetKey((KeyCode)119)) { val += Vector2.up; } if (Input.GetKey((KeyCode)97)) { val += Vector2.left; } if (Input.GetKey((KeyCode)115)) { val += Vector2.down; } if (Input.GetKey((KeyCode)100)) { val += Vector2.right; } if (Input.GetKeyDown((KeyCode)113)) { leftHandLocked = !leftHandLocked; } if (Input.GetKeyDown((KeyCode)101)) { rightHandLocked = !rightHandLocked; } if (Input.GetKey((KeyCode)102)) { if (leftHandLocked) { val2.z = 1f; } if (rightHandLocked) { val3.z = 1f; } } if (Input.GetKeyDown((KeyCode)114)) { rotateMode = !rotateMode; } if (Input.GetKeyDown((KeyCode)116)) { aimModee = !aimModee; } if (rotateMode) { handsLastRotation.z += Input.GetAxis("Mouse X") * cameraSpeed.Value; handsLastRotation.y += Input.GetAxis("Mouse Y") * cameraSpeed.Value; Quaternion val4 = Quaternion.AngleAxis(handsLastRotation.x, Vector3.up); Quaternion val5 = Quaternion.AngleAxis(handsLastRotation.y, Vector3.left); Quaternion val6 = Quaternion.AngleAxis(handsLastRotation.z, Vector3.forward); Quaternion val7 = val4 * val5 * val6; if (leftHandLocked) { ((ControllerActionMap)LeftController)._rotation = val7 * leftHandRot; } if (rightHandLocked) { ((ControllerActionMap)RightController)._rotation = val7 * rightHandRot; } } else { cameraLastRotation.x += Input.GetAxis("Mouse X") * cameraSpeed.Value; cameraLastRotation.y += Input.GetAxis("Mouse Y") * cameraSpeed.Value; cameraLastRotation.y = Mathf.Clamp(cameraLastRotation.y, -87f, 87f); Quaternion val8 = Quaternion.AngleAxis(cameraLastRotation.x, Vector3.up); Quaternion val9 = Quaternion.AngleAxis(cameraLastRotation.y, Vector3.left); Quaternion val10 = val8 * val9; XRHmd._rotation = val10; handsLastRotation = Vector2.op_Implicit(cameraLastRotation); if (leftHandLocked) { ((ControllerActionMap)LeftController)._rotation = val10 * leftHandRot; ((ControllerActionMap)LeftController)._position = val10 * val2; } if (rightHandLocked) { ((ControllerActionMap)RightController)._rotation = val10 * rightHandRot; ((ControllerActionMap)RightController)._position = val10 * val3; } } if (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) { flag = true; } if (Input.GetKeyDown((KeyCode)9)) { ((XRController)LeftController).BButton = true; ((XRController)LeftController).BButtonDown = true; } if (Input.GetKeyUp((KeyCode)9)) { ((XRController)LeftController).BButton = false; ((XRController)LeftController).BButtonUp = true; } int num = (Input.GetKey((KeyCode)275) ? 1 : 0) - (Input.GetKey((KeyCode)276) ? 1 : 0); int num2 = (Input.GetKey((KeyCode)273) ? 1 : 0) - (Input.GetKey((KeyCode)274) ? 1 : 0); ((XRController)RightController).Joystick2DAxis = new Vector2((float)num, (float)num2); if (Input.GetKey((KeyCode)32)) { ((XRController)RightController).AButton = true; ((XRController)RightController).AButtonDown = true; } if (Input.GetKeyUp((KeyCode)32)) { ((XRController)RightController).AButtonUp = true; ((XRController)RightController).AButton = false; } if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) { ((XRController)LeftController).JoystickButtonDown = true; } if (leftHandLocked) { leftHandGrip = Input.GetMouseButton(0); } if (rightHandLocked) { righttHandGrip = Input.GetMouseButton(1); } ((XRController)LeftController).Grip = (leftHandGrip ? 1 : 0); ((XRController)RightController).Grip = (righttHandGrip ? 1 : 0); ((XRController)LeftController).GripButton = leftHandGrip; ((XRController)RightController).GripButton = righttHandGrip; ((XRController)LeftController).TriggerButtonDown = leftHandLocked && flag; ((XRController)LeftController).Trigger = ((leftHandLocked && flag) ? 1 : 0); ((XRController)RightController).TriggerButtonDown = rightHandLocked && flag; ((XRController)RightController).Trigger = ((rightHandLocked && flag) ? 1 : 0); ((XRController)LeftController).Joystick2DAxis = val; } } [HarmonyPatch(typeof(OpenControllerRig))] [HarmonyPatch("OnAwake")] internal static class OpenControllerAwake { [HarmonyPrefix] private static bool Prefix(OpenControllerRig __instance) { //IL_0091: 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_00a4: 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_00b5: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0156: Unknown result type (might be due to invalid IL or missing references) if (((Object)((Component)((Component)__instance).transform.parent).gameObject).name != "[RigManager (Blank)]") { return true; } 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>(); FlatBooter.mainCamera = Camera.main; 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; ((ControllerActionMap)FlatBooter.LeftController).Refresh(); ((ControllerActionMap)FlatBooter.RightController).Refresh(); FlatBooter.isReady = true; FlatBooter.mainCamera.cameraType = (CameraType)2; FlatBooter.mainCamera.fieldOfView = 90f; return true; } } [HarmonyPatch(typeof(OpenControllerRig))] [HarmonyPatch("OnDestroy")] internal static class OpenControllerDestroy { [HarmonyPrefix] private static bool Prefix(OpenControllerRig __instance) { if (((Object)((Component)((Component)__instance).transform.parent).gameObject).name == "[RigManager (Blank)]") { FlatBooter.isReady = false; } return true; } } [HarmonyPatch(typeof(__c__DisplayClass50_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) { Debug.Log(Object.op_Implicit("Requesting Boolean Feature " + usage.name)); if (usage.name == "UserPresence") { value = true; return false; } value = __result; 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; } }