Decompiled source of Enable Movement On Focused UI v1.0.0

EnableMovementOnFocusedUI.dll

Decompiled 5 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HG.Reflection;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EnableMovementOnFocusedUI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EnableMovementOnFocusedUI")]
[assembly: AssemblyTitle("EnableMovementOnFocusedUI")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EnableMovementOnFocusedUI
{
	[Serializable]
	[BepInPlugin("com.brynzananas.enablemovementonfocusedui", "EnableMovementOnFocusedUI", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		public const string ModGuid = "com.brynzananas.enablemovementonfocusedui";

		public const string ModName = "EnableMovementOnFocusedUI";

		public const string ModVer = "1.0.0";

		public void Awake()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			PlayerCharacterMasterController.CanSendBodyInput += new Manipulator(PlayerCharacterMasterController_CanSendBodyInput);
			PlayerCharacterMasterController.PollButtonInput += new Manipulator(PlayerCharacterMasterController_PollButtonInput);
		}

		private void PlayerCharacterMasterController_PollButtonInput(ILContext il)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			ILLabel val = null;
			ILCursor val2 = new ILCursor(il);
			int num3 = default(int);
			int num2 = default(int);
			ILLabel val3 = default(ILLabel);
			int num = default(int);
			if (val2.TryGotoNext(new Func<Instruction, bool>[7]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num3),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num2),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<LocalUser>(x, "get_isUIFocused"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val3),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num)
			}))
			{
				val2.RemoveRange(7);
			}
			else
			{
				Debug.LogError((object)(((MemberReference)il.Method).Name + " IL Hook failed!"));
			}
		}

		private void PlayerCharacterMasterController_CanSendBodyInput(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel iLLabel = null;
			ILLabel iLLabel2 = null;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 3),
				(Instruction x) => ILPatternMatchingExt.MatchLdindRef(x),
				(Instruction x) => ILPatternMatchingExt.MatchCall<Object>(x, "op_Implicit"),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref iLLabel)
			}))
			{
				int index = val.Index;
				val.Index = index - 1;
				ILCursor val2 = new ILCursor(il);
				if (val2.TryGotoNext(new Func<Instruction, bool>[4]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1),
					(Instruction x) => ILPatternMatchingExt.MatchLdindRef(x),
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt<LocalUser>(x, "get_isUIFocused"),
					(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref iLLabel2)
				}))
				{
					val.Remove();
					val.Emit(OpCodes.Brtrue_S, (object)iLLabel2);
					val2.RemoveRange(4);
				}
				else
				{
					Debug.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 2 failed!"));
				}
			}
			else
			{
				Debug.LogError((object)(((MemberReference)il.Method).Name + " IL Hook 1 failed!"));
			}
		}
	}
}