Decompiled source of YawOnMouse v1.0.1

YawOnMouse.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("YawOnMouse")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+048f3fb1454b8f43ce740aef706b85490198f91b")]
[assembly: AssemblyProduct("YawOnMouse")]
[assembly: AssemblyTitle("YawOnMouse")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 YawOnMouse
{
	public enum AxisPatchType
	{
		Roll,
		NoRoll,
		Yaw
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "YawOnMouse";

		public const string PLUGIN_NAME = "YawOnMouse";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("YawOnMouse", "YawOnMouse", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static ConfigEntry<bool> Enabled;

		public static ConfigEntry<AxisPatchType> AxisPatchType;

		public static Plugin Instance;

		private void Awake()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Config", "PlayerAxisControls_Patch", true, "Enable/Disable controller roll input patch (can only be changed before startup not at runtime.)");
			AxisPatchType = ((BaseUnityPlugin)this).Config.Bind<AxisPatchType>("Config", "AxisPatchType", YawOnMouse.AxisPatchType.Yaw, "What you want the patch to do on the x-axis (can only be changed before startup not at runtime.)");
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin YawOnMouse is loaded!");
			new Harmony("YawOnMouse").PatchAll();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "YawOnMouse";

		public const string PLUGIN_NAME = "YawOnMouse";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace YawOnMouse.Patches
{
	public class PilotPlayerStatePatches
	{
		[HarmonyPatch(typeof(PilotPlayerState), "PlayerAxisControls")]
		private static class PlayerAxisControls
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				if (!Plugin.Enabled.Value)
				{
					return instructions;
				}
				if (Plugin.AxisPatchType.Value == AxisPatchType.Roll)
				{
					return instructions;
				}
				List<CodeInstruction> list = new List<CodeInstruction>(instructions);
				if (Plugin.AxisPatchType.Value == AxisPatchType.NoRoll)
				{
					return NoRoll(list);
				}
				if (Plugin.AxisPatchType.Value == AxisPatchType.Yaw)
				{
					return Yaw(list);
				}
				return list;
			}

			private static IEnumerable<CodeInstruction> Yaw(List<CodeInstruction> codes)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Expected O, but got Unknown
				return new CodeMatcher((IEnumerable<CodeInstruction>)codes, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Div, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(PilotPlayerState), "rollInput"), (string)null)
				}).Set(OpCodes.Stfld, (object)AccessTools.Field(typeof(PilotPlayerState), "yawInput")).InstructionEnumeration();
			}

			private static IEnumerable<CodeInstruction> NoRoll(List<CodeInstruction> codes)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Expected O, but got Unknown
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Expected O, but got Unknown
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Expected O, but got Unknown
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Expected O, but got Unknown
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Expected O, but got Unknown
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Expected O, but got Unknown
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Expected O, but got Unknown
				int num = 0;
				int num2 = 0;
				CodeMatcher val = new CodeMatcher((IEnumerable<CodeInstruction>)codes, (ILGenerator)null);
				val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Div, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(PilotPlayerState), "pitchInput"), (string)null)
				});
				num = val.Pos;
				val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3]
				{
					new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Div, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(PilotPlayerState), "rollInput"), (string)null)
				});
				num2 = val.Pos - 1;
				if (num >= 0 && num2 > num)
				{
					val.Start().Advance(num + 1).RemoveInstructions(num2 - num)
						.Insert((CodeInstruction[])(object)new CodeInstruction[2]
						{
							new CodeInstruction(OpCodes.Ldarg_0, (object)null),
							new CodeInstruction(OpCodes.Ldc_R4, (object)0f)
						});
				}
				return val.InstructionEnumeration();
			}
		}
	}
}