Decompiled source of MoveRestrictor v2.2.2

Mods/MoveRestrictor.dll

Decompiled 2 weeks ago
using System;
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.2.2", "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
{
	[CompilerGenerated]
	private sealed class <LookForTwitchMod>d__14 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public main <>4__this;

		private IEnumerator<MelonBase> <>s__1;

		private MelonMod <mod>5__2;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <LookForTwitchMod>d__14(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>s__1 = null;
			<mod>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			if (<>1__state != 0)
			{
				return false;
			}
			<>1__state = -1;
			<>s__1 = MelonBase.RegisteredMelons.GetEnumerator();
			try
			{
				while (<>s__1.MoveNext())
				{
					<mod>5__2 = (MelonMod)<>s__1.Current;
					if (((MelonBase)<mod>5__2).Info.Name == "MoveRestrictorTwitchIntegration")
					{
						<>4__this.twitchModFound = true;
						MelonLogger.Msg("Mod Found");
						return false;
					}
					<mod>5__2 = null;
				}
			}
			finally
			{
				if (<>s__1 != null)
				{
					<>s__1.Dispose();
				}
			}
			<>s__1 = null;
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <WaitThenCheckPoses>d__15 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public int sceneCount;

		public main <>4__this;

		private bool <enabled>5__1;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <WaitThenCheckPoses>d__15(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(6f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				goto IL_0073;
			case 2:
				<>1__state = -1;
				goto IL_0073;
			case 3:
				{
					<>1__state = -1;
					break;
				}
				IL_0073:
				if ((Object)(object)Singleton<PlayerManager>.instance.localPlayer.Controller == (Object)null)
				{
					<>2__current = (object)new WaitForFixedUpdate();
					<>1__state = 2;
					return true;
				}
				<enabled>5__1 = ((Behaviour)((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform).GetComponentInChildren<PlayerPoseSystem>()).enabled;
				break;
			}
			if (!<enabled>5__1 && sceneCount == <>4__this.sceneChangeCount)
			{
				<enabled>5__1 = ((Behaviour)((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform).GetComponentInChildren<PlayerPoseSystem>()).enabled;
				<>2__current = (object)new WaitForFixedUpdate();
				<>1__state = 3;
				return true;
			}
			if (<enabled>5__1)
			{
				<>4__this.movesSettable = true;
			}
			MoveRestrictor.GetFromFile();
			timeToReadFile = true;
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	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.2.2";
		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();
	}

	[IteratorStateMachine(typeof(<LookForTwitchMod>d__14))]
	private IEnumerator LookForTwitchMod()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <LookForTwitchMod>d__14(0)
		{
			<>4__this = this
		};
	}

	[IteratorStateMachine(typeof(<WaitThenCheckPoses>d__15))]
	public IEnumerator WaitThenCheckPoses(int sceneCount)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <WaitThenCheckPoses>d__15(0)
		{
			<>4__this = this,
			sceneCount = sceneCount
		};
	}

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