Decompiled source of LastMovesList v1.0.6

Mods/LastMovesListMod.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using LastMovesListMod;
using MelonLoader;
using RUMBLE.Players.Subsystems;
using RUMBLE.Poses;
using RumbleModUI;
using RumbleModdingAPI;
using UnhollowerBaseLib;
using UnityEngine;
using UnityEngine.InputSystem;
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: MelonInfo(typeof(LMLClass), "LastMoveslist", "1.0.6", "CactusGod", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(ConsoleColor.Red)]
[assembly: AssemblyTitle("LastMovesListMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LastMovesListMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("313c2611-9dd1-49fe-911c-7b1199662b22")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LastMovesListMod;

public class LMLClass : MelonMod
{
	[HarmonyPatch(typeof(PlayerPoseSystem), "OnPoseSetCompleted", new Type[] { typeof(PoseSet) })]
	private static class PosePatch
	{
		private static void Postfix(PoseSet set)
		{
			switch (((Object)set).name)
			{
			case "PoseSetSpawnPillar":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Pillar")));
				break;
			case "PoseSetBall":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Ball")));
				break;
			case "PoseSetSpawnCube":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Cube")));
				break;
			case "PoseSetWall_Grounded":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Wall")));
				break;
			case "PoseSetDisc":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Disc")));
				break;
			case "PoseSetParry":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Parry")));
				break;
			case "PoseSetFlick":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Flick")));
				break;
			case "PoseSetStomp":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Stomp")));
				break;
			case "PoseSetStraight":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Straight")));
				break;
			case "PoseSetUppercut":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Uppercut")));
				break;
			case "PoseSetKick":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Kick")));
				break;
			case "PoseSetExplode":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Explode")));
				break;
			case "PoseSetDash":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Dash")));
				break;
			case "PoseSetRockjump":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Jump")));
				break;
			case "PoseSetHoldRight":
			case "PoseSetHoldLeft":
				AddSprite(Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Hold")));
				break;
			}
		}
	}

	public GameObject playerController;

	public GameObject playerRightArm;

	public GameObject wallInsMain;

	public GameObject wallIns;

	public static GameObject ui = new GameObject();

	public Stopwatch stopWatch = new Stopwatch();

	public string picsPath = "UserData\\LastMovesList\\StruPics";

	public static List<Texture2D> images;

	public bool WBOOLNAME;

	public static List<Sprite> spriteList = new List<Sprite>();

	public static int maxSprites = 5;

	public static Image[] imageComponents = (Image[])(object)new Image[5];

	public UI modingUI = UI.instance;

	public Mod modRef = new Mod();

	public ModSetting<bool> onOrOff;

	public bool runMod;

	public static InputActionMap map = new InputActionMap("Rest Xr Map");

	public static InputAction rightThumbstick = InputActionSetupExtensions.AddAction(map, "Right Joysitck Click", (InputActionType)1, "<XRController>{RightHand}/thumbstickClick", (string)null, (string)null, (string)null, (string)null);

	public static InputAction leftThumbstick = InputActionSetupExtensions.AddAction(map, "Left Joystick Click", (InputActionType)1, "<XRController>{LeftHand}/thumbstickClick", (string)null, (string)null, (string)null, (string)null);

	public static float clickCounter = 0f;

	public static float neededClicks = 2f;

	public static float stopAtClicks = 0f;

	public static Stopwatch clickStopwatch = new Stopwatch();

	public override void OnLateInitializeMelon()
	{
		images = FileToTexture(picsPath);
		modRef.ModName = "LastMovesList";
		modRef.ModVersion = "1.0.6";
		modRef.SetFolder("LastMovesList");
		modRef.AddToList("Description", (AvailableTypes)0, "", "Toggle the Bool on or off to enable and disable the mod.");
		onOrOff = modRef.AddToList("On or off", true, 0, "");
		modRef.GetFromFile();
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		if (sceneName != "Loader" && runMod)
		{
			map.Enable();
			stopWatch.Stop();
			stopWatch.Restart();
			stopWatch.Start();
		}
	}

	public void SetupUI()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Expected O, but got Unknown
		//IL_00d5: 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_0110: 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_0121: Expected O, but got Unknown
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: 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_01b2: Expected O, but got Unknown
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Expected O, but got Unknown
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Expected O, but got Unknown
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: 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)
		ui = new GameObject();
		ui.transform.parent = wallIns.transform;
		((Object)ui).name = "UI";
		ui.SetActive(true);
		ui.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
		ui.transform.localPosition = new Vector3(0f, 0f, 0.265f);
		GameObject val = new GameObject();
		((Object)val).name = "image1";
		val.transform.parent = ui.transform;
		val.AddComponent<Image>();
		val.AddComponent<Canvas>();
		val.transform.localPosition = new Vector3(0f, 0.1f, 0f);
		val.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
		val.GetComponent<RectTransform>().sizeDelta = new Vector2(0.05f, 0.05f);
		GameObject val2 = new GameObject();
		((Object)val2).name = "image2";
		val2.transform.parent = ui.transform;
		val2.AddComponent<Image>();
		val2.AddComponent<Canvas>();
		val2.transform.localPosition = new Vector3(0f, 0.05f, 0f);
		val2.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
		val2.GetComponent<RectTransform>().sizeDelta = new Vector2(0.05f, 0.05f);
		GameObject val3 = new GameObject();
		((Object)val3).name = "image3";
		val3.transform.parent = ui.transform;
		val3.AddComponent<Image>();
		val3.AddComponent<Canvas>();
		val3.transform.localPosition = new Vector3(0f, 0f, 0f);
		val3.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
		val3.GetComponent<RectTransform>().sizeDelta = new Vector2(0.05f, 0.05f);
		GameObject val4 = new GameObject();
		((Object)val4).name = "image4";
		val4.transform.parent = ui.transform;
		val4.AddComponent<Image>();
		val4.AddComponent<Canvas>();
		val4.transform.localPosition = new Vector3(0f, -0.05f, 0f);
		val4.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
		val4.GetComponent<RectTransform>().sizeDelta = new Vector2(0.05f, 0.05f);
		GameObject val5 = new GameObject();
		((Object)val5).name = "image5";
		val5.transform.parent = ui.transform;
		val5.AddComponent<Image>();
		val5.AddComponent<Canvas>();
		val5.transform.localPosition = new Vector3(0f, -0.1f, 0f);
		val5.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
		val5.GetComponent<RectTransform>().sizeDelta = new Vector2(0.05f, 0.05f);
		imageComponents[0] = val.GetComponent<Image>();
		imageComponents[1] = val2.GetComponent<Image>();
		imageComponents[2] = val3.GetComponent<Image>();
		imageComponents[3] = val4.GetComponent<Image>();
		imageComponents[4] = val5.GetComponent<Image>();
	}

	public void SetupWall()
	{
		//IL_007f: 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)
		wallInsMain = ((Component)((Component)Structures.GetPoolWall().transform.GetChild(0)).transform.GetChild(0)).gameObject;
		wallIns = Object.Instantiate<GameObject>(wallInsMain, playerRightArm.transform);
		Object.Destroy((Object)(object)wallIns.GetComponent<BoxCollider>());
		((Object)wallIns).name = "wristWall";
		wallIns.transform.localPosition = new Vector3(0f, 0.12f, 0.06f);
		wallIns.transform.localScale = new Vector3(0.12f, 0.12f, 0.1f);
		SetupUI();
	}

	public void SetupPlayer()
	{
		playerController = ((Component)Managers.GetPlayerManager().localPlayer.Controller).gameObject;
		playerRightArm = ((Component)((Component)((Component)((Component)((Component)((Component)((Component)((Component)playerController.transform.GetChild(5)).transform.GetChild(7)).transform.GetChild(0)).transform.GetChild(2)).transform.GetChild(0)).transform.GetChild(2)).transform.GetChild(0)).transform.GetChild(0)).gameObject;
		SetupWall();
	}

	public override void OnLateUpdate()
	{
		float num = rightThumbstick.ReadValue<float>();
		float num2 = leftThumbstick.ReadValue<float>();
		if ((num == 1f && stopAtClicks != 2f) || (num2 == 1f && stopAtClicks != 2f))
		{
			clickCounter += 1f;
			stopAtClicks += 1f;
			clickStopwatch.Stop();
			clickStopwatch.Restart();
			clickStopwatch.Start();
		}
		if (stopWatch.IsRunning && stopWatch.ElapsedMilliseconds == 3000 && (num != 1f || num2 != 1f))
		{
			clickCounter = 0f;
			clickStopwatch.Stop();
		}
		if ((clickCounter <= neededClicks && num == 1f) || (clickCounter <= neededClicks && num2 == 1f))
		{
			imageComponents[0].sprite = null;
			imageComponents[1].sprite = null;
			imageComponents[2].sprite = null;
			imageComponents[3].sprite = null;
			imageComponents[4].sprite = null;
			spriteList.Clear();
			clickCounter = 0f;
		}
		if (stopWatch.IsRunning && stopWatch.ElapsedMilliseconds >= 5000)
		{
			SetupPlayer();
			stopWatch.Stop();
		}
		if (modingUI.GetInit() && !modRef.GetUIStatus())
		{
			modingUI.AddMod(modRef);
		}
		if (modRef.GetSaveStatus())
		{
			modRef.ConfirmSave();
			if (((ModSetting)onOrOff).GetValueAsString() == "true")
			{
				MelonLogger.Msg("on!");
				runMod = true;
			}
			else if (((ModSetting)onOrOff).GetValueAsString() == "false")
			{
				runMod = false;
				MelonLogger.Msg("off!");
			}
		}
	}

	public static void AddSprite(Sprite newSprite)
	{
		spriteList.Insert(0, newSprite);
		if (spriteList.Count >= maxSprites)
		{
			spriteList.RemoveAt(5);
		}
		UpdateImages();
	}

	private static void UpdateImages()
	{
		for (int i = 0; i < imageComponents.Length; i++)
		{
			if (i < spriteList.Count)
			{
				imageComponents[i].sprite = spriteList[i];
				((Behaviour)imageComponents[i]).enabled = true;
			}
			else
			{
				((Behaviour)imageComponents[i]).enabled = false;
			}
		}
	}

	private List<Texture2D> FileToTexture(string path)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		bool flag = false;
		string[] files = Directory.GetFiles(path);
		List<Texture2D> list = new List<Texture2D>();
		string[] array = files;
		foreach (string text in array)
		{
			list.Add(new Texture2D(2, 2));
			byte[] array2 = File.ReadAllBytes(text);
			ImageConversion.LoadImage(list.Last(), Il2CppStructArray<byte>.op_Implicit(array2));
			((Object)list.Last()).name = text.Split(new char[1] { '\\' }).Last().Split(new char[1] { '.' })[0];
			((Object)list.Last()).hideFlags = (HideFlags)61;
			if (flag)
			{
				MelonLogger.Msg("Image Imported: " + ((Object)list.Last()).name);
			}
		}
		return list;
	}

	private static Sprite Texture2DToSprite(Texture2D Input, bool DoBorders = false, float border = 20f)
	{
		//IL_0003: 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_0042: 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_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: 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_006e: Unknown result type (might be due to invalid IL or missing references)
		Rect val = default(Rect);
		((Rect)(ref val)).x = 0f;
		((Rect)(ref val)).y = 0f;
		((Rect)(ref val)).width = ((Texture)Input).width;
		((Rect)(ref val)).height = ((Texture)Input).height;
		Rect val2 = val;
		if (DoBorders)
		{
			Vector4 val3 = default(Vector4);
			((Vector4)(ref val3))..ctor(border, border, border, border);
			return Sprite.Create(Input, val2, new Vector2(0f, 0f), (float)((Texture)Input).width, 0u, (SpriteMeshType)0, val3);
		}
		return Sprite.Create(Input, val2, new Vector2(0f, 0f));
	}
}