Decompiled source of MoveRestrictor v2.1.1

Mods/MoveRestrictor.dll

Decompiled a month ago
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Poses;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MoveRestrictor;
using RumbleModUI;
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), "MoveRestrictor", "2.1.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("MoveRestrictor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoveRestrictor")]
[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 MoveRestrictor;

public class main : MelonMod
{
	private bool sceneChanged = false;

	private string currentScene = "Loader";

	private int sceneChangeCount = 0;

	private UI UI = UI.instance;

	public static Mod MoveRestrictor = new Mod();

	private bool movesSettable = false;

	private static bool timeToReadFile = true;

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

	private bool twitchModFound = false;

	public override void OnLateInitializeMelon()
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Expected O, but got Unknown
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Expected O, but got Unknown
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Expected O, but got Unknown
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Expected O, but got Unknown
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Expected O, but got Unknown
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Expected O, but got Unknown
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Expected O, but got Unknown
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Expected O, but got Unknown
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Expected O, but got Unknown
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Expected O, but got Unknown
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Expected O, but got Unknown
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Expected O, but got Unknown
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Expected O, but got Unknown
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Expected O, but got Unknown
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Expected O, but got Unknown
		MoveRestrictor.ModName = "MoveRestrictor";
		MoveRestrictor.ModVersion = "2.1.1";
		MoveRestrictor.SetFolder("MoveRestrictor");
		MoveRestrictor.AddDescription("Description", "Description", "Disables Specific Moves", new Tags
		{
			IsSummary = true
		});
		MoveRestrictor.AddToList("Sprint", true, 0, "Grey Box Turns Off Sprint", new Tags());
		MoveRestrictor.AddToList("Disc", true, 0, "Grey Box Turns Off Disc", new Tags());
		MoveRestrictor.AddToList("Pillar", true, 0, "Grey Box Turns Off Pillar", new Tags());
		MoveRestrictor.AddToList("Straight", true, 0, "Grey Box Turns Off Straight", new Tags());
		MoveRestrictor.AddToList("Ball", true, 0, "Grey Box Turns Off Ball", new Tags());
		MoveRestrictor.AddToList("Kick", true, 0, "Grey Box Turns Off Kick", new Tags());
		MoveRestrictor.AddToList("Stomp", true, 0, "Grey Box Turns Off Stomp", new Tags());
		MoveRestrictor.AddToList("Wall", true, 0, "Grey Box Turns Off Wall", new Tags());
		MoveRestrictor.AddToList("Jump", true, 0, "Grey Turns Off Jump", new Tags());
		MoveRestrictor.AddToList("Uppercut", true, 0, "Grey Box Turns Off Uppercut", new Tags());
		MoveRestrictor.AddToList("Cube", true, 0, "Grey Box Turns Off Cube", new Tags());
		MoveRestrictor.AddToList("Dash", true, 0, "Grey Box Turns Off Dash", new Tags());
		MoveRestrictor.AddToList("Parry", true, 0, "Grey Box Turns Off Parry", new Tags());
		MoveRestrictor.AddToList("Hold Left", true, 0, "Grey Box Turns Off Left Hand Hold", new Tags());
		MoveRestrictor.AddToList("Hold Right", true, 0, "Grey Box Turns Off Right Hand Hold", new Tags());
		MoveRestrictor.AddToList("Explode", true, 0, "Grey Box Turns Off Explode", new Tags());
		MoveRestrictor.AddToList("Flick", true, 0, "Grey Box Turns Off Flick", new Tags());
		MoveRestrictor.GetFromFile();
		MoveRestrictor.ModSaved += Save;
		UI.instance.UI_Initialized += UIInit;
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		sceneChanged = true;
		movesSettable = false;
		storedMoves.Clear();
		sceneChangeCount++;
	}

	public override void OnFixedUpdate()
	{
		if (sceneChanged)
		{
			if (twitchModFound)
			{
				return;
			}
			if (currentScene != "Loader")
			{
				MelonCoroutines.Start(WaitThenCheckPoses(sceneChangeCount));
			}
			else
			{
				MelonCoroutines.Start(LookForTwitchMod());
			}
			sceneChanged = false;
		}
		if (movesSettable && timeToReadFile)
		{
			Save();
		}
	}

	public void UIInit()
	{
		UI.AddMod(MoveRestrictor);
	}

	public static void Save()
	{
		timeToReadFile = false;
		ChangeAvailableMoveSets();
	}

	private IEnumerator LookForTwitchMod()
	{
		foreach (MelonMod registeredMelon in MelonBase.RegisteredMelons)
		{
			MelonMod mod = registeredMelon;
			if (((MelonBase)mod).Info.Name == "MoveRestrictorTwitchIntegration")
			{
				twitchModFound = true;
				MelonLogger.Msg("Mod Found");
				yield break;
			}
		}
	}

	public IEnumerator WaitThenCheckPoses(int sceneCount)
	{
		yield return (object)new WaitForSeconds(6f);
		while ((Object)(object)Singleton<PlayerManager>.instance.localPlayer.Controller == (Object)null)
		{
			yield return (object)new WaitForFixedUpdate();
		}
		bool enabled = ((Behaviour)((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform).GetComponentInChildren<PlayerPoseSystem>()).enabled;
		while (!enabled && sceneCount == sceneChangeCount)
		{
			enabled = ((Behaviour)((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform).GetComponentInChildren<PlayerPoseSystem>()).enabled;
			yield return (object)new WaitForFixedUpdate();
		}
		if (enabled)
		{
			movesSettable = true;
		}
		MoveRestrictor.GetFromFile();
		timeToReadFile = true;
	}

	public static void ChangeAvailableMoveSets()
	{
		List<string> list = new List<string>();
		for (int i = 1; i < MoveRestrictor.Settings.Count; i++)
		{
			if ((bool)MoveRestrictor.Settings[i].SavedValue)
			{
				switch (i)
				{
				case 1:
					list.Add("SprintingPoseSet");
					break;
				case 2:
					list.Add("PoseSetDisc");
					break;
				case 3:
					list.Add("PoseSetSpawnPillar");
					break;
				case 4:
					list.Add("PoseSetStraight");
					break;
				case 5:
					list.Add("PoseSetBall");
					break;
				case 6:
					list.Add("PoseSetKick");
					break;
				case 7:
					list.Add("PoseSetStomp");
					break;
				case 8:
					list.Add("PoseSetWall_Grounded");
					break;
				case 9:
					list.Add("PoseSetRockjump");
					break;
				case 10:
					list.Add("PoseSetUppercut");
					break;
				case 11:
					list.Add("PoseSetSpawnCube");
					break;
				case 12:
					list.Add("PoseSetDash");
					break;
				case 13:
					list.Add("PoseSetParry");
					break;
				case 14:
					list.Add("PoseSetHoldLeft");
					break;
				case 15:
					list.Add("PoseSetHoldRight");
					break;
				case 16:
					list.Add("PoseSetExplode");
					break;
				case 17:
					list.Add("PoseSetFlick");
					break;
				}
			}
		}
		List<PoseInputSource> currentInputPoses = ((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform).GetComponentInChildren<PlayerPoseSystem>().currentInputPoses;
		string text = "";
		for (int j = 0; j < currentInputPoses.Count; j++)
		{
			bool flag = false;
			for (int k = 0; k < list.Count; k++)
			{
				if (((Object)currentInputPoses[j].poseSet).name == list[k])
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				if (text != "")
				{
					text += ", ";
				}
				text += ((Object)currentInputPoses[j].poseSet).name;
				storedMoves.Add(currentInputPoses[j]);
				currentInputPoses.RemoveAt(j);
				j--;
			}
		}
		if (text != "")
		{
			MelonLogger.Msg("Poses Removed: " + text);
		}
		text = "";
		for (int l = 0; l < storedMoves.Count; l++)
		{
			bool flag2 = false;
			for (int m = 0; m < list.Count; m++)
			{
				if (((Object)storedMoves[l].poseSet).name == list[m])
				{
					flag2 = true;
					break;
				}
			}
			if (flag2)
			{
				if (text != "")
				{
					text += ", ";
				}
				text += ((Object)storedMoves[l].poseSet).name;
				currentInputPoses.Add(storedMoves[l]);
				storedMoves.RemoveAt(l);
				l--;
			}
		}
		if (text != "")
		{
			MelonLogger.Msg("Poses Added: " + text);
		}
	}
}