Decompiled source of Straftat Aim Fix v1.0.0

StraftatAimFix.dll

Decompiled 11 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 ComputerysModdingUtilities;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: StraftatMod(true)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StraftatAimFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+eb6a1cf1c8f1ae5f8b2ad4333f9aba8d3ec9b627")]
[assembly: AssemblyProduct("StraftatAimFix")]
[assembly: AssemblyTitle("StraftatAimFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 StraftatAimFix
{
	[BepInPlugin("Bryan_-000-.StraftatAimFix", "StraftatAimFix", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static class Info
		{
			public const string GUID = "Bryan_-000-.StraftatAimFix";

			public const string Name = "StraftatAimFix";

			public const string Version = "1.0.0";

			public const bool Debug = true;
		}

		public Harmony harmony;

		public void Awake()
		{
			harmony = Harmony.CreateAndPatchAll(((object)this).GetType(), "Bryan_-000-.StraftatAimFix");
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(FirstPersonController), "HandleMouseLook")]
		public static IEnumerable<CodeInstruction> FixCalcBugInSensitivityCode(IEnumerable<CodeInstruction> ilInstructions)
		{
			FieldInfo lookSpeedAim = AccessTools.Field(typeof(FirstPersonController), "lookSpeedAim");
			FieldInfo lookSpeedX = AccessTools.Field(typeof(FirstPersonController), "lookSpeedX");
			FieldInfo lookSpeedY = AccessTools.Field(typeof(FirstPersonController), "lookSpeedY");
			bool first = true;
			CodeInstruction[] instructions = ilInstructions.ToArray();
			for (int i = 0; i < instructions.Length; i++)
			{
				CodeInstruction instruction = instructions[i];
				if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldfld, (MemberInfo)lookSpeedX) || CodeInstructionExtensions.Is(instruction, OpCodes.Ldfld, (MemberInfo)lookSpeedY))
				{
					yield return new CodeInstruction(OpCodes.Pop, (object)null);
					yield return new CodeInstruction(OpCodes.Ldc_R4, (object)1f);
				}
				else if (instruction.opcode == OpCodes.Mul && CodeInstructionExtensions.Is(instructions[i - 1], OpCodes.Ldfld, (MemberInfo)lookSpeedAim))
				{
					yield return instruction;
					yield return new CodeInstruction(OpCodes.Ldarg, (object)0);
					yield return new CodeInstruction(OpCodes.Ldfld, (object)(first ? lookSpeedX : lookSpeedY));
					yield return new CodeInstruction(OpCodes.Mul, (object)null);
					first = false;
				}
				else
				{
					yield return instruction;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}