Decompiled source of LoaderSkipper v3.0.1

Mods/LoaderSkipper.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players.Scaling;
using Il2CppRUMBLE.Utilities;
using Il2CppTMPro;
using LoaderSkipper;
using MelonLoader;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(main), "LoaderSkipper", "3.0.1", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: AssemblyTitle("LoaderSkipper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LoaderSkipper")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("924f355c-9d5e-4b6d-9104-9e3d94766e61")]
[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 LoaderSkipper;

public class main : MelonMod
{
	private SceneManager sceneManager;

	private GameObject status;

	private string currentScene = "";

	private bool sceneChanged = false;

	private bool init = false;

	private string[] fileText;

	private string FILEPATH = "UserData\\LoaderSkipper";

	private string FILENAME = "OverrideLastTpose.txt";

	private static string FILEPATHLastTPose = "UserData\\LoaderSkipper\\LastTpose.txt";

	private bool tPoseSet = false;

	private static PlayerManager playerManager;

	private static Transform[] measurements = (Transform[])(object)new Transform[4];

	private GameObject head;

	private GameObject lController;

	private GameObject rController;

	private GameObject root;

	private PlayerMeasurement playerMeasurement;

	private bool measurementGot = false;

	private object coroutineObj;

	public override void OnUpdate()
	{
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		if (sceneChanged)
		{
			try
			{
				sceneManager = Singleton<SceneManager>.instance;
				status = GameObject.Find("________________SCENE_________________/Text/Measuring/TextCanvas/Status");
				playerManager = Singleton<PlayerManager>.instance;
				init = true;
				sceneChanged = false;
			}
			catch
			{
				return;
			}
			if (currentScene == "Gym")
			{
				if (measurementGot || playerManager.localPlayer == null || playerManager.localPlayer.Data == null)
				{
					return;
				}
				playerMeasurement = playerManager.localPlayer.Data.PlayerMeasurement;
				measurementGot = true;
			}
			if (!tPoseSet && currentScene == "Gym")
			{
				SetTPose();
				tPoseSet = true;
			}
		}
		if (measurementGot && (playerMeasurement.ArmSpan != playerManager.localPlayer.Data.PlayerMeasurement.ArmSpan || playerMeasurement.Length != playerManager.localPlayer.Data.PlayerMeasurement.Length))
		{
			StoreTPose();
			playerMeasurement = playerManager.localPlayer.Data.PlayerMeasurement;
		}
		if (init && currentScene == "Loader" && ((TMP_Text)status.GetComponent<TextMeshProUGUI>()).text == "Ready to RUMBLE!")
		{
			coroutineObj = MelonCoroutines.Start(StartGymLoad());
		}
	}

	public IEnumerator StartGymLoad()
	{
		for (int i = 0; i < 100; i++)
		{
			yield return (object)new WaitForFixedUpdate();
		}
		sceneManager.PerformStartupGymLoad();
		MelonCoroutines.Stop(coroutineObj);
	}

	public void SetTPose()
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Expected O, but got Unknown
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Expected O, but got Unknown
		//IL_00e4: 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_00fa: Expected O, but got Unknown
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Expected O, but got Unknown
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			fileText = File.ReadAllLines(FILEPATH + "\\" + FILENAME);
			if (fileText.Length < 12)
			{
				MelonLogger.Msg("Override not Set, Loading Last T-Pose");
				fileText = File.ReadAllLines(FILEPATHLastTPose);
			}
			else
			{
				MelonLogger.Msg("Override Found, Loading Override Measurements");
			}
			head = new GameObject();
			head.transform.position = new Vector3(float.Parse(fileText[0]), float.Parse(fileText[1]), float.Parse(fileText[2]));
			lController = new GameObject();
			lController.transform.position = new Vector3(float.Parse(fileText[3]), float.Parse(fileText[4]), float.Parse(fileText[5]));
			rController = new GameObject();
			rController.transform.position = new Vector3(float.Parse(fileText[6]), float.Parse(fileText[7]), float.Parse(fileText[8]));
			root = new GameObject();
			root.transform.position = new Vector3(float.Parse(fileText[9]), float.Parse(fileText[10]), float.Parse(fileText[11]));
			playerManager.localPlayer.Data.SetMeasurement(PlayerMeasurement.Create(head.transform, lController.transform, rController.transform, root.transform, true), true);
			playerMeasurement = playerManager.localPlayer.Data.PlayerMeasurement;
			Object.Destroy((Object)(object)head);
			Object.Destroy((Object)(object)lController);
			Object.Destroy((Object)(object)rController);
			Object.Destroy((Object)(object)root);
			MelonLogger.Msg("TPose Loaded: " + ((object)(PlayerMeasurement)(ref playerMeasurement)).ToString());
		}
		catch (Exception ex)
		{
			MelonLogger.Error("Error Setting TPose, Please T-Pose In Game: " + ex);
		}
	}

	public static void StoreTPose()
	{
		//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_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_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: 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_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_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: 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_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		measurements[0] = ((Component)playerManager.localPlayer.Controller).gameObject.transform.GetChild(1).GetChild(0).GetChild(0);
		measurements[1] = ((Component)playerManager.localPlayer.Controller).gameObject.transform.GetChild(1).GetChild(1).GetChild(0);
		measurements[2] = ((Component)playerManager.localPlayer.Controller).gameObject.transform.GetChild(1).GetChild(2).GetChild(0);
		measurements[3] = ((Component)playerManager.localPlayer.Controller).gameObject.transform.GetChild(1).GetChild(3);
		WriteToFile(new string[12]
		{
			measurements[0].position.x.ToString(),
			measurements[0].position.y.ToString(),
			measurements[0].position.z.ToString(),
			measurements[1].position.x.ToString(),
			measurements[1].position.y.ToString(),
			measurements[1].position.z.ToString(),
			measurements[2].position.x.ToString(),
			measurements[2].position.y.ToString(),
			measurements[2].position.z.ToString(),
			measurements[3].position.x.ToString(),
			(measurements[3].position.y - 0.06f).ToString(),
			measurements[3].position.z.ToString()
		}, FILEPATHLastTPose);
		MelonLogger.Msg("TPose Stored");
	}

	public override void OnLateInitializeMelon()
	{
		MelonCoroutines.Start(CheckIfFileExists(FILEPATH, FILENAME));
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		sceneChanged = true;
	}

	public static void WriteToFile(string[] text, string outputFile)
	{
		if (File.Exists(outputFile))
		{
			try
			{
				List<string> list = new List<string>();
				File.WriteAllLines(outputFile, text);
				return;
			}
			catch (Exception ex)
			{
				MelonLogger.Error((object)ex);
				return;
			}
		}
		MelonLogger.Error("File not Found: Check Game Folder for " + outputFile);
	}

	public IEnumerator CheckIfFileExists(string filePath, string fileName)
	{
		if (!File.Exists(filePath + "\\" + fileName) || !File.Exists(FILEPATHLastTPose))
		{
			if (!Directory.Exists(filePath))
			{
				MelonLogger.Msg("Folder Not Found, Creating Folder: " + filePath);
				Directory.CreateDirectory(filePath);
			}
			if (!File.Exists(filePath + "\\" + fileName))
			{
				MelonLogger.Msg("Creating File " + filePath + "\\" + fileName);
				File.Create(filePath + "\\" + fileName);
			}
			if (!File.Exists(FILEPATHLastTPose))
			{
				MelonLogger.Msg("Creating File " + FILEPATHLastTPose);
				File.Create(FILEPATHLastTPose);
			}
		}
		else
		{
			fileText = ReadFileText(filePath + "\\" + fileName);
		}
		yield return null;
	}

	public string[] ReadFileText(string inputFile)
	{
		if (File.Exists(inputFile))
		{
			try
			{
				List<string> list = new List<string>();
				return File.ReadAllLines(inputFile);
			}
			catch (Exception ex)
			{
				MelonLogger.Error((object)ex);
			}
		}
		else
		{
			MelonLogger.Error("File not Found: Check Game Folder for " + inputFile);
		}
		return null;
	}
}