Decompiled source of MagnetRotationFix v1.0.0

magnetRotationFix.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using magnetRotationFix.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("magnetRotationFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("magnetRotationFix")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a3684ac1-4dea-4d8e-84de-98ae8a5bee54")]
[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 magnetRotationFix
{
	[BepInPlugin("Ryoryoman_magnetRotaionFix", "magnetRotaionFix", "1.0.0")]
	public class MagnetRotationFixBase : BaseUnityPlugin
	{
		private const string modGUID = "Ryoryoman_magnetRotaionFix";

		private const string modName = "magnetRotaionFix";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Ryoryoman_magnetRotaionFix");

		private static MagnetRotationFixBase Instanse;

		public static ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instanse == (Object)null)
			{
				Instanse = this;
			}
			mls = Logger.CreateLogSource("Ryoryoman_magnetRotaionFix");
			mls.LogInfo((object)"magnetRotaionFix1.0.0loaded.");
			harmony.PatchAll(typeof(MagnetRotationFixBase));
			harmony.PatchAll(typeof(QuaternionPatch));
		}
	}
}
namespace magnetRotationFix.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class QuaternionPatch
	{
		[HarmonyPatch("SyncShipUnlockablesClientRpc")]
		[HarmonyPostfix]
		private static void QuaternionFix(StartOfRound __instance)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance.attachedVehicle != (Object)null && !GameNetworkManager.Instance.isHostingGame)
			{
				typeof(VehicleController).GetField("magnetTargetRotation", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance.attachedVehicle, (object)new Quaternion(123f, 0.707f, 0.123f, 0.707f));
				typeof(VehicleController).GetField("magnetStartRotation", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance.attachedVehicle, (object)new Quaternion(0.123f, 0.707f, 0.123f, 0.707f));
			}
		}
	}
}