Decompiled source of ShipInventory WiderShipFix v1.0.6

BepInEx/Plugins/ShipInventoryMoved.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
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("ShipInventoryMoved")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Moves the ship inventory")]
[assembly: AssemblyTitle("ShipInventoryMoved")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 ShipInventoryMoved
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.atomic.shipinventoryfix", "Ship Inventory Position Fix", "1.0.3")]
	public class Main : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private bool shouldAdd;

		private void Awake()
		{
			SceneManager.sceneLoaded += OnSceneLoaded;
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"The ship inventory moved has loaded! Load into a game and see your new position");
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name == "SampleSceneRelay")
			{
				if (!shouldAdd)
				{
					return;
				}
				GameObject val = GameObject.Find("Environment");
				val.AddComponent<Attached>();
				shouldAdd = false;
			}
			if (((Scene)(ref scene)).name == "MainMenu")
			{
				shouldAdd = true;
			}
		}
	}
	public class Attached : MonoBehaviour
	{
		private bool isfound = false;

		private bool is2StoryModInstalled = false;

		private bool isFancyShipModInstalled = false;

		private bool isWiderShipModInstalled = false;

		private bool WiderShipLeft = false;

		private bool checkedMod = false;

		private void CheckForMods()
		{
			checkedMod = true;
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				BepInPlugin metadata = pluginInfo.Value.Metadata;
				if (metadata.GUID.Equals("MelanieMelicious.2StoryShip"))
				{
					is2StoryModInstalled = true;
				}
				if (metadata.GUID.Equals("MelanieMelicious.fancyShip"))
				{
					isFancyShipModInstalled = true;
				}
				if (metadata.GUID.Equals("mborsh.WiderShipMod"))
				{
					isWiderShipModInstalled = true;
					WiderShipCheckLeft();
				}
			}
		}

		private void WiderShipCheckLeft()
		{
			if (isWiderShipModInstalled)
			{
				GameObject val = GameObject.Find("ShipInsideLeft");
				if ((Object)(object)val != (Object)null)
				{
					WiderShipLeft = true;
				}
			}
		}

		private void Update()
		{
			if (!checkedMod)
			{
				CheckForMods();
			}
			if (!isfound)
			{
				MoveInventory();
			}
			else
			{
				Object.Destroy((Object)(object)this);
			}
		}

		private void MoveInventory()
		{
			GameObject val = GameObject.Find("VentChute(Clone)");
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			if (isWiderShipModInstalled)
			{
				if (is2StoryModInstalled)
				{
					Mel2StoryMovement(val);
				}
				else if (WiderShipLeft)
				{
					WiderShipMovementLeftSide(val);
				}
				else
				{
					WiderShipMovementRightSide(val);
				}
			}
			if (isFancyShipModInstalled)
			{
				FancyShipMovement(val);
			}
			if (is2StoryModInstalled)
			{
				Mel2StoryMovement(val);
			}
			if (!isWiderShipModInstalled && !isFancyShipModInstalled && !is2StoryModInstalled)
			{
				Object.Destroy((Object)(object)this);
			}
		}

		public void WiderShipMovementRightSide(GameObject VentChute)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			VentChute.transform.localPosition = new Vector3(3.1782f, 1.0457f, -1.3573f);
			VentChute.transform.localRotation = Quaternion.Euler(35.0012f, 61.3801f, 0f);
			isfound = true;
		}

		public void WiderShipMovementLeftSide(GameObject VentChute)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			VentChute.transform.localPosition = new Vector3(3.1782f, 1.0457f, -11.9573f);
			VentChute.transform.localRotation = Quaternion.Euler(35.0013f, 119.8801f, 0f);
			isfound = true;
		}

		public void FancyShipMovement(GameObject VentChute)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			VentChute.transform.localPosition = new Vector3(4.39f, 0.9509f, -2.09f);
			VentChute.transform.localRotation = Quaternion.Euler(31.4869f, 307.1009f, 359.7217f);
			isfound = true;
		}

		public void Mel2StoryMovement(GameObject VentChute)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			VentChute.transform.localPosition = new Vector3(4.39f, 0.9509f, -2.09f);
			VentChute.transform.localRotation = Quaternion.Euler(31.4869f, 307.1009f, 359.7217f);
			isfound = true;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ShipInventoryMoved";

		public const string PLUGIN_NAME = "Moves the ship inventory";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}