Decompiled source of lastmoveslist v1.0.0

Mods/LastMovesListMod.dll

Decompiled 2 years 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 RumbleModdingAPI;
using UnhollowerBaseLib;
using UnityEngine;
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.1", "Me", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[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)
		{
			if (((Object)set).name == "PoseSetSpawnPillar")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Pillar"));
			}
			if (((Object)set).name == "PoseSetBall")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Ball"));
			}
			if (((Object)set).name == "PoseSetSpawnCube")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Cube"));
			}
			if (((Object)set).name == "PoseSetWall_Grounded")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Wall"));
			}
			if (((Object)set).name == "PoseSetDisc")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Disc"));
			}
			if (((Object)set).name == "PoseSetParry")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Parry"));
			}
			if (((Object)set).name == "PoseSetFlick")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Flick"));
			}
			if (((Object)set).name == "PoseSetStomp")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Stomp"));
			}
			if (((Object)set).name == "PoseSetStraight")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Straight"));
			}
			if (((Object)set).name == "PoseSetUppercut")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Uppercut"));
			}
			if (((Object)set).name == "PoseSetKick")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Kick"));
			}
			if (((Object)set).name == "PoseSetExplode")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Explode"));
			}
			if (((Object)set).name == "PoseSetDash")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Dash"));
			}
			if (((Object)set).name == "PoseSetRockjump")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Jump"));
			}
			if (((Object)set).name == "PoseSetHoldRight")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Hold"));
			}
			if (((Object)set).name == "PoseSetHoldLeft")
			{
				insUI.GetComponent<Image>().sprite = Texture2DToSprite(images.Find((Texture2D x) => ((Object)x).name == "Hold"));
			}
		}
	}

	public GameObject playerController;

	public GameObject playerRightArm;

	public GameObject wallInsMain;

	public GameObject wallIns;

	public Stopwatch stopWatch = new Stopwatch();

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

	public GameObject ui;

	public static GameObject insUI;

	public static List<Texture2D> images;

	public override void OnInitializeMelon()
	{
		images = FileToTexture(path);
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		if (sceneName == "Gym")
		{
			stopWatch.Stop();
			stopWatch.Restart();
			stopWatch.Start();
		}
	}

	public void SetupUIParent()
	{
		//IL_0091: 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_00df: Unknown result type (might be due to invalid IL or missing references)
		ui = ((Component)Model.GetGameObject().transform.GetChild(7)).gameObject;
		insUI = Object.Instantiate<GameObject>(ui, wallIns.transform);
		Object.DontDestroyOnLoad((Object)(object)insUI);
		Object.Destroy((Object)(object)((Component)insUI.transform.GetChild(0)).gameObject);
		Object.Destroy((Object)(object)((Component)insUI.transform.GetChild(1)).gameObject);
		insUI.transform.localPosition = new Vector3(0f, 0f, 0.25f);
		insUI.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
		insUI.AddComponent<Image>();
		insUI.GetComponent<RectTransform>().sizeDelta = new Vector2(1f, 1f);
	}

	public void SetupWall()
	{
		//IL_0080: 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)
		wallInsMain = ((Component)((Component)Structures.GetPoolWall().transform.GetChild(0)).transform.GetChild(0)).gameObject;
		((Collider)wallInsMain.GetComponent<BoxCollider>()).enabled = false;
		wallIns = Object.Instantiate<GameObject>(wallInsMain, playerRightArm.transform);
		((Object)wallIns).name = "wristWall";
		wallIns.transform.localPosition = new Vector3(0f, 0.14f, 0.05f);
		wallIns.transform.localScale = new Vector3(0.12f, 0.12f, 0.1f);
		SetupUIParent();
	}

	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()
	{
		if (stopWatch.IsRunning && stopWatch.ElapsedMilliseconds >= 5000)
		{
			SetupPlayer();
			stopWatch.Stop();
		}
	}

	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 = true;
		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));
	}
}