Decompiled source of TetrisMoves v2.0.7

Mods/TetrisMoves.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Poses;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using MelonLoader;
using RumbleModUI;
using TetrisMoves;
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), "TetrisMoves", "2.0.7", "ERROR", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 255, 0, 0)]
[assembly: MelonAuthorColor(255, 255, 0, 0)]
[assembly: AssemblyTitle("TetrisMoves")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TetrisMoves")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b10c94a1-8a40-4701-bc5b-98eabb44dfea")]
[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 TetrisMoves;

public static class BuildInfo
{
	public const string ModName = "TetrisMoves";

	public const string ModVersion = "2.0.7";

	public const string Description = "Allows you to only do a specific move at a time.You can only do your 'next move' like in tetris!";

	public const string Author = "ERROR";

	public const string Company = "";
}
public class main : MelonMod
{
	[HarmonyPatch(typeof(PlayerPoseSystem), "OnPoseSetCompleted", new Type[] { typeof(PoseSet) })]
	private static class PosePatch
	{
		private static void Postfix(PoseSet set)
		{
			if (Instance.modToggled && ((Object)set).name == Instance.CurrentMove)
			{
				Instance.SetRandomMoveSet();
			}
		}
	}

	private static List<string> list = new List<string>
	{
		"SprintPoseSet", "PoseSetStraight", "PoseSetKick", "PoseSetStomp", "PoseSetDash", "PoseSetParry", "PoseSetHoldLeft", "PoseSetHoldRight", "PoseSetExplode", "PoseSetFlick",
		"PoseSetUppercut"
	};

	private static main _instance;

	private Mod Mod = new Mod();

	private UI UI = UI.instance;

	private static List<string> structureMoveSetMap;

	private string CurrentMove;

	private bool modToggled;

	private ModSetting<bool> ModToggled;

	private bool includeModifiers;

	private ModSetting<bool> IncludeModifiers;

	private bool sceneChanged = false;

	private int sceneChangeCount = 0;

	private string currentScene = "Loader";

	private bool movesSettable = false;

	private static GameObject textObject;

	private static TextMeshPro textText;

	private static GameObject healthBar;

	private static readonly Vector3 textObjectTranslate = new Vector3(0f, 0.1f, 1f);

	private object checkControllerCoroutine;

	private List<PoseInputSource> storedMoves = new List<PoseInputSource>();

	public static main Instance
	{
		get
		{
			if (_instance == null)
			{
				_instance = new main();
			}
			return _instance;
		}
	}

	public main()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		_instance = this;
	}

	public override void OnLateInitializeMelon()
	{
		//IL_0050: 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_0062: Expected O, but got Unknown
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Expected O, but got Unknown
		((MelonBase)this).OnLateInitializeMelon();
		Mod.ModName = "TetrisMoves";
		Mod.ModVersion = "2.0.7";
		Mod.SetFolder("TetrisMoves");
		Mod.AddDescription("Description", "", "Allows you to only do a specific move at a time.You can only do your 'next move' like in tetris!", new Tags
		{
			IsSummary = true
		});
		ModToggled = Mod.AddToList("Toggle Mod", false, 0, "Gray box turns on mod. Default is off", new Tags());
		IncludeModifiers = Mod.AddToList("Include Modifiers?", false, 0, "Gray box toggles on if you want to include only specific modifers too", new Tags());
		Mod.GetFromFile();
		Mod.ModSaved += Saver;
		UI.instance.UI_Initialized += OnUIInit;
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		currentScene = sceneName;
		sceneChanged = true;
		movesSettable = false;
		storedMoves.Clear();
		sceneChangeCount++;
		textObject = new GameObject("Next Move");
		textText = textObject.AddComponent<TextMeshPro>();
		((TMP_Text)textText).text = "";
		foreach (TMP_FontAsset item in Resources.FindObjectsOfTypeAll<TMP_FontAsset>())
		{
			if (((Object)item).name == "GOODDP__ SDF Global Text Material")
			{
				((TMP_Text)textText).font = item;
				break;
			}
		}
		((TMP_Text)textText).fontSize = 0.5f;
		((TMP_Text)textText).color = Color.white;
		((TMP_Text)textText).alignment = (TextAlignmentOptions)514;
		((TMP_Text)textText).enableWordWrapping = false;
		((TMP_Text)textText).maxVisibleCharacters = 999;
	}

	public void OnUIInit()
	{
		UI.AddMod(Mod);
	}

	public void MapInitialized()
	{
		MelonLogger.Msg("Map Initialized: " + currentScene);
	}

	public override void OnLateUpdate()
	{
		if (modToggled && currentScene != "Loader")
		{
			if (includeModifiers)
			{
				list = new List<string> { structureMoveSetMap[0] };
			}
			else
			{
				list = new List<string>
				{
					"SprintingPoseSet",
					"PoseSetStraight",
					"PoseSetKick",
					"PoseSetStomp",
					"PoseSetDash",
					"PoseSetParry",
					"PoseSetHoldLeft",
					"PoseSetHoldRight",
					"PoseSetExplode",
					"PoseSetFlick",
					"PoseSetUppercut",
					"PoseSetRockjump",
					structureMoveSetMap[0]
				};
			}
			if (sceneChanged)
			{
				if (currentScene != "Loader")
				{
					checkControllerCoroutine = MelonCoroutines.Start(WaitForControllerAndCheckPoses(sceneChangeCount));
				}
				sceneChanged = false;
			}
			if ((Object)(object)textObject != (Object)null)
			{
				string currentMove = CurrentMove;
				((TMP_Text)textText).text = "Next Move:" + Environment.NewLine + currentMove switch
				{
					"PoseSetDisc" => "Disc", 
					"PoseSetSpawnPillar" => "Pillar", 
					"PoseSetBall" => "Ball", 
					"PoseSetWall_Grounded" => "Wall", 
					"PoseSetSpawnCube" => "Cube", 
					"SprintingPoseSet" => "Sprint", 
					"PoseSetStraight" => "Straight", 
					"PoseSetKick" => "Kick", 
					"PoseSetStomp" => "Stomp", 
					"PoseSetDash" => "Dash", 
					"PoseSetParry" => "Parry", 
					"PoseSetHoldLeft" => "Left Hold", 
					"PoseSetHoldRight" => "Right Hold", 
					"PoseSetExplode" => "Explode", 
					"PoseSetFlick" => "Flick", 
					"PoseSetUppercut" => "Uppercut", 
					"PoseSetRockjump" => "Jump", 
					_ => "Unknown Move", 
				};
			}
		}
		if (!modToggled)
		{
			list = new List<string>
			{
				"SprintingPoseSet", "PoseSetStraight", "PoseSetKick", "PoseSetStomp", "PoseSetDash", "PoseSetParry", "PoseSetHoldLeft", "PoseSetHoldRight", "PoseSetExplode", "PoseSetFlick",
				"PoseSetUppercut", "PoseSetRockjump", "PoseSetDisc", "PoseSetSpawnPillar", "PoseSetBall", "PoseSetWall_Grounded", "PoseSetSpawnCube"
			};
			if ((Object)(object)textObject != (Object)null)
			{
				((TMP_Text)textText).maxVisibleCharacters = 0;
			}
		}
		if (movesSettable)
		{
			UpdateMoves();
		}
	}

	public override void OnUpdate()
	{
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: 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)
		if (!((Object)(object)textObject != (Object)null) || !(currentScene != "Loader") || !modToggled)
		{
			return;
		}
		if ((Object)(object)healthBar == (Object)null)
		{
			healthBar = GameObject.Find("Health");
			if ((Object)(object)healthBar != (Object)null)
			{
				textObject.transform.parent = healthBar.transform.GetChild(1);
				textObject.transform.localPosition = textObjectTranslate;
			}
		}
		textObject.transform.rotation = Quaternion.LookRotation(textObject.transform.position - ((Component)Camera.main).transform.position);
	}

	public void Saver()
	{
		modToggled = (bool)((ModSetting)ModToggled).Value;
		includeModifiers = (bool)((ModSetting)IncludeModifiers).Value;
		structureMoveSetMap = null;
		if (!modToggled)
		{
			list = new List<string>
			{
				"PoseSetDisc", "PoseSetSpawnPillar", "PoseSetBall", "PoseSetWall_Grounded", "PoseSetSpawnCube", "SprintingPoseSet", "PoseSetStraight", "PoseSetKick", "PoseSetStomp", "PoseSetDash",
				"PoseSetParry", "PoseSetHoldLeft", "PoseSetHoldRight", "PoseSetExplode", "PoseSetFlick", "PoseSetUppercut", "PoseSetRockjump"
			};
		}
		UpdateMoves();
	}

	public IEnumerator WaitForControllerAndCheckPoses(int targetSceneCount)
	{
		for (int framesWaited = 0; framesWaited < 300; framesWaited++)
		{
			yield return (object)new WaitForFixedUpdate();
		}
		PlayerController playerController = null;
		while ((Object)(object)playerController == (Object)null)
		{
			yield return (object)new WaitForFixedUpdate();
			playerController = Singleton<PlayerManager>.instance.localPlayer.Controller;
		}
		bool poseSystemEnabled = false;
		while (!poseSystemEnabled)
		{
			yield return (object)new WaitForFixedUpdate();
			PlayerPoseSystem poseSystem = ((Component)((Component)playerController).gameObject.transform).GetComponentInChildren<PlayerPoseSystem>();
			if ((Object)(object)poseSystem != (Object)null)
			{
				poseSystemEnabled = ((Behaviour)poseSystem).enabled;
			}
			if (targetSceneCount != sceneChangeCount)
			{
				yield break;
			}
		}
		movesSettable = true;
		MelonCoroutines.Stop(checkControllerCoroutine);
	}

	public void SetRandomMoveSet()
	{
		if (structureMoveSetMap == null || structureMoveSetMap.Count == 0)
		{
			structureMoveSetMap = (includeModifiers ? new List<string>
			{
				"PoseSetDisc", "PoseSetSpawnPillar", "PoseSetBall", "PoseSetWall_Grounded", "PoseSetSpawnCube", "SprintingPoseSet", "PoseSetStraight", "PoseSetKick", "PoseSetStomp", "PoseSetDash",
				"PoseSetParry", "PoseSetHoldLeft", "PoseSetHoldRight", "PoseSetExplode", "PoseSetFlick", "PoseSetUppercut", "PoseSetRockjump"
			} : new List<string> { "PoseSetDisc", "PoseSetSpawnPillar", "PoseSetBall", "PoseSetWall_Grounded", "PoseSetSpawnCube" });
			structureMoveSetMap = structureMoveSetMap.OrderBy((string x) => Random.value).ToList();
		}
		list.Add(structureMoveSetMap[0]);
		structureMoveSetMap.RemoveAt(0);
	}

	public void UpdateMoves()
	{
		List<PoseInputSource> currentInputPoses = ((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform).GetComponentInChildren<PlayerPoseSystem>().currentInputPoses;
		CurrentMove = structureMoveSetMap[0];
		for (int i = 0; i < currentInputPoses.Count; i++)
		{
			bool flag = false;
			for (int j = 0; j < list.Count; j++)
			{
				if (((Object)currentInputPoses[i].poseSet).name == list[j])
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				storedMoves.Add(currentInputPoses[i]);
				currentInputPoses.RemoveAt(i);
				i--;
			}
		}
		for (int k = 0; k < storedMoves.Count; k++)
		{
			bool flag2 = false;
			for (int l = 0; l < list.Count; l++)
			{
				if (((Object)storedMoves[k].poseSet).name == list[l])
				{
					flag2 = true;
					break;
				}
			}
			if (flag2)
			{
				currentInputPoses.Add(storedMoves[k]);
				storedMoves.RemoveAt(k);
				k--;
			}
		}
	}
}