Decompiled source of SeekerOmniSojourn v0.1.0

BepInEx\plugins\SeekerOmniSojourn\SojournOmniAimRelative.dll

Decompiled 9 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SojournOmniAimRelative")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SojournOmniAimRelative")]
[assembly: AssemblyTitle("SojournOmniAimRelative")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 SojournOmniAimRelative
{
	[BepInPlugin("localfix.sojourn.omni.aimrelative", "Sojourn Omnidirectional - Aim Relative", "0.1.0")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "localfix.sojourn.omni.aimrelative";

		public const string PluginName = "Sojourn Omnidirectional - Aim Relative";

		public const string PluginVersion = "0.1.0";

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("localfix.sojourn.omni.aimrelative").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Sojourn Omnidirectional - Aim Relative 0.1.0 loaded.");
		}
	}
	[HarmonyPatch(typeof(SojournVehicleBase), "FixedUpdateMovement")]
	internal static class SojournVehiclePatch
	{
		private const float InputDeadzone = 0.05f;

		private const float TinyVector = 0.0001f;

		[HarmonyPostfix]
		private static void FixedUpdateMovement_Postfix(SojournVehicleBase __instance, VehicleSeat ___vehicleSeat, Rigidbody ___vehicleRigidbody, float ___currentSpeed)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)___vehicleSeat == (Object)null || (Object)(object)___vehicleRigidbody == (Object)null)
			{
				return;
			}
			InputBankTest currentPassengerInputBank = ___vehicleSeat.currentPassengerInputBank;
			if ((Object)(object)currentPassengerInputBank == (Object)null)
			{
				return;
			}
			Vector3 moveVector = currentPassengerInputBank.moveVector;
			moveVector.y = 0f;
			if (((Vector3)(ref moveVector)).sqrMagnitude <= 0.0025000002f)
			{
				___vehicleRigidbody.velocity = Vector3.zero;
				return;
			}
			Vector3 val = currentPassengerInputBank.aimDirection;
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = ((Component)___vehicleRigidbody).transform.forward;
			}
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				___vehicleRigidbody.velocity = Vector3.zero;
				return;
			}
			((Vector3)(ref val)).Normalize();
			Vector3 val2 = val;
			val2.y = 0f;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f)
			{
				val2 = ((Component)___vehicleRigidbody).transform.forward;
				val2.y = 0f;
			}
			if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f)
			{
				___vehicleRigidbody.velocity = Vector3.zero;
				return;
			}
			((Vector3)(ref val2)).Normalize();
			Vector3 val3 = Vector3.Cross(Vector3.up, val2);
			if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f)
			{
				___vehicleRigidbody.velocity = Vector3.zero;
				return;
			}
			((Vector3)(ref val3)).Normalize();
			float num = Vector3.Dot(moveVector, val2);
			float num2 = Vector3.Dot(moveVector, val3);
			Vector3 val4 = val * num + val3 * num2;
			float num3 = Mathf.Clamp01(Mathf.Sqrt(num * num + num2 * num2));
			if (((Vector3)(ref val4)).sqrMagnitude <= 0.0001f || num3 <= 0.05f)
			{
				___vehicleRigidbody.velocity = Vector3.zero;
				return;
			}
			((Vector3)(ref val4)).Normalize();
			___vehicleRigidbody.velocity = val4 * ___currentSpeed * num3;
		}
	}
}