Decompiled source of Moved Magnet Switch v1.3.0

BepInEx/Plugins/MagnetLever.dll

Decompiled 5 days ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MagnetLever")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MagnetLever")]
[assembly: AssemblyTitle("MagnetLever")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.atomic.magnetmoved", "Magnet Moved", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MyLethalCompanyMod : BaseUnityPlugin
{
	private bool isWiderShipModInstalled = false;

	private bool isRightSideOn = false;

	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Magnet Moved loaded");
		isWiderShipModInstalled = CheckIfWiderShipModInstalled();
		if (isWiderShipModInstalled)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"WiderShipMod detected. Running alternate behavior.");
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"WiderShipMod not detected. Running default behavior.");
		}
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		if (((Scene)(ref scene)).name == "SampleSceneRelay")
		{
			if (isWiderShipModInstalled)
			{
				MoveAssetWithWiderShipMod();
			}
			else
			{
				MoveAsset();
			}
		}
	}

	private void checkLeftSide()
	{
		GameObject val = GameObject.Find("ShipInsideRight");
		if ((Object)(object)val != (Object)null)
		{
			isRightSideOn = true;
		}
	}

	private void MoveAsset()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.Find("MagnetLever");
		if ((Object)(object)val != (Object)null)
		{
			val.transform.localPosition = new Vector3(-6.579f, 1.778f, -9.633f);
			val.transform.localRotation = Quaternion.Euler(90f, 0f, -87.878f);
			val.transform.localScale = new Vector3(1.414123f, 1.414122f, 1.414122f);
			ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
			object arg = val.transform.position;
			Quaternion rotation = val.transform.rotation;
			logger.LogInfo((object)$"MagnetLever moved to: Position: {arg}, Rotation: {((Quaternion)(ref rotation)).eulerAngles}, Scale: {val.transform.localScale}");
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"MagnetLever was not found in the scene.");
		}
	}

	private void MoveAssetWithWiderShipMod()
	{
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.Find("MagnetLever");
		if ((Object)(object)val != (Object)null)
		{
			Quaternion localRotation;
			if (isRightSideOn)
			{
				val.transform.localPosition = new Vector3(-7.513f, 1.61f, -3.853f);
				val.transform.localRotation = Quaternion.Euler(90f, 0f, 180f);
				val.transform.localScale = new Vector3(1.414123f, 1.414122f, 1.414122f);
				ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
				object arg = val.transform.localPosition;
				localRotation = val.transform.localRotation;
				logger.LogInfo((object)$"MagnetLever (with WiderShipMod) moved to: Position: {arg}, Rotation: {((Quaternion)(ref localRotation)).eulerAngles}, Scale: {val.transform.localScale}");
			}
			else
			{
				val.transform.localPosition = new Vector3(-7.513f, 1.61f, -9.553f);
				val.transform.localRotation = Quaternion.Euler(90f, 0f, 180f);
				val.transform.localScale = new Vector3(1.414123f, 1.414122f, 1.414122f);
				ManualLogSource logger2 = ((BaseUnityPlugin)this).Logger;
				object arg2 = val.transform.localPosition;
				localRotation = val.transform.localRotation;
				logger2.LogInfo((object)$"MagnetLever (with WiderShipMod) moved to: Position: {arg2}, Rotation: {((Quaternion)(ref localRotation)).eulerAngles}, Scale: {val.transform.localScale}");
			}
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"MagnetLever was not found in the scene.");
		}
	}

	private bool CheckIfWiderShipModInstalled()
	{
		Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos;
		return pluginInfos.Values.Any((PluginInfo info) => info.Metadata.GUID == "mborsh.WiderShipMod");
	}
}