Decompiled source of FrankysExtraSpaces v1.0.7

FrankysExtraSpaces.dll

Decompiled an hour ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInExPlugin;
using FrankysExtraSpaces;
using HarmonyLib;
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: AssemblyTitle("FrankysExtraSpaces (FrankysExtraSpaces)")]
[assembly: AssemblyProduct("FrankysExtraSpaces")]
[assembly: AssemblyVersion("1.0.7.0")]
public class ExtraSpacesMenu : MonoBehaviour
{
	private bool _visible;

	private Rect _windowRect = new Rect(20f, 20f, 350f, 500f);

	private Vector2 _scrollPosition;

	private ConfigEntry<KeyCode> _waitingForKey;

	private void Update()
	{
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		if (_waitingForKey != null)
		{
			foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
			{
				if (Input.GetKeyDown(value))
				{
					_waitingForKey.Value = value;
					_waitingForKey = null;
					((BaseUnityPlugin)Plugin.Instance).Config.Save();
					return;
				}
			}
		}
		if (Input.GetKeyDown(Plugin.MenuValue.Value))
		{
			_visible = !_visible;
		}
	}

	private void OnGUI()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		if (_visible)
		{
			_windowRect = GUI.Window(2351, _windowRect, new WindowFunction(DrawWindow), "Frankys Extra Spaces");
		}
	}

	private void DrawWindow(int windowID)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Unknown result type (might be due to invalid IL or missing references)
		_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Space(5f);
		DrawPartition("Catapult 1 Bays");
		GUILayout.Space(10f);
		DrawToggle("Parking Bay 100", Plugin.PB100);
		DrawToggle("Parking Bay 101", Plugin.PB101);
		DrawToggle("Parking Bay 102", Plugin.PB102);
		DrawToggle("Parking Bay 103", Plugin.PB103);
		DrawToggle("Parking Bay 104", Plugin.PB104);
		DrawToggle("Parking Bay 105", Plugin.PB105);
		DrawToggle("Parking Bay 106", Plugin.PB106);
		DrawToggle("Parking Bay 107", Plugin.PB107);
		DrawToggle("Parking Bay 108", Plugin.PB108);
		GUILayout.Space(10f);
		DrawPartition("Catapult 2 Bays");
		GUILayout.Space(10f);
		DrawToggle("Parking Bay 200", Plugin.PB200);
		DrawToggle("Parking Bay 201", Plugin.PB201);
		DrawToggle("Parking Bay 202", Plugin.PB202);
		DrawToggle("Parking Bay 203", Plugin.PB203);
		DrawToggle("Parking Bay 204", Plugin.PB204);
		DrawToggle("Parking Bay 205", Plugin.PB205);
		DrawToggle("Parking Bay 206", Plugin.PB206);
		DrawToggle("Parking Bay 207", Plugin.PB207);
		DrawToggle("Parking Bay 208", Plugin.PB208);
		GUILayout.Space(10f);
		DrawPartition("Other Bays");
		GUILayout.Space(10f);
		DrawToggle("Parking Bay 300", Plugin.PB300);
		DrawToggle("Parking Bay 301", Plugin.PB301);
		DrawToggle("Parking Bay 302", Plugin.PB302);
		DrawToggle("Parking Bay 303", Plugin.PB303);
		DrawToggle("Parking Bay 304", Plugin.PB304);
		DrawToggle("Parking Bay 305", Plugin.PB305);
		DrawToggle("Parking Bay 306", Plugin.PB306);
		DrawToggle("Parking Bay 307", Plugin.PB307);
		DrawToggle("Parking Bay 308", Plugin.PB308);
		GUILayout.Space(10f);
		DrawPartition("Helicopter Bays");
		GUILayout.Space(10f);
		DrawToggle("Helicopter Bay 4", Plugin.HB04);
		DrawToggle("Helicopter Bay 5", Plugin.HB05);
		GUILayout.Space(10f);
		DrawPartition("Repair Bays");
		GUILayout.Space(10f);
		DrawToggle("Repair Bay 11", Plugin.RB11);
		DrawToggle("Repair Bay 12", Plugin.RB12);
		DrawToggle("Repair Bay 13", Plugin.RB13);
		GUILayout.Space(10f);
		DrawPartition("Key Bindings");
		GUILayout.Space(10f);
		DrawKeyCode("Menu Keybinding", Plugin.MenuValue);
		GUILayout.EndScrollView();
		GUILayout.Space(10f);
		if (GUILayout.Button("Save Configuration", (GUILayoutOption[])(object)new GUILayoutOption[0]))
		{
			((BaseUnityPlugin)Plugin.Instance).Config.Save();
			CarrierLayoutPatch.ApplyBayStates();
			RepairBay11.ApplyState();
			RepairBay12.ApplyState();
			RepairBay13.ApplyState();
		}
		GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width, 15f));
	}

	private void DrawToggle(string label, ConfigEntry<bool> configEntry)
	{
		bool flag = GUILayout.Toggle(configEntry.Value, label, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (flag != configEntry.Value)
		{
			configEntry.Value = flag;
			((BaseUnityPlugin)Plugin.Instance).Config.Save();
		}
	}

	private void DrawKeyCode(string label, ConfigEntry<KeyCode> configEntry)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		string text = ((_waitingForKey == configEntry) ? "Press a key..." : ((object)configEntry.Value/*cast due to .constrained prefix*/).ToString());
		if (GUILayout.Button(text, (GUILayoutOption[])(object)new GUILayoutOption[0]))
		{
			_waitingForKey = configEntry;
		}
		GUILayout.EndHorizontal();
	}

	private void DrawPartition(string title)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Space(8f);
		GUILayout.Label(title, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		Rect rect = GUILayoutUtility.GetRect(1f, 1f);
		GUI.Box(rect, "");
		GUILayout.Space(5f);
	}
}
namespace BepInExPlugin
{
	[BepInPlugin("FrankysExtraSpaces", "FrankysExtraSpaces", "1.0.7")]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<string> RepairBayDesc;

		public static ConfigEntry<bool> RB11;

		public static ConfigEntry<bool> RB12;

		public static ConfigEntry<bool> RB13;

		public static ConfigEntry<string> ParkingBayDesc;

		public static ConfigEntry<bool> PB100;

		public static ConfigEntry<bool> PB101;

		public static ConfigEntry<bool> PB102;

		public static ConfigEntry<bool> PB103;

		public static ConfigEntry<bool> PB104;

		public static ConfigEntry<bool> PB105;

		public static ConfigEntry<bool> PB106;

		public static ConfigEntry<bool> PB107;

		public static ConfigEntry<bool> PB108;

		public static ConfigEntry<string> ParkingBayDesc2;

		public static ConfigEntry<bool> PB200;

		public static ConfigEntry<bool> PB201;

		public static ConfigEntry<bool> PB202;

		public static ConfigEntry<bool> PB203;

		public static ConfigEntry<bool> PB204;

		public static ConfigEntry<bool> PB205;

		public static ConfigEntry<bool> PB206;

		public static ConfigEntry<bool> PB207;

		public static ConfigEntry<bool> PB208;

		public static ConfigEntry<string> ParkingBayDesc3;

		public static ConfigEntry<bool> PB300;

		public static ConfigEntry<bool> PB301;

		public static ConfigEntry<bool> PB302;

		public static ConfigEntry<bool> PB303;

		public static ConfigEntry<bool> PB304;

		public static ConfigEntry<bool> PB305;

		public static ConfigEntry<bool> PB306;

		public static ConfigEntry<bool> PB307;

		public static ConfigEntry<bool> PB308;

		public static ConfigEntry<string> HelicopterLaunchBayDesc;

		public static ConfigEntry<bool> HB04;

		public static ConfigEntry<bool> HB05;

		public static ConfigEntry<string> MenuDesc;

		public static ConfigEntry<KeyCode> MenuValue;

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			Instance = this;
			Harmony val = new Harmony("FrankysExtraSpaces");
			val.PatchAll();
			Debug.Log((object)"FrankysExtraSpaces loaded");
			RepairBayDesc = ((BaseUnityPlugin)this).Config.Bind<string>("Repair Bays", "Description", "Toggle which extra repair bays you want active", "Description");
			RB11 = ((BaseUnityPlugin)this).Config.Bind<bool>("Repair Bays", "Repair Bay 11", true, "Right Upper");
			RB12 = ((BaseUnityPlugin)this).Config.Bind<bool>("Repair Bays", "Repair Bay 12", true, "Right Lower");
			RB13 = ((BaseUnityPlugin)this).Config.Bind<bool>("Repair Bays", "Repair Bay 13", true, "Left Upper");
			ParkingBayDesc = ((BaseUnityPlugin)this).Config.Bind<string>("Cat1 Parking Bays", "Description", "Toggle which extra parking bays you want active", "Description");
			PB100 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat1 Parking Bays", "Parking Bay 100", true, "Closest to Elevator 1");
			PB101 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat1 Parking Bays", "Parking Bay 101", true, "");
			PB102 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat1 Parking Bays", "Parking Bay 102", true, "");
			PB103 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat1 Parking Bays", "Parking Bay 103", true, "");
			PB104 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat1 Parking Bays", "Parking Bay 104", true, "");
			PB105 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat1 Parking Bays", "Parking Bay 105", true, "");
			PB106 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat1 Parking Bays", "Parking Bay 106", true, "");
			PB107 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat1 Parking Bays", "Parking Bay 107", true, "");
			PB108 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat1 Parking Bays", "Parking Bay 108", true, "Furthest Forward");
			ParkingBayDesc2 = ((BaseUnityPlugin)this).Config.Bind<string>("Cat2 Parking Bays", "Description", "Toggle which extra parking bays you want active", "Description");
			PB200 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat2 Parking Bays", "Parking Bay 200", true, "Front of Cat 2");
			PB201 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat2 Parking Bays", "Parking Bay 201", true, "");
			PB202 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat2 Parking Bays", "Parking Bay 202", true, "");
			PB203 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat2 Parking Bays", "Parking Bay 203", true, "");
			PB204 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat2 Parking Bays", "Parking Bay 204", true, "");
			PB205 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat2 Parking Bays", "Parking Bay 205", true, "Furthest Forward");
			PB206 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat2 Parking Bays", "Parking Bay 206", true, "");
			PB207 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat2 Parking Bays", "Parking Bay 207", true, "");
			PB208 = ((BaseUnityPlugin)this).Config.Bind<bool>("Cat2 Parking Bays", "Parking Bay 208", true, "Next to Cat 2 Blast Shield");
			ParkingBayDesc3 = ((BaseUnityPlugin)this).Config.Bind<string>("Other Parking Bays", "Description", "Toggle which extra parking bays you want active", "Description");
			PB300 = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Parking Bays", "Parking Bay 300", true, "Back Upper Right, Also shifts 2 other bays to fit");
			PB301 = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Parking Bays", "Parking Bay 301", true, "In front of Elevator 2");
			PB302 = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Parking Bays", "Parking Bay 302", true, "In front of Island, Left");
			PB303 = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Parking Bays", "Parking Bay 303", true, "In front of Island, Right");
			PB304 = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Parking Bays", "Parking Bay 304", true, "Where the Helicopter Bays were");
			PB305 = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Parking Bays", "Parking Bay 305", true, "Where the Helicopter Bays were");
			PB306 = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Parking Bays", "Parking Bay 306", true, "Where the Helicopter Bays were");
			PB307 = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Parking Bays", "Parking Bay 307", true, "Where the Helicopter Bays were");
			PB308 = ((BaseUnityPlugin)this).Config.Bind<bool>("Other Parking Bays", "Parking Bay 308", true, "Where the Helicopter Bays were");
			HelicopterLaunchBayDesc = ((BaseUnityPlugin)this).Config.Bind<string>("Helicopter Launch Bays", "Description", "Toggle which extra Helicopter launch bays you want active", "Description");
			HB04 = ((BaseUnityPlugin)this).Config.Bind<bool>("Helicopter Launch Bays", "Helicopter Bay 4", true, "TEST DONT FORGET TO CHANGE ME");
			HB05 = ((BaseUnityPlugin)this).Config.Bind<bool>("Helicopter Launch Bays", "Helicopter Bay 5", true, "TEST DONT FORGET TO CHANGE ME");
			MenuDesc = ((BaseUnityPlugin)this).Config.Bind<string>("Menu Key", "Description", "Set what hotkey opens the GUI", "");
			MenuValue = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Menu Key", "Menu Key", (KeyCode)91, "");
			((Component)this).gameObject.AddComponent<ExtraSpacesMenu>();
		}
	}
	internal static class PluginInfo
	{
		public const string PLUGIN_NAME = "FrankysExtraSpaces";

		public const string PLUGIN_ID = "FrankysExtraSpaces";

		public const string PLUGIN_VERSION = "1.0.7";
	}
}
namespace FrankysExtraSpaces
{
	[HarmonyPatch(typeof(CarrierLayout), "Start")]
	public static class CarrierLayoutPatch
	{
		private class NodeDefinition
		{
			public string Name;

			public Vector3 LocalPosition;

			public Quaternion LocalRotation;

			public NodeDefinition(string name, Vector3 pos, Quaternion rot)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				Name = name;
				LocalPosition = pos;
				LocalRotation = rot;
			}
		}

		private class BayDefinition
		{
			public string Name;

			public Vector3 LocalPosition;

			public Quaternion LocalRotation;

			public string OriginalName;

			public ConfigEntry<bool> ConfigEntry;

			public List<string> AttachToNodes;

			public BayDefinition(string name, string originalName, Vector3 pos, Quaternion rot, ConfigEntry<bool> configEntry, List<string> attachTo)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				Name = name;
				OriginalName = originalName;
				LocalPosition = pos;
				LocalRotation = rot;
				ConfigEntry = configEntry;
				AttachToNodes = attachTo;
			}
		}

		private static readonly FieldInfo ConnectionsField = AccessTools.Field(typeof(NavigationNode), "_connections");

		private static readonly NodeDefinition[] CustomNodes = new NodeDefinition[8]
		{
			new NodeDefinition("JunctionNode (41)", new Vector3(-114f, 0f, 2.59f), Quaternion.identity),
			new NodeDefinition("JunctionNode (42)", new Vector3(-125.2f, 0f, 2.43f), Quaternion.identity),
			new NodeDefinition("JunctionNode (43)", new Vector3(-139.6f, 0f, 2.45f), Quaternion.identity),
			new NodeDefinition("JunctionNode (44)", new Vector3(-152.5f, 0f, 2.87f), Quaternion.identity),
			new NodeDefinition("JunctionNode (45)", new Vector3(54.4f, 0f, 2.87f), Quaternion.identity),
			new NodeDefinition("JunctionNode (46)", new Vector3(66.48f, 0f, 2.87f), Quaternion.identity),
			new NodeDefinition("JunctionNode (47)", new Vector3(-58f, 0f, 7.2f), Quaternion.identity),
			new NodeDefinition("JunctionNode (48)", new Vector3(-58f, 0f, -15.46f), Quaternion.identity)
		};

		private static readonly BayDefinition[] CustomBays = new BayDefinition[29]
		{
			new BayDefinition("ParkingBay (100)", "ParkingBay (0)", new Vector3(-68.88f, 0f, 30.32f), Quaternion.Euler(0f, -35.795f, 0f), Plugin.PB100, new List<string> { "JunctionNode (23)" }),
			new BayDefinition("ParkingBay (101)", "ParkingBay (0)", new Vector3(-77.48f, 0f, 24.127f), Quaternion.Euler(0f, -35.795f, 0f), Plugin.PB101, new List<string> { "JunctionNode (3)" }),
			new BayDefinition("ParkingBay (102)", "ParkingBay (0)", new Vector3(-85.76f, 0f, 18.07f), Quaternion.Euler(0f, -21.068f, 0f), Plugin.PB102, new List<string> { "JunctionNode (2)" }),
			new BayDefinition("ParkingBay (103)", "ParkingBay (0)", new Vector3(-100.5f, 0f, 17.1f), Quaternion.Euler(0f, -44.712f, 0f), Plugin.PB103, new List<string> { "JunctionNode (2)" }),
			new BayDefinition("ParkingBay (104)", "ParkingBay (0)", new Vector3(-112.9f, 0f, 16.1f), Quaternion.Euler(0f, -44.712f, 0f), Plugin.PB104, new List<string> { "JunctionNode (1)" }),
			new BayDefinition("ParkingBay (105)", "ParkingBay (0)", new Vector3(-124.92f, 0f, 14.98f), Quaternion.Euler(0f, -44.712f, 0f), Plugin.PB105, new List<string> { "JunctionNode (41)" }),
			new BayDefinition("ParkingBay (106)", "ParkingBay (0)", new Vector3(-136.93f, 0f, 14.17f), Quaternion.Euler(0f, -44.712f, 0f), Plugin.PB106, new List<string> { "JunctionNode (42)" }),
			new BayDefinition("ParkingBay (107)", "ParkingBay (0)", new Vector3(-149.4f, 0f, 13.25f), Quaternion.Euler(0f, -44.712f, 0f), Plugin.PB107, new List<string> { "JunctionNode (43)" }),
			new BayDefinition("ParkingBay (108)", "ParkingBay (0)", new Vector3(-161.18f, 0f, 11.92f), Quaternion.Euler(0f, -44.712f, 0f), Plugin.PB108, new List<string> { "JunctionNode (44)" }),
			new BayDefinition("ParkingBay (200)", "ParkingBay (0)", new Vector3(-99.99f, 0f, -11.27f), Quaternion.Euler(0f, 224.712f, 0f), Plugin.PB200, new List<string> { "JunctionNode (2)" }),
			new BayDefinition("ParkingBay (201)", "ParkingBay (0)", new Vector3(-111.67f, 0f, -10.37f), Quaternion.Euler(0f, 224.712f, 0f), Plugin.PB201, new List<string> { "JunctionNode (1)" }),
			new BayDefinition("ParkingBay (202)", "ParkingBay (0)", new Vector3(-123.82f, 0f, -9.75f), Quaternion.Euler(0f, 224.712f, 0f), Plugin.PB202, new List<string> { "JunctionNode (41)" }),
			new BayDefinition("ParkingBay (203)", "ParkingBay (0)", new Vector3(-135.88f, 0f, -8.67f), Quaternion.Euler(0f, 224.712f, 0f), Plugin.PB203, new List<string> { "JunctionNode (42)" }),
			new BayDefinition("ParkingBay (204)", "ParkingBay (0)", new Vector3(-149.02f, 0f, -8.58f), Quaternion.Euler(0f, 224.712f, 0f), Plugin.PB204, new List<string> { "JunctionNode (43)" }),
			new BayDefinition("ParkingBay (205)", "ParkingBay (0)", new Vector3(-160.75f, 0f, -6.69f), Quaternion.Euler(0f, 224.712f, 0f), Plugin.PB205, new List<string> { "JunctionNode (44)" }),
			new BayDefinition("ParkingBay (206)", "ParkingBay (0)", new Vector3(-84.1f, 0f, -8f), Quaternion.Euler(0f, 224.712f, 0f), Plugin.PB206, new List<string> { "JunctionNode (3)" }),
			new BayDefinition("ParkingBay (207)", "ParkingBay (0)", new Vector3(-70.1f, 0f, -6.5f), Quaternion.Euler(0f, 224.712f, 0f), Plugin.PB207, new List<string> { "JunctionNode (47)" }),
			new BayDefinition("ParkingBay (208)", "ParkingBay (0)", new Vector3(-55.2f, 0f, -4.2f), Quaternion.Euler(0f, 224.712f, 0f), Plugin.PB208, new List<string> { "JunctionNode (5)" }),
			new BayDefinition("ParkingBay (300)", "ParkingBay (0)", new Vector3(116.3f, 0f, 23.8f), Quaternion.Euler(0f, 48.962f, 0f), Plugin.PB300, new List<string> { "JunctionNode (27)" }),
			new BayDefinition("ParkingBay (301)", "ParkingBay (0)", new Vector3(18.61f, 0f, 5.11f), Quaternion.Euler(0f, 28f, 0f), Plugin.PB301, new List<string> { "JunctionNode (11)", "JunctionNode (35)" }),
			new BayDefinition("ParkingBay (302)", "ParkingBay (0)", new Vector3(54f, 0f, 14.03f), Quaternion.Euler(0f, 0f, 0f), Plugin.PB302, new List<string> { "JunctionNode (45)" }),
			new BayDefinition("ParkingBay (303)", "ParkingBay (0)", new Vector3(66.2f, 0f, 15.99f), Quaternion.Euler(0f, 0f, 0f), Plugin.PB303, new List<string> { "JunctionNode (46)" }),
			new BayDefinition("ParkingBay (304)", "ParkingBay (0)", new Vector3(88.88f, 0f, -29.63f), Quaternion.Euler(0f, 169.076f, 0f), Plugin.PB304, new List<string> { "JunctionNode (16)" }),
			new BayDefinition("ParkingBay (305)", "ParkingBay (0)", new Vector3(79.13f, 0f, -31.68f), Quaternion.Euler(0f, 180f, 0f), Plugin.PB304, new List<string> { "JunctionNode (16)" }),
			new BayDefinition("ParkingBay (306)", "ParkingBay (0)", new Vector3(68.79f, 0f, -31.68f), Quaternion.Euler(0f, 180f, 0f), Plugin.PB306, new List<string> { "JunctionNode (15)" }),
			new BayDefinition("ParkingBay (307)", "ParkingBay (0)", new Vector3(58.55f, 0f, -31.68f), Quaternion.Euler(0f, 180f, 0f), Plugin.PB307, new List<string> { "JunctionNode (15)" }),
			new BayDefinition("ParkingBay (308)", "ParkingBay (0)", new Vector3(48.39f, 0f, -31.68f), Quaternion.Euler(0f, 180f, 0f), Plugin.PB308, new List<string> { "JunctionNode (13)" }),
			new BayDefinition("HelicopterLaunchBay (4)", "HelicopterLaunchBay (1)", new Vector3(-58.01f, 0f, -24.61f), Quaternion.Euler(0f, -90f, 0f), Plugin.HB04, new List<string> { "JunctionNode (48)" }),
			new BayDefinition("HelicopterLaunchBay (5)", "HelicopterLaunchBay (1)", new Vector3(-30.99f, 0f, -20.98f), Quaternion.Euler(0f, -90f, 0f), Plugin.HB05, new List<string> { "JunctionNode (31)" })
		};

		private static readonly Dictionary<string, UnitMovementNode> NodeLookup = new Dictionary<string, UnitMovementNode>();

		private static readonly Dictionary<string, GameObject> BayLookup = new Dictionary<string, GameObject>();

		private static void ClearNodeConnections(NavigationNode node)
		{
			if (!((Object)(object)node == (Object)null))
			{
				if ((object)ConnectionsField == null)
				{
					Debug.LogError((object)"Could not find NavigationNode._connections.");
				}
				else
				{
					ConnectionsField.SetValue(node, new List<NavigationConnection>());
				}
			}
		}

		private static void Postfix(CarrierLayout __instance)
		{
			try
			{
				InitializeNodes(__instance);
				InitializeConnections();
				InitializeBays(__instance);
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"CarrierLayoutPatch failed: {arg}");
			}
		}

		private static void InitializeNodes(CarrierLayout layout)
		{
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			NodeLookup.Clear();
			GameObject obj = GameObject.Find("UpperDeckNodes");
			Transform val = ((obj != null) ? obj.transform : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			UnitMovementNode[] componentsInChildren = ((Component)val).GetComponentsInChildren<UnitMovementNode>();
			foreach (UnitMovementNode val2 in componentsInChildren)
			{
				if (!NodeLookup.ContainsKey(((Object)val2).name))
				{
					NodeLookup.Add(((Object)val2).name, val2);
					Debug.Log((object)("Vanilla node registered: " + ((Object)val2).name));
				}
			}
			NodeDefinition[] customNodes = CustomNodes;
			foreach (NodeDefinition nodeDefinition in customNodes)
			{
				GameObject obj2 = GameObject.Find("JunctionNode (1)");
				UnitMovementNode val3 = ((obj2 != null) ? obj2.GetComponent<UnitMovementNode>() : null);
				if (!((Object)(object)val3 == (Object)null))
				{
					UnitMovementNode val4 = Object.Instantiate<UnitMovementNode>(val3, val);
					((Object)val4).name = nodeDefinition.Name;
					((Component)val4).transform.localPosition = nodeDefinition.LocalPosition;
					((Component)val4).transform.localRotation = nodeDefinition.LocalRotation;
					ClearNodeConnections((NavigationNode)(object)val4);
					NodeLookup[nodeDefinition.Name] = val4;
					Debug.Log((object)("Custom Node " + nodeDefinition.Name + " added"));
				}
			}
		}

		private static void InitializeConnections()
		{
			if (NodeLookup != null)
			{
				((NavigationNode)NodeLookup["JunctionNode (41)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (1)"]);
				((NavigationNode)NodeLookup["JunctionNode (41)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (42)"]);
				((NavigationNode)NodeLookup["JunctionNode (42)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (43)"]);
				((NavigationNode)NodeLookup["JunctionNode (43)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (44)"]);
				((NavigationNode)NodeLookup["JunctionNode (45)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (20)"]);
				((NavigationNode)NodeLookup["JunctionNode (45)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (21)"]);
				((NavigationNode)NodeLookup["JunctionNode (46)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (21)"]);
				((NavigationNode)NodeLookup["JunctionNode (46)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (22)"]);
				((NavigationNode)NodeLookup["JunctionNode (47)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (3)"]);
				((NavigationNode)NodeLookup["JunctionNode (47)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (5)"]);
				((NavigationNode)NodeLookup["JunctionNode (48)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (38)"]);
				((NavigationNode)NodeLookup["JunctionNode (1)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (41)"]);
				((NavigationNode)NodeLookup["JunctionNode (42)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (41)"]);
				((NavigationNode)NodeLookup["JunctionNode (43)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (42)"]);
				((NavigationNode)NodeLookup["JunctionNode (44)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (43)"]);
				((NavigationNode)NodeLookup["JunctionNode (20)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (45)"]);
				((NavigationNode)NodeLookup["JunctionNode (21)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (45)"]);
				((NavigationNode)NodeLookup["JunctionNode (21)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (46)"]);
				((NavigationNode)NodeLookup["JunctionNode (22)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (46)"]);
				((NavigationNode)NodeLookup["JunctionNode (3)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (47)"]);
				((NavigationNode)NodeLookup["JunctionNode (5)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (47)"]);
				((NavigationNode)NodeLookup["JunctionNode (38)"]).AddTargetNode((NavigationNode)(object)NodeLookup["JunctionNode (48)"]);
				Debug.Log((object)"Custom nodes connected.");
			}
		}

		private static void InitializeBays(CarrierLayout layout)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.Find("UpperDeckBays");
			Transform val = ((obj != null) ? obj.transform : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			BayLookup.Clear();
			FieldInfo fieldInfo = AccessTools.Field(typeof(Region), "_orientationMultiplier");
			BayDefinition[] customBays = CustomBays;
			foreach (BayDefinition bayDefinition in customBays)
			{
				GameObject val2 = GameObject.Find(bayDefinition.OriginalName);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				GameObject val3 = Object.Instantiate<GameObject>(val2, val);
				((Object)val3).name = bayDefinition.Name;
				val3.transform.localPosition = bayDefinition.LocalPosition;
				val3.transform.localRotation = bayDefinition.LocalRotation;
				Region component = val3.GetComponent<Region>();
				BayLookup[bayDefinition.Name] = val3;
				if ((object)fieldInfo != null && (Object)(object)component != (Object)null)
				{
					if (bayDefinition.Name == "HelicopterLaunchBay (4)")
					{
						fieldInfo.SetValue(component, (object)new Vector3(1f, 0f, 1f));
					}
					else if (bayDefinition.Name == "HelicopterLaunchBay (5)")
					{
						fieldInfo.SetValue(component, (object)new Vector3(1f, 0f, 1f));
					}
					else
					{
						fieldInfo.SetValue(component, (object)new Vector3(-1f, 0f, -1f));
					}
				}
				UnitMovementNode componentInChildren = val3.GetComponentInChildren<UnitMovementNode>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					ClearNodeConnections((NavigationNode)(object)componentInChildren);
					foreach (string attachToNode in bayDefinition.AttachToNodes)
					{
						if (NodeLookup.TryGetValue(attachToNode, out var value))
						{
							((NavigationNode)componentInChildren).AddTargetNode((NavigationNode)(object)value);
							((NavigationNode)value).AddTargetNode((NavigationNode)(object)componentInChildren);
							continue;
						}
						GameObject val4 = GameObject.Find(attachToNode);
						UnitMovementNode val5 = ((val4 != null) ? val4.GetComponent<UnitMovementNode>() : null);
						if ((Object)(object)val5 != (Object)null)
						{
							((NavigationNode)componentInChildren).AddTargetNode((NavigationNode)(object)val5);
							((NavigationNode)val5).AddTargetNode((NavigationNode)(object)componentInChildren);
						}
					}
				}
				val3.SetActive(bayDefinition.ConfigEntry.Value);
				Debug.Log((object)(bayDefinition.Name + " added and connected"));
			}
			if (Plugin.PB300.Value)
			{
				GameObject obj2 = GameObject.Find("ParkingBay (8)");
				ParkingBay val6 = ((obj2 != null) ? obj2.GetComponent<ParkingBay>() : null);
				GameObject obj3 = GameObject.Find("ParkingBay (9)");
				ParkingBay val7 = ((obj3 != null) ? obj3.GetComponent<ParkingBay>() : null);
				((Component)val6).transform.localPosition = new Vector3(128.2f, 0f, 21.4f);
				((Component)val6).transform.localRotation = Quaternion.Euler(0f, 48.962f, 0f);
				((Component)val7).transform.localPosition = new Vector3(142.64f, 0f, 23.18f);
				((Component)val7).transform.localRotation = Quaternion.Euler(0f, 48.962f, 0f);
			}
			if (Plugin.PB302.Value || Plugin.PB303.Value)
			{
				GameObject obj4 = GameObject.Find("LargeParkingBay (2)");
				ParkingBay val8 = ((obj4 != null) ? obj4.GetComponent<ParkingBay>() : null);
				((Component)val8).transform.localPosition = new Vector3(41.76f, 0f, 12.27f);
				((Component)val8).transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
			}
			GameObject obj5 = GameObject.Find("ParkingBay (5)");
			ParkingBay val9 = ((obj5 != null) ? obj5.GetComponent<ParkingBay>() : null);
			GameObject obj6 = GameObject.Find("ParkingBay (6)");
			ParkingBay val10 = ((obj6 != null) ? obj6.GetComponent<ParkingBay>() : null);
			((Component)val9).transform.localPosition = new Vector3(-14.37f, 0f, 2.47f);
			((Component)val9).transform.localRotation = Quaternion.Euler(0f, 28f, 0f);
			((Component)val10).transform.localPosition = new Vector3(-3.67f, 0f, 4.01f);
			((Component)val10).transform.localRotation = Quaternion.Euler(0f, 28f, 0f);
			if (Plugin.HB04.Value)
			{
				GameObject obj7 = GameObject.Find("HelicopterLaunchBay (4)");
				HelicopterBay val11 = ((obj7 != null) ? obj7.GetComponent<HelicopterBay>() : null);
				Transform val12 = ((Component)val11).transform.Find("LaunchArrowsTrigger");
				val12.localPosition += new Vector3(0f, 0.8f, 0f);
			}
			if (Plugin.HB05.Value)
			{
				GameObject obj8 = GameObject.Find("HelicopterLaunchBay (5)");
				HelicopterBay val13 = ((obj8 != null) ? obj8.GetComponent<HelicopterBay>() : null);
				Transform val14 = ((Component)val13).transform.Find("LaunchArrowsTrigger");
				val14.localPosition += new Vector3(0f, 0.8f, 0f);
			}
			if (Plugin.PB304.Value || Plugin.PB305.Value)
			{
				GameObject.Find("HelicopterLaunchBay (1)").SetActive(false);
			}
			if (Plugin.PB306.Value || Plugin.PB307.Value)
			{
				GameObject.Find("HelicopterLaunchBay (2)").SetActive(false);
			}
			if (Plugin.PB308.Value)
			{
				GameObject.Find("HelicopterLaunchBay (3)").SetActive(false);
			}
			if (Plugin.PB306.Value || Plugin.PB307.Value || Plugin.PB307.Value)
			{
				GameObject.Find("Catapult 4").SetActive(false);
			}
			if (Plugin.PB208.Value)
			{
				GameObject.Find("Catapult 2").SetActive(false);
			}
		}

		public static void ApplyBayStates()
		{
			BayDefinition[] customBays = CustomBays;
			foreach (BayDefinition bayDefinition in customBays)
			{
				if (BayLookup.TryGetValue(bayDefinition.Name, out var value) && (Object)(object)value != (Object)null)
				{
					value.SetActive(bayDefinition.ConfigEntry.Value);
				}
			}
			GameObject val = FindBayIncludingInactive("HelicopterLaunchBay (1)");
			GameObject val2 = FindBayIncludingInactive("HelicopterLaunchBay (2)");
			GameObject val3 = FindBayIncludingInactive("HelicopterLaunchBay (3)");
			GameObject val4 = FindBayIncludingInactive("Catapult 2");
			GameObject val5 = FindBayIncludingInactive("Catapult 4");
			if ((Object)(object)val != (Object)null)
			{
				val.SetActive(!Plugin.PB304.Value && !Plugin.PB305.Value);
			}
			if ((Object)(object)val2 != (Object)null)
			{
				val2.SetActive(!Plugin.PB306.Value && !Plugin.PB307.Value);
			}
			if ((Object)(object)val3 != (Object)null)
			{
				val3.SetActive(!Plugin.PB308.Value);
			}
			if ((Object)(object)val5 != (Object)null)
			{
				val5.SetActive(!Plugin.PB306.Value && !Plugin.PB307.Value && !Plugin.PB308.Value);
			}
			if ((Object)(object)val4 != (Object)null)
			{
				val4.SetActive(!Plugin.PB208.Value);
			}
			Debug.Log((object)"Extra Spaces bay states updated.");
		}

		private static GameObject FindBayIncludingInactive(string bayName)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if (((Object)val).name == bayName)
				{
					Scene scene = val.scene;
					if (((Scene)(ref scene)).isLoaded)
					{
						return val;
					}
				}
			}
			return null;
		}
	}
	[HarmonyPatch(typeof(CarrierLayout), "Start")]
	public static class RepairBay11
	{
		public static RepairBay _clone;

		private static void Postfix(CarrierLayout __instance)
		{
			try
			{
				AddNewRepairBay(__instance);
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Failed to add new RepairBay: {arg}");
			}
		}

		private static void AddNewRepairBay(CarrierLayout layout)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.Find("RepairBay (10)");
			RepairBay val = ((obj != null) ? obj.GetComponent<RepairBay>() : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject obj2 = GameObject.Find("LowerDeckBays");
			Transform val2 = ((obj2 != null) ? obj2.transform : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			_clone = Object.Instantiate<RepairBay>(val, val2);
			((Object)_clone).name = "RepairBay (11)";
			((Component)_clone).transform.localPosition = new Vector3(119.37f, 0f, 7.76f);
			((Component)_clone).transform.localRotation = Quaternion.Euler(0f, -90f, 0f);
			UnitMovementNode componentInChildren = ((Component)_clone).GetComponentInChildren<UnitMovementNode>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			AccessTools.Field(typeof(Region), "_orientationMultiplier")?.SetValue(_clone, (object)new Vector3(1f, 0f, 1f));
			GameObject obj3 = GameObject.Find("LowerDeckNodes/JunctionNode (13)");
			UnitMovementNode val3 = ((obj3 != null) ? obj3.GetComponent<UnitMovementNode>() : null);
			if ((Object)(object)val3 == (Object)null)
			{
				return;
			}
			List<NavigationConnection> list = new List<NavigationConnection>();
			((NavigationNode)componentInChildren).GetConnections(list);
			foreach (NavigationConnection item in list)
			{
				((NavigationNode)componentInChildren).RemoveTargetNode(item.TargetNode);
			}
			((NavigationNode)componentInChildren).AddTargetNode((NavigationNode)(object)val3);
			((NavigationNode)val3).AddTargetNode((NavigationNode)(object)componentInChildren);
			((Component)_clone).gameObject.SetActive(Plugin.RB11.Value);
			Debug.Log((object)(((Object)_clone).name + " added"));
		}

		public static void ApplyState()
		{
			if ((Object)(object)_clone != (Object)null)
			{
				((Component)_clone).gameObject.SetActive(Plugin.RB11.Value);
			}
		}
	}
	[HarmonyPatch(typeof(CarrierLayout), "Start")]
	public static class RepairBay12
	{
		public static RepairBay _clone;

		private static void Postfix(CarrierLayout __instance)
		{
			try
			{
				AddNewRepairBay(__instance);
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Failed to add new RepairBay: {arg}");
			}
		}

		private static void AddNewRepairBay(CarrierLayout layout)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.Find("RepairBay (10)");
			RepairBay val = ((obj != null) ? obj.GetComponent<RepairBay>() : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject obj2 = GameObject.Find("LowerDeckBays");
			Transform val2 = ((obj2 != null) ? obj2.transform : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			_clone = Object.Instantiate<RepairBay>(val, val2);
			((Object)_clone).name = "RepairBay (12)";
			((Component)_clone).transform.localPosition = new Vector3(122.11f, 0f, -2.23f);
			((Component)_clone).transform.localRotation = Quaternion.Euler(0f, -90f, 0f);
			UnitMovementNode componentInChildren = ((Component)_clone).GetComponentInChildren<UnitMovementNode>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			AccessTools.Field(typeof(Region), "_orientationMultiplier")?.SetValue(_clone, (object)new Vector3(1f, 0f, 1f));
			GameObject obj3 = GameObject.Find("LowerDeckNodes/JunctionNode (15)");
			UnitMovementNode val3 = ((obj3 != null) ? obj3.GetComponent<UnitMovementNode>() : null);
			if ((Object)(object)val3 == (Object)null)
			{
				return;
			}
			List<NavigationConnection> list = new List<NavigationConnection>();
			((NavigationNode)componentInChildren).GetConnections(list);
			foreach (NavigationConnection item in list)
			{
				((NavigationNode)componentInChildren).RemoveTargetNode(item.TargetNode);
			}
			((NavigationNode)componentInChildren).AddTargetNode((NavigationNode)(object)val3);
			((NavigationNode)val3).AddTargetNode((NavigationNode)(object)componentInChildren);
			((Component)_clone).gameObject.SetActive(Plugin.RB12.Value);
			Debug.Log((object)(((Object)_clone).name + " added"));
		}

		public static void ApplyState()
		{
			if ((Object)(object)_clone != (Object)null)
			{
				((Component)_clone).gameObject.SetActive(Plugin.RB12.Value);
			}
		}
	}
	[HarmonyPatch(typeof(CarrierLayout), "Start")]
	public static class RepairBay13
	{
		public static RepairBay _clone;

		private static void Postfix(CarrierLayout __instance)
		{
			try
			{
				AddNewRepairBay(__instance);
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Failed to add new RepairBay: {arg}");
			}
		}

		private static void AddNewRepairBay(CarrierLayout layout)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.Find("RepairBay (10)");
			RepairBay val = ((obj != null) ? obj.GetComponent<RepairBay>() : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			GameObject obj2 = GameObject.Find("LowerDeckBays");
			Transform val2 = ((obj2 != null) ? obj2.transform : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			_clone = Object.Instantiate<RepairBay>(val, val2);
			((Object)_clone).name = "RepairBay (13)";
			((Component)_clone).transform.localPosition = new Vector3(-42.42f, 0f, 9.07f);
			((Component)_clone).transform.localRotation = Quaternion.Euler(0f, 90f, 0f);
			UnitMovementNode componentInChildren = ((Component)_clone).GetComponentInChildren<UnitMovementNode>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			AccessTools.Field(typeof(Region), "_orientationMultiplier")?.SetValue(_clone, (object)new Vector3(1f, 0f, 1f));
			GameObject obj3 = GameObject.Find("LowerDeckNodes/JunctionNode (21)");
			UnitMovementNode val3 = ((obj3 != null) ? obj3.GetComponent<UnitMovementNode>() : null);
			if ((Object)(object)val3 == (Object)null)
			{
				return;
			}
			List<NavigationConnection> list = new List<NavigationConnection>();
			((NavigationNode)componentInChildren).GetConnections(list);
			foreach (NavigationConnection item in list)
			{
				((NavigationNode)componentInChildren).RemoveTargetNode(item.TargetNode);
			}
			((NavigationNode)componentInChildren).AddTargetNode((NavigationNode)(object)val3);
			((NavigationNode)val3).AddTargetNode((NavigationNode)(object)componentInChildren);
			((Component)_clone).gameObject.SetActive(Plugin.RB13.Value);
			Debug.Log((object)(((Object)_clone).name + " added"));
		}

		public static void ApplyState()
		{
			if ((Object)(object)_clone != (Object)null)
			{
				((Component)_clone).gameObject.SetActive(Plugin.RB13.Value);
			}
		}
	}
}