Decompiled source of Moved Magnet Switch v1.1.0

BepInEx/Plugins/MagnetLever.dll

Decompiled 2 weeks 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 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 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_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(-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 logger = ((BaseUnityPlugin)this).Logger;
			object arg = val.transform.localPosition;
			Quaternion localRotation = val.transform.localRotation;
			logger.LogInfo((object)$"MagnetLever (with WiderShipMod) moved to: Position: {arg}, 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");
	}
}