Decompiled source of SnapRotateFurniture v1.0.1

SnapRotateDecor.dll

Decompiled 5 months 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 SnapRotateFurniture.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SnapRotateDecor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SnapRotateDecor")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f8855d2f-421c-493b-a4b8-096a44d3d8ee")]
[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 SnapRotateFurniture
{
	[BepInPlugin("SleeplessKyru.SnapRotateFurniture", "Snap Rotate Furniture", "1.0.1")]
	public class SleeplessModBase : BaseUnityPlugin
	{
		private const string modGUID = "SleeplessKyru.SnapRotateFurniture";

		private const string modName = "Snap Rotate Furniture";

		private const string modVersion = "1.0.1";

		private readonly Harmony harmony = new Harmony("SleeplessKyru.SnapRotateFurniture");

		private static SleeplessModBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("SleeplessKyru.SnapRotateFurniture");
			mls.LogInfo((object)"Snap Rotate Furniture by Sleepless Kyru has loaded!");
			harmony.PatchAll(typeof(SleeplessModBase));
			harmony.PatchAll(typeof(SnapRotateFurniturePatch));
		}
	}
}
namespace SnapRotateFurniture.Patches
{
	[HarmonyPatch(typeof(ShipBuildModeManager))]
	internal class SnapRotateFurniturePatch
	{
		private static bool wasButtonPressed;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void rotateFurniturePatch(ref PlayerActions ___playerActions, ref Transform ___ghostObject)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			if (!IngamePlayerSettings.Instance.playerInput.actions.FindAction("ActivateItem", false).IsPressed())
			{
				if (StartOfRound.Instance.localPlayerUsingController)
				{
					MovementActions movement = ___playerActions.Movement;
					if (((MovementActions)(ref movement)).ActivateItem.IsPressed())
					{
						goto IL_004c;
					}
				}
				if (wasButtonPressed)
				{
					wasButtonPressed = false;
					float num = 45f;
					Vector3 eulerAngles = ___ghostObject.eulerAngles;
					float num2 = Mathf.Round(eulerAngles.y / num) * num + num;
					___ghostObject.eulerAngles = new Vector3(eulerAngles.x, num2, eulerAngles.z);
				}
				return;
			}
			goto IL_004c;
			IL_004c:
			wasButtonPressed = true;
		}
	}
}