Decompiled source of Blueprints v5.0.0

plugins/Blueprints/Blueprints.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Xml.Serialization;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Blueprints.Panels;
using Blueprints.Patches;
using EquinoxsDebuggingTools;
using EquinoxsModUtils;
using HarmonyLib;
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("Blueprints")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Blueprints")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("98b74f00-212c-455b-aca4-7f20b8c04b6b")]
[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 Blueprints
{
	public static class AimingHelper
	{
		public static LayerMask? buildablesMask;

		public static Vector3? getLookedAtMachinePos()
		{
			//IL_000c: 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_0018: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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)
			Camera cam = Player.instance.cam;
			GenericMachineInstanceRef val = GenericMachineInstanceRef.INVALID_REFERENCE;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(((Component)cam).transform.position, ((Component)cam).transform.forward, ref val2, 1000f, LayerMask.op_Implicit(buildablesMask.Value)))
			{
				val = FHG_Utils.FindMachineRef(((Component)((RaycastHit)(ref val2)).collider).gameObject);
				if (((GenericMachineInstanceRef)(ref val)).instanceId != ((GenericMachineInstanceRef)(ref GenericMachineInstanceRef.INVALID_REFERENCE)).instanceId)
				{
					_ = ((GridInfo)(ref ((GenericMachineInstanceRef)(ref val)).MyGridInfo)).Center;
					if (true)
					{
						return ((GridInfo)(ref ((GenericMachineInstanceRef)(ref val)).MyGridInfo)).Center;
					}
				}
			}
			return null;
		}

		public static Vector3? getAboveLookedAtMachinePos()
		{
			//IL_000c: 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_0018: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			Camera cam = Player.instance.cam;
			GenericMachineInstanceRef val = GenericMachineInstanceRef.INVALID_REFERENCE;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(((Component)cam).transform.position, ((Component)cam).transform.forward, ref val2, 1000f, LayerMask.op_Implicit(buildablesMask.Value)))
			{
				val = FHG_Utils.FindMachineRef(((Component)((RaycastHit)(ref val2)).collider).gameObject);
				if (((GenericMachineInstanceRef)(ref val)).instanceId != ((GenericMachineInstanceRef)(ref GenericMachineInstanceRef.INVALID_REFERENCE)).instanceId)
				{
					_ = ((GridInfo)(ref ((GenericMachineInstanceRef)(ref val)).MyGridInfo)).Center;
					if (true)
					{
						Vector3 bottomCenter = ((GridInfo)(ref ((GenericMachineInstanceRef)(ref val)).MyGridInfo)).BottomCenter;
						bottomCenter.y += ((Vector3Int)(ref ((GenericMachineInstanceRef)(ref val)).MyGridInfo.dims)).y;
						return bottomCenter;
					}
				}
			}
			return null;
		}

		public static Vector3 getAimedLocationForPasting()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			if (MachinePaster.isPositionLocked)
			{
				if (flag)
				{
					Debug.Log((object)$"getAimedLocationForPasting() - Returning lockedLocation {MachinePaster.lockedPosition}");
				}
				return MachinePaster.lockedPosition;
			}
			Vector3 currentAimTarget = Player.instance.builder.CurrentAimTarget;
			if (flag)
			{
				Debug.Log((object)$"getAimedLocationForPasting() - currentAim: {currentAimTarget}");
			}
			float num = Mathf.Floor(currentAimTarget.x);
			if (num == -1f)
			{
				currentAimTarget.x = -0.5f;
			}
			else if (num == 0f)
			{
				currentAimTarget.x = 0.5f;
			}
			else if (currentAimTarget.x >= 0f)
			{
				currentAimTarget.x += 0.5f - currentAimTarget.x % num;
			}
			else
			{
				currentAimTarget.x += Mathf.Abs(currentAimTarget.x) % Mathf.Floor(Mathf.Abs(currentAimTarget.x)) - 0.5f;
			}
			if (flag)
			{
				Debug.Log((object)$"getAimedLocationForPasting() - currentAim After X Adjust: {currentAimTarget}");
			}
			currentAimTarget.y = Mathf.Floor(currentAimTarget.y);
			float num2 = Mathf.Floor(currentAimTarget.z);
			if (num2 == -1f)
			{
				currentAimTarget.z = -0.5f;
			}
			else if (num2 == 0f)
			{
				currentAimTarget.z = 0.5f;
			}
			else if (currentAimTarget.z >= 0f)
			{
				currentAimTarget.z += 0.5f - currentAimTarget.z % Mathf.Floor(currentAimTarget.z);
			}
			else
			{
				currentAimTarget.z += Mathf.Abs(currentAimTarget.z) % Mathf.Floor(Mathf.Abs(currentAimTarget.z)) - 0.5f;
			}
			if (flag)
			{
				Debug.Log((object)$"getAimedLocationForPasting() - currentAim After Z Adjust: {currentAimTarget}");
			}
			return currentAimTarget;
		}

		public static Vector3Int getRoundedAimLocation()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_001b: 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)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			Vector3 currentAimTarget = Player.instance.builder.CurrentAimTarget;
			Vector3Int result = default(Vector3Int);
			((Vector3Int)(ref result)).x = (int)((currentAimTarget.x >= 0f) ? Math.Floor(currentAimTarget.x) : Math.Ceiling(currentAimTarget.x));
			((Vector3Int)(ref result)).y = (int)((currentAimTarget.y >= 0f) ? Math.Floor(currentAimTarget.y) : Math.Ceiling(currentAimTarget.y));
			((Vector3Int)(ref result)).z = (int)((currentAimTarget.z >= 0f) ? Math.Floor(currentAimTarget.z) : Math.Ceiling(currentAimTarget.z));
			return result;
		}

		public static Vector3Int getMinPosOfAimedMachine()
		{
			//IL_0028: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			FieldInfo field = typeof(PlayerInteraction).GetField("targetMachineRef", BindingFlags.Instance | BindingFlags.NonPublic);
			GenericMachineInstanceRef val = (GenericMachineInstanceRef)field.GetValue(Player.instance.interaction);
			return ((GenericMachineInstanceRef)(ref val)).GetGridInfo().minPos;
		}

		public static Vector3Int getAboveMinPosOfAimedMachine()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Vector3Int minPosOfAimedMachine = getMinPosOfAimedMachine();
			int y = ((Vector3Int)(ref minPosOfAimedMachine)).y + 1;
			((Vector3Int)(ref minPosOfAimedMachine)).y = y;
			return minPosOfAimedMachine;
		}

		public static Vector3 ClampToAxis(Vector3 vector)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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)
			vector.x = Mathf.RoundToInt(vector.x);
			vector.y = Mathf.RoundToInt(vector.y);
			vector.z = Mathf.RoundToInt(vector.z);
			return vector;
		}
	}
	[Serializable]
	public class Blueprint
	{
		public int id = -1;

		public int parentId;

		public string name = "New Blueprint";

		public string icon;

		public string description;

		public string size;

		public int rotation = 0;

		public List<uint> machineIDs = new List<uint>();

		public List<int> machineIndexes = new List<int>();

		public List<int> machineResIDs = new List<int>();

		public List<int> machineTypes = new List<int>();

		public List<int> machineRotations = new List<int>();

		public List<int> machineRecipes = new List<int>();

		public List<int> machineVariationIndexes = new List<int>();

		public List<string> machineDimensions = new List<string>();

		public List<int> conveyorShapes = new List<int>();

		public List<bool> conveyorBuildBackwards = new List<bool>();

		public List<int> conveyorHeights = new List<int>();

		public List<bool> conveyorInputBottoms = new List<bool>();

		public List<int> conveyorTopYawRots = new List<int>();

		public List<int> chestSizes = new List<int>();

		public List<string> machineRelativePositions = new List<string>();

		private Dictionary<uint, int> newMachineRotations = new Dictionary<uint, int>();

		private MyVector3 ninetyDegSize;

		private MyVector3 oneEightyDegSize;

		private MyVector3 twoSeventyDegSize;

		public string ToJson(bool formatted = false)
		{
			return JsonUtility.ToJson((object)this, formatted);
		}

		public List<MachineCost> GetCost()
		{
			List<MachineCost> list = new List<MachineCost>();
			Dictionary<int, int> dictionary = new Dictionary<int, int>();
			foreach (int machineResID in machineResIDs)
			{
				if (dictionary.ContainsKey(machineResID))
				{
					int key = machineResID;
					int value = dictionary[key] + 1;
					dictionary[key] = value;
				}
				else
				{
					dictionary[machineResID] = 1;
				}
			}
			foreach (KeyValuePair<int, int> item in dictionary)
			{
				bool affordable = ((InventoryWrapper)Player.instance.inventory).HasResources(item.Key, item.Value, (List<NetworkInventorySlot>)null);
				list.Add(new MachineCost(item.Key, item.Value, affordable));
			}
			return list;
		}

		public bool CanAfford(bool notify = false)
		{
			List<MachineCost> list = (from machine in GetCost()
				where !machine.affordable
				select machine).ToList();
			if (list.Count == 0)
			{
				return true;
			}
			foreach (MachineCost item in list)
			{
				ResourceInfo resInfoFromId = SaveState.GetResInfoFromId(item.resId);
				int resourceCount = ((InventoryWrapper)Player.instance.inventory).GetResourceCount(item.resId, false);
				BlueprintsPlugin.Notify($"Missing {resInfoFromId.displayName} {resourceCount} / {item.count}");
			}
			return false;
		}

		public void RotateCW()
		{
			rotation++;
			if (rotation == 4)
			{
				rotation = 0;
			}
			foreach (uint machineID in machineIDs)
			{
				if (!newMachineRotations.ContainsKey(machineID))
				{
					newMachineRotations.Add(machineID, 90);
				}
				else
				{
					newMachineRotations[machineID] += 90;
				}
			}
		}

		public void RotateCCW()
		{
			rotation--;
			if (rotation == -1)
			{
				rotation = 3;
			}
			foreach (uint machineID in machineIDs)
			{
				if (!newMachineRotations.ContainsKey(machineID))
				{
					newMachineRotations.Add(machineID, -90);
				}
				else
				{
					newMachineRotations[machineID] -= 90;
				}
			}
		}

		public MyVector3 GetSize()
		{
			return new MyVector3(size);
		}

		public void SetSize(Vector3 newSize)
		{
			//IL_0007: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			size = $"{Mathf.RoundToInt(newSize.x)},{Mathf.RoundToInt(newSize.y)},{Mathf.RoundToInt(newSize.z)}";
			ninetyDegSize = new MyVector3
			{
				x = Mathf.RoundToInt(newSize.z),
				y = Mathf.RoundToInt(newSize.y),
				z = Mathf.RoundToInt(0f - newSize.x)
			};
			oneEightyDegSize = new MyVector3
			{
				x = Mathf.RoundToInt(0f - newSize.x),
				y = Mathf.RoundToInt(newSize.y),
				z = Mathf.RoundToInt(0f - newSize.z)
			};
			twoSeventyDegSize = new MyVector3
			{
				x = Mathf.RoundToInt(0f - newSize.z),
				y = Mathf.RoundToInt(newSize.y),
				z = Mathf.RoundToInt(newSize.x)
			};
		}

		public Vector3Int GetRotatedSize()
		{
			//IL_0028: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			return (Vector3Int)(rotation switch
			{
				1 => ninetyDegSize.asUnityVector3Int(), 
				2 => oneEightyDegSize.asUnityVector3Int(), 
				3 => twoSeventyDegSize.asUnityVector3Int(), 
				_ => GetSize().asUnityVector3Int(), 
			});
		}

		public int GetMachineRotation(uint instanceId)
		{
			if (newMachineRotations.ContainsKey(instanceId))
			{
				return newMachineRotations[instanceId];
			}
			return 0;
		}

		public Vector3 GetMachineDimensions(int index)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			switch (rotation)
			{
			case 0:
			case 2:
				return new MyVector3(machineDimensions[index]).AsUnityVector3();
			case 1:
			case 3:
			{
				MyVector3 myVector = new MyVector3(machineDimensions[index]);
				Vector3 result = default(Vector3);
				result.x = myVector.z;
				result.y = myVector.y;
				result.z = myVector.x;
				return result;
			}
			default:
				return Vector3.zero;
			}
		}

		public void ClearMachineRotations()
		{
			newMachineRotations.Clear();
		}

		public List<Vector3> GetMachineRelativePositions()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: 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_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			foreach (string machineRelativePosition in machineRelativePositions)
			{
				list2.Add(new MyVector3(machineRelativePosition).AsUnityVector3());
			}
			switch (rotation)
			{
			case 0:
				list = list2;
				break;
			case 1:
				foreach (Vector3 item in list2)
				{
					list.Add(new Vector3
					{
						x = item.z,
						y = item.y,
						z = 0f - item.x
					});
				}
				break;
			case 2:
				foreach (Vector3 item2 in list2)
				{
					list.Add(new Vector3
					{
						x = 0f - item2.x,
						y = item2.y,
						z = 0f - item2.z
					});
				}
				break;
			case 3:
				foreach (Vector3 item3 in list2)
				{
					list.Add(new Vector3
					{
						x = 0f - item3.z,
						y = item3.y,
						z = item3.x
					});
				}
				break;
			}
			return list;
		}

		public static Blueprint CreateFromClipboard()
		{
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			Blueprint blueprint = new Blueprint
			{
				id = -1,
				parentId = BookManager.currentBookId,
				name = "New Blueprint",
				icon = "",
				description = "",
				rotation = 0,
				machineIDs = BlueprintsPlugin.clipboard.machineIDs,
				machineIndexes = BlueprintsPlugin.clipboard.machineIndexes,
				machineResIDs = BlueprintsPlugin.clipboard.machineResIDs,
				machineTypes = BlueprintsPlugin.clipboard.machineTypes,
				machineRotations = BlueprintsPlugin.clipboard.machineRotations,
				machineRecipes = BlueprintsPlugin.clipboard.machineRecipes,
				machineVariationIndexes = BlueprintsPlugin.clipboard.machineVariationIndexes,
				machineDimensions = BlueprintsPlugin.clipboard.machineDimensions,
				conveyorShapes = BlueprintsPlugin.clipboard.conveyorShapes,
				conveyorBuildBackwards = BlueprintsPlugin.clipboard.conveyorBuildBackwards,
				conveyorHeights = BlueprintsPlugin.clipboard.conveyorHeights,
				conveyorInputBottoms = BlueprintsPlugin.clipboard.conveyorInputBottoms,
				conveyorTopYawRots = BlueprintsPlugin.clipboard.conveyorTopYawRots,
				chestSizes = BlueprintsPlugin.clipboard.chestSizes,
				machineRelativePositions = BlueprintsPlugin.clipboard.machineRelativePositions
			};
			blueprint.SetSize(BlueprintsPlugin.clipboard.GetSize().AsUnityVector3());
			return blueprint;
		}
	}
	[Serializable]
	public struct MachineCost
	{
		public int resId;

		public int count;

		public bool affordable;

		public MachineCost(int _resId, int _count, bool _affordable)
		{
			resId = _resId;
			count = _count;
			affordable = _affordable;
		}
	}
	[Serializable]
	public class MyVector3
	{
		public float x;

		public float y;

		public float z;

		public MyVector3()
		{
		}

		public MyVector3(Vector3 unityVector)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			x = unityVector.x;
			y = unityVector.y;
			z = unityVector.z;
		}

		public MyVector3(Vector3Int unityVector)
		{
			x = ((Vector3Int)(ref unityVector)).x;
			y = ((Vector3Int)(ref unityVector)).y;
			z = ((Vector3Int)(ref unityVector)).z;
		}

		public MyVector3(string input)
		{
			string[] array = input.Split(new char[1] { ',' });
			x = float.Parse(array[0]);
			y = float.Parse(array[1]);
			z = float.Parse(array[2]);
		}

		public override string ToString()
		{
			return $"{x},{y},{z}";
		}

		public Vector3 AsUnityVector3()
		{
			//IL_0013: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(x, y, z);
		}

		public Vector3Int asUnityVector3Int()
		{
			//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)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3Int(Mathf.RoundToInt(x), Mathf.RoundToInt(y), Mathf.RoundToInt(z));
		}

		public static MyVector3 operator /(MyVector3 vector, float f)
		{
			return new MyVector3
			{
				x = vector.x / f,
				y = vector.y / f,
				z = vector.z / f
			};
		}
	}
	[Serializable]
	public class BlueprintBook
	{
		public int id = -1;

		public int parentId = -1;

		public string name = "New Book";

		public string icon;

		public string description;

		public List<string> slots = new List<string>();

		public void AddBlueprint(int blueprintId)
		{
			slots.Add(new Slot
			{
				blueprintId = blueprintId
			}.ToString());
		}

		public void RemoveBlueprint(int blueprintId)
		{
			Debug.Log((object)$"Removing blueprint #{blueprintId}");
			for (int i = 0; i < slots.Count; i++)
			{
				Debug.Log((object)("Checking slot '" + slots[i] + "'"));
				Debug.Log((object)("Checking id '" + slots[i].Split(new char[1] { ',' })[0] + "'"));
				if (slots[i].Split(new char[1] { ',' })[0] == blueprintId.ToString())
				{
					Debug.Log((object)"Match found, removing");
					slots.RemoveAt(i);
					break;
				}
			}
		}

		public void AddBook(int bookId)
		{
			slots.Add(new Slot
			{
				bookId = bookId
			}.ToString());
		}

		public void RemoveBook(int bookId)
		{
			for (int i = 0; i < slots.Count; i++)
			{
				if (slots[i].Split(new char[1] { ',' })[1] == bookId.ToString())
				{
					slots.RemoveAt(i);
					break;
				}
			}
		}

		public List<Slot> GetSlots()
		{
			List<Slot> list = new List<Slot>();
			foreach (string slot in slots)
			{
				list.Add(new Slot(slot));
			}
			return list;
		}

		public BlueprintBook GetParent()
		{
			return BookManager.TryGetBook(parentId);
		}

		public string GetPath()
		{
			List<string> list = new List<string> { name };
			BlueprintBook blueprintBook = this;
			while (blueprintBook.parentId != -1)
			{
				BlueprintBook parent = blueprintBook.GetParent();
				list.Insert(0, parent.name);
				blueprintBook = parent;
			}
			return string.Join(" > ", list);
		}

		public string ToJson(bool formatted = false)
		{
			return JsonUtility.ToJson((object)this, formatted);
		}

		public void AddBlueprint(Blueprint blueprint)
		{
			AddBlueprint(blueprint.id);
		}

		public void RemoveBlueprint(Blueprint blueprint)
		{
			RemoveBlueprint(blueprint.id);
		}

		public void AddBook(BlueprintBook book)
		{
			AddBook(book.id);
		}

		public void RemoveBook(BlueprintBook book)
		{
			RemoveBook(book.id);
		}
	}
	[Serializable]
	public class Slot
	{
		public int blueprintId = -1;

		public int bookId = -1;

		public SlotType GetSlotType()
		{
			if (blueprintId != -1)
			{
				return SlotType.Blueprint;
			}
			if (bookId != -1)
			{
				return SlotType.Book;
			}
			return SlotType.None;
		}

		public override string ToString()
		{
			return $"{blueprintId},{bookId}";
		}

		public Slot()
		{
		}

		public Slot(string input)
		{
			string[] array = input.Split(new char[1] { ',' });
			blueprintId = int.Parse(array[0]);
			bookId = int.Parse(array[1]);
		}
	}
	public enum SlotType
	{
		None,
		Blueprint,
		Book
	}
	[BepInPlugin("com.equinox.Blueprints", "Blueprints", "5.0.0")]
	public class BlueprintsPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.equinox.Blueprints";

		private const string PluginName = "Blueprints";

		private const string VersionString = "5.0.0";

		private static readonly Harmony Harmony = new Harmony("com.equinox.Blueprints");

		public static ManualLogSource Log = new ManualLogSource("Blueprints");

		private static string copyShortcutKey = "Copy Shortcut";

		private static string pasteShortcutKey = "Paste Shortcut";

		private static string cancelShortcutKey = "Cancel Shortcut";

		private static string cwRotateKey = "CW Rotation Shortcut";

		private static string ccwRotateKey = "CCW Rotation Shortcut";

		private static string blueprintsKey = "Open Blueprints Shortcut";

		private static string lockPositionKey = "Lock Position";

		private static string nudgeLeftKey = "Nudge Left";

		private static string nudgeRightKey = "Nudge Right";

		private static string nudgeForwardKey = "Nudge Forward";

		private static string nudgeBackwardKey = "Nudge Backward";

		private static string nudgeUpKey = "Nudge Up";

		private static string nudgeDownKey = "Nudge Down";

		private static string shrinkLeftKey = "Shrink Copy Region Left";

		private static string shrinkRightKey = "Shrink Copy Region Right";

		private static string shrinkForwardKey = "Shrink Copy Region Forward";

		private static string shrinkBackwardKey = "Shrink Copy Region Backward";

		private static string shrinkUpKey = "Shrink Copy Region Up";

		private static string shrinkDownKey = "Shrink Copy Region Down";

		public static ConfigEntry<KeyboardShortcut> copyShortcut;

		public static ConfigEntry<KeyboardShortcut> pasteShortcut;

		public static ConfigEntry<KeyboardShortcut> cancelShortcut;

		public static ConfigEntry<KeyboardShortcut> cwRotateShortcut;

		public static ConfigEntry<KeyboardShortcut> ccwRotateShortcut;

		public static ConfigEntry<KeyboardShortcut> blueprintsShortcut;

		public static ConfigEntry<KeyboardShortcut> lockPositionShortcut;

		public static ConfigEntry<KeyboardShortcut> nudgeLeftShortcut;

		public static ConfigEntry<KeyboardShortcut> nudgeRightShortcut;

		public static ConfigEntry<KeyboardShortcut> nudgeForwardShortcut;

		public static ConfigEntry<KeyboardShortcut> nudgeBackwardShortcut;

		public static ConfigEntry<KeyboardShortcut> nudgeUpShortcut;

		public static ConfigEntry<KeyboardShortcut> nudgeDownShortcut;

		public static ConfigEntry<KeyboardShortcut> shrinkLeftShortcut;

		public static ConfigEntry<KeyboardShortcut> shrinkRightShortcut;

		public static ConfigEntry<KeyboardShortcut> shrinkForwardShortcut;

		public static ConfigEntry<KeyboardShortcut> shrinkBackwardShortcut;

		public static ConfigEntry<KeyboardShortcut> shrinkUpShortcut;

		public static ConfigEntry<KeyboardShortcut> shrinkDownShortcut;

		public static Blueprint clipboard = null;

		public static List<IMachineInstanceRef> machinesToCopy = new List<IMachineInstanceRef>();

		private float sSinceLastBuild = 0f;

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: Blueprints, VersionString: 5.0.0 is loading...");
			Harmony.PatchAll();
			BindConfigEntries();
			ApplyPatches();
			BlueprintsLibraryGUI.LoadTextures();
			BlueprintManager.LoadData();
			BookManager.LoadData();
			FixParentIds();
			if (BookManager.GetBookCount() == 0)
			{
				BookManager.AddBook(new BlueprintBook
				{
					name = "All Blueprints"
				});
			}
			BookManager.currentBookId = 0;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: Blueprints, VersionString: 5.0.0 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
		}

		private void Update()
		{
			HandleInput();
			if (MachineCopier.isCopying)
			{
				MachineCopier.UpdateEndPosition();
			}
			if (MachinePaster.isPasting)
			{
				MachinePaster.UpdateHolograms();
			}
		}

		private void FixedUpdate()
		{
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			if (machinesToCopy.Count != 0)
			{
				IMachineInstanceRef machine = machinesToCopy[0];
				AddMachineToBlueprint(machine);
				machinesToCopy.RemoveAt(0);
				if (machinesToCopy.Count == 0)
				{
					Notify("Region copied!");
				}
			}
			sSinceLastBuild += Time.deltaTime;
			for (int i = 0; i < BuildQueue.queuedBuildings.Count; i++)
			{
				EDT.PacedLog("Fixed Update", $"Processing build index {i}", 1f);
				if (ShouldBuild(i))
				{
					EDT.PacedLog("Fixed Update", $"Build index {i} should be built", 1f);
					BuildQueue.HideHologram(i);
					EDT.PacedLog("Fixed Update", "Hid hologram", 1f);
					List<Vector3Int> list = new List<Vector3Int>();
					EDT.PacedLog("Fixed Update", "Checking buildable", 1f);
					if (GridManager.instance.CheckBuildableAt(BuildQueue.queuedBuildings[i].gridInfo, ref list))
					{
						EDT.PacedLog("Fixed Update", "Is buildable, building", 1f);
						BuildBuilding(BuildQueue.queuedBuildings[i]);
						EDT.PacedLog("Fixed Update", "Built", 1f);
					}
					EDT.PacedLog("Fixed Update", $"Removing building index {i} from queue", 1f);
					BuildQueue.queuedBuildings.RemoveAt(i);
					EDT.PacedLog("Fixed Update", $"Removed building index {i} from queue", 1f);
					sSinceLastBuild = 0f;
					break;
				}
			}
			if (BuildQueue.queuedBuildings.Count == 0 && BuildQueue.holograms.Count != 0)
			{
				BuildQueue.ClearHolograms();
			}
		}

		private void OnGUI()
		{
			ControlsGUI.DrawControlsGUI();
			if (BlueprintsLibraryGUI.shouldShow)
			{
				BlueprintsLibraryGUI.DrawGUI();
			}
			else if (BuildQueue.shouldShowBuildQueue)
			{
				BuildQueue.ShowBuildQueue();
			}
		}

		public static void Notify(string message)
		{
			UIManager.instance.systemLog.FlashMessage((SystemMessageInfo)(object)new CustomSystemMessage(message));
		}

		private void BindConfigEntries()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			copyShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", copyShortcutKey, new KeyboardShortcut((KeyCode)99, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
			pasteShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", pasteShortcutKey, new KeyboardShortcut((KeyCode)118, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
			cancelShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", cancelShortcutKey, new KeyboardShortcut((KeyCode)8, Array.Empty<KeyCode>()), (ConfigDescription)null);
			cwRotateShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", cwRotateKey, new KeyboardShortcut((KeyCode)122, Array.Empty<KeyCode>()), (ConfigDescription)null);
			ccwRotateShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", ccwRotateKey, new KeyboardShortcut((KeyCode)122, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
			blueprintsShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", blueprintsKey, new KeyboardShortcut((KeyCode)120, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
			lockPositionShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Nudge", lockPositionKey, new KeyboardShortcut((KeyCode)110, Array.Empty<KeyCode>()), (ConfigDescription)null);
			nudgeLeftShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Nudge", nudgeLeftKey, new KeyboardShortcut((KeyCode)276, Array.Empty<KeyCode>()), (ConfigDescription)null);
			nudgeRightShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Nudge", nudgeRightKey, new KeyboardShortcut((KeyCode)275, Array.Empty<KeyCode>()), (ConfigDescription)null);
			nudgeForwardShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Nudge", nudgeForwardKey, new KeyboardShortcut((KeyCode)273, Array.Empty<KeyCode>()), (ConfigDescription)null);
			nudgeBackwardShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Nudge", nudgeBackwardKey, new KeyboardShortcut((KeyCode)274, Array.Empty<KeyCode>()), (ConfigDescription)null);
			nudgeUpShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Nudge", nudgeUpKey, new KeyboardShortcut((KeyCode)273, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), (ConfigDescription)null);
			nudgeDownShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Nudge", nudgeDownKey, new KeyboardShortcut((KeyCode)274, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), (ConfigDescription)null);
			shrinkLeftShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Shrink Copy Region", shrinkLeftKey, new KeyboardShortcut((KeyCode)276, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
			shrinkRightShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Shrink Copy Region", shrinkRightKey, new KeyboardShortcut((KeyCode)275, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
			shrinkForwardShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Shrink Copy Region", shrinkForwardKey, new KeyboardShortcut((KeyCode)273, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
			shrinkBackwardShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Shrink Copy Region", shrinkBackwardKey, new KeyboardShortcut((KeyCode)274, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
			shrinkUpShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Shrink Copy Region", shrinkUpKey, new KeyboardShortcut((KeyCode)273, (KeyCode[])(object)new KeyCode[2]
			{
				(KeyCode)304,
				(KeyCode)306
			}), (ConfigDescription)null);
			shrinkDownShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Shrink Copy Region", shrinkDownKey, new KeyboardShortcut((KeyCode)274, (KeyCode[])(object)new KeyCode[2]
			{
				(KeyCode)304,
				(KeyCode)306
			}), (ConfigDescription)null);
		}

		private void ApplyPatches()
		{
			Harmony.CreateAndPatchAll(typeof(PlayerBuilderPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(PlayerInspectorPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(PlayerInteractionPatch), (string)null);
		}

		private void HandleInput()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = copyShortcut.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && !BlueprintsLibraryGUI.shouldShow && !MachinePaster.isPasting)
			{
				if (!MachineCopier.isCopying)
				{
					MachineCopier.StartCopying();
				}
				else
				{
					MachineCopier.EndCopying();
				}
			}
			value = pasteShortcut.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && !BlueprintsLibraryGUI.shouldShow && !MachineCopier.isCopying)
			{
				if (!MachinePaster.isPasting)
				{
					if (clipboard.CanAfford(notify: true))
					{
						MachinePaster.StartPasting();
					}
					else
					{
						((FMODAudioSource)(ref Player.instance.audio.buildError)).PlayRandomClip(true);
					}
				}
				else
				{
					MachinePaster.EndPasting();
				}
			}
			value = lockPositionShortcut.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && !BlueprintsLibraryGUI.shouldShow && MachinePaster.isPasting)
			{
				MachinePaster.isPositionLocked = !MachinePaster.isPositionLocked;
			}
			value = blueprintsShortcut.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				BlueprintsLibraryGUI.shouldShow = !BlueprintsLibraryGUI.shouldShow;
				EMU.FreeCursor(BlueprintsLibraryGUI.shouldShow);
			}
		}

		private void AddMachineToBlueprint(IMachineInstanceRef machine)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected I4, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected I4, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: 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_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Expected I4, but got Unknown
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			clipboard.machineIDs.Add(machine.instanceId);
			clipboard.machineIndexes.Add(machine.index);
			clipboard.machineResIDs.Add(machine.GetCommonInfo().resId);
			clipboard.machineTypes.Add((int)machine.typeIndex);
			clipboard.machineRotations.Add(machine.GetGridInfo().yawRot);
			clipboard.machineDimensions.Add(GetDimensions(machine).ToString());
			clipboard.machineVariationIndexes.Add(machine.GetCommonInfo().variationIndex);
			if (flag)
			{
				string displayName = SaveState.GetResInfoFromId(machine.GetCommonInfo().resId).displayName;
				Debug.Log((object)$"addMachineToBlueprint() machine.instanceId: {machine.instanceId}");
				Debug.Log((object)$"addMachineToBlueprint() machine.index: {machine.index}");
				Debug.Log((object)$"addMachineToBlueprint() machine.resID: {machine.GetCommonInfo().resId}");
				Debug.Log((object)("addMachineToBlueprint() machine.resName: " + displayName));
				Debug.Log((object)$"addMachineToBlueprint() machine.typIndex: {machine.typeIndex}");
				Debug.Log((object)$"addMachineToBlueprint() machine.yawRot: {machine.GetGridInfo().yawRot}");
				Debug.Log((object)$"addMachineToBlueprint() machine.dims: {machine.gridInfo.dims}");
				Debug.Log((object)$"addMachineToBlueprint() machine.variationIndex: {machine.GetCommonInfo().variationIndex}");
			}
			GenericMachineInstanceRef val = machine.AsGeneric();
			MachineTypeEnum typeIndex = machine.typeIndex;
			MachineTypeEnum val2 = typeIndex;
			switch (val2 - 1)
			{
			case 0:
			{
				AssemblerInstance val6 = ((GenericMachineInstanceRef)(ref val)).Get<AssemblerInstance>();
				clipboard.machineRecipes.Add(((Object)(object)val6.targetRecipe == (Object)null) ? (-1) : ((UniqueIdScriptableObject)val6.targetRecipe).uniqueId);
				clipboard.conveyorShapes.Add(0);
				clipboard.conveyorBuildBackwards.Add(item: false);
				clipboard.conveyorHeights.Add(0);
				clipboard.conveyorInputBottoms.Add(item: false);
				clipboard.conveyorTopYawRots.Add(0);
				clipboard.chestSizes.Add(0);
				break;
			}
			case 6:
			{
				InserterInstance val5 = ((GenericMachineInstanceRef)(ref val)).Get<InserterInstance>();
				clipboard.machineRecipes.Add(val5.filterType);
				clipboard.conveyorShapes.Add(0);
				clipboard.conveyorBuildBackwards.Add(item: false);
				clipboard.conveyorHeights.Add(0);
				clipboard.conveyorInputBottoms.Add(item: false);
				clipboard.conveyorTopYawRots.Add(0);
				clipboard.chestSizes.Add(0);
				break;
			}
			case 3:
			{
				ConveyorInstance val4 = ((GenericMachineInstanceRef)(ref val)).Get<ConveyorInstance>();
				clipboard.machineRecipes.Add(0);
				clipboard.conveyorShapes.Add((int)val4.beltShape);
				clipboard.conveyorBuildBackwards.Add(val4.buildBackwards);
				clipboard.conveyorHeights.Add(val4.verticalHeight);
				clipboard.conveyorInputBottoms.Add(val4.inputBottom);
				clipboard.conveyorTopYawRots.Add(val4.topYawRot);
				clipboard.chestSizes.Add(0);
				break;
			}
			case 2:
			{
				ChestInstance val3 = ((GenericMachineInstanceRef)(ref val)).Get<ChestInstance>();
				clipboard.machineRecipes.Add(0);
				clipboard.conveyorShapes.Add(0);
				clipboard.conveyorBuildBackwards.Add(item: false);
				clipboard.conveyorHeights.Add(0);
				clipboard.conveyorInputBottoms.Add(item: false);
				clipboard.conveyorTopYawRots.Add(0);
				clipboard.chestSizes.Add(val3.commonInfo.inventories[0].numSlots);
				break;
			}
			default:
				clipboard.machineRecipes.Add(0);
				clipboard.conveyorShapes.Add(0);
				clipboard.conveyorBuildBackwards.Add(item: false);
				clipboard.conveyorHeights.Add(0);
				clipboard.conveyorInputBottoms.Add(item: false);
				clipboard.conveyorTopYawRots.Add(0);
				clipboard.chestSizes.Add(0);
				break;
			}
		}

		private MyVector3 GetDimensions(IMachineInstanceRef machine)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			switch (machine.gridInfo.yawRot)
			{
			default:
				return new MyVector3(machine.gridInfo.dims);
			case 90:
			case 270:
			{
				Vector3 unityVector = default(Vector3);
				unityVector.x = ((Vector3Int)(ref machine.gridInfo.dims)).z;
				unityVector.y = ((Vector3Int)(ref machine.gridInfo.dims)).y;
				unityVector.z = ((Vector3Int)(ref machine.gridInfo.dims)).x;
				return new MyVector3(unityVector);
			}
			}
		}

		private bool ShouldBuild(int index)
		{
			ResourceInfo resInfoFromId = SaveState.GetResInfoFromId(BuildQueue.queuedBuildings[index].resID);
			return sSinceLastBuild > 0f && ((InventoryWrapper)Player.instance.inventory).HasResources(resInfoFromId, 1);
		}

		private void BuildBuilding(QueuedBuilding building)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Expected I4, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			MachineTypeEnum val = (MachineTypeEnum)(byte)building.type;
			GridInfo gridInfo = building.gridInfo;
			ChainData val2 = default(ChainData);
			val2.count = 1;
			val2.height = building.conveyorHeight;
			val2.shape = (BeltShape)(byte)building.conveyorShape;
			val2.rotation = gridInfo.yawRot;
			ref Vector3Int minPos = ref gridInfo.minPos;
			byte strata = GameState.instance.GetStrata();
			val2.start = new GridPos(ref minPos, ref strata);
			val2.inputBottom = building.conveyorInputBottom;
			val2.topYawRot = building.conveyorTopYawRot;
			ChainData value = val2;
			if (flag)
			{
				Debug.Log((object)$"id: {building.machineID}");
				Debug.Log((object)$"resID: {building.resID}");
				Debug.Log((object)$"type: {val}");
				Debug.Log((object)$"yawRotation: {gridInfo.yawRot}");
				Debug.Log((object)$"recipe: {building.recipe}");
				Debug.Log((object)$"gridInfo.minPos: {gridInfo.minPos}");
				Debug.Log((object)$"buildBackwards: {building.conveyorBuildBackwards}");
			}
			MachineTypeEnum val3 = val;
			MachineTypeEnum val4 = val3;
			switch (val4 - 1)
			{
			case 1:
			case 2:
			case 4:
			case 7:
			case 9:
			case 11:
			case 15:
			case 18:
			case 20:
			case 23:
			case 25:
			case 31:
			case 32:
			case 33:
			case 34:
				EMUBuilder.BuildMachine(building.resID, gridInfo, false, -1, -1, (ChainData?)null, false);
				break;
			case 21:
			case 30:
				EMUBuilder.BuildMachine(building.resID, gridInfo, false, building.variationIndex, -1, (ChainData?)null, false);
				break;
			case 0:
			case 6:
				EMUBuilder.BuildMachine(building.resID, gridInfo, false, -1, building.recipe, (ChainData?)null, false);
				break;
			case 3:
				EMUBuilder.BuildMachine(building.resID, gridInfo, false, -1, -1, (ChainData?)value, building.conveyorBuildBackwards);
				break;
			default:
				Debug.Log((object)("Unsupported machine type '" + SaveState.GetResInfoFromId(building.resID).displayName + "'"));
				break;
			}
			sSinceLastBuild = 0f;
		}

		private void FixParentIds()
		{
			List<BlueprintBook> allBooks = BookManager.GetAllBooks();
			foreach (Blueprint allBlueprint in BlueprintManager.GetAllBlueprints())
			{
				if (allBlueprint.parentId != 0 || BookManager.GetRootBook().slots.Contains($"{allBlueprint.id},-1"))
				{
					continue;
				}
				foreach (BlueprintBook item in allBooks)
				{
					if (item.slots.Contains($"{allBlueprint.id},-1"))
					{
						allBlueprint.parentId = item.id;
						BlueprintManager.UpdateBlueprint(allBlueprint);
					}
				}
			}
		}
	}
	public class CustomSystemMessage : SystemMessageInfo
	{
		public override MessageType type => (MessageType)5;

		public CustomSystemMessage(string message)
			: base(message)
		{
		}
	}
	public static class BuildQueue
	{
		public static List<QueuedBuilding> queuedBuildings = new List<QueuedBuilding>();

		public static List<StreamedHologramData> holograms = new List<StreamedHologramData>();

		public static bool shouldShowBuildQueue => queuedBuildings.Count != 0;

		public static void ShowBuildQueue()
		{
		}

		public static void HideHologram(int index)
		{
			holograms[index].AbandonHologramPreview(false);
			holograms.RemoveAt(index);
		}

		public static void ClearHolograms()
		{
			foreach (StreamedHologramData hologram in holograms)
			{
				hologram.AbandonHologramPreview(false);
			}
			holograms.Clear();
		}

		private static string GetItemHaveNeed(int resID)
		{
			return $"{((InventoryWrapper)Player.instance.inventory).GetResourceCount(resID, false)} / {queuedBuildings.Where((QueuedBuilding machine) => machine.resID == resID).Count()}";
		}
	}
	public class QueuedBuilding
	{
		public uint machineID;

		public int index;

		public int resID;

		public int type;

		public int rotation;

		public int recipe;

		public int variationIndex;

		public MyVector3 dimensions;

		public int conveyorShape;

		public bool conveyorBuildBackwards;

		public int conveyorHeight;

		public bool conveyorInputBottom;

		public int conveyorTopYawRot;

		public int chestSize;

		public GridInfo gridInfo;
	}
	public static class ControlsGUI
	{
		private static List<DynamicControl> controlsToRender = new List<DynamicControl>();

		private static Texture2D shaderTile;

		private static Dictionary<KeyCode, Texture2D> keyTextures = new Dictionary<KeyCode, Texture2D>();

		private static GUIStyle labelStyle;

		public static void DrawControlsGUI()
		{
			InitialiseStyles();
			if (!LoadingStates.hasGameLoaded || BlueprintsLibraryGUI.shouldShow || BlueprintsPlugin.machinesToCopy.Count != 0 || BuildQueue.queuedBuildings.Count != 0)
			{
				return;
			}
			RefreshControls();
			for (int i = 0; i < controlsToRender.Count; i++)
			{
				if (controlsToRender[i] != null)
				{
					DrawControl(controlsToRender[i], i);
				}
			}
		}

		private static void InitialiseStyles()
		{
			//IL_08da: Unknown result type (might be due to invalid IL or missing references)
			//IL_08df: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_090e: Expected O, but got Unknown
			if (labelStyle == null)
			{
				keyTextures.Add((KeyCode)59, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.;.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)91, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.[.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)93, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.].png", false, (Assembly)null));
				keyTextures.Add((KeyCode)48, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.0.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)49, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.1.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)50, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.2.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)51, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.3.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)52, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.4.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)53, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.5.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)54, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.6.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)55, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.7.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)56, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.8.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)57, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.9.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)282, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F1.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)283, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F2.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)284, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F3.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)285, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F4.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)286, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F5.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)287, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F6.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)288, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F7.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)289, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F8.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)290, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F9.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)291, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F10.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)292, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F11.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)293, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F12.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)97, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.A.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)98, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.B.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)99, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.C.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)100, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.D.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)101, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.E.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)102, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.F.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)103, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.G.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)104, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.H.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)105, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.I.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)106, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.J.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)107, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.K.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)108, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.L.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)109, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.M.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)110, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.N.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)111, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.O.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)112, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.P.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)113, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Q.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)114, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.R.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)115, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.S.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)116, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.T.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)117, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.U.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)118, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.V.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)119, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.W.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)120, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.X.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)121, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Y.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)122, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Z.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)273, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Up.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)274, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Down.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)276, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Left.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)275, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Right.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)308, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Alt.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)304, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Shift.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)306, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Control.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)307, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Alt.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)303, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Shift.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)305, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Control.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)92, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Backslash.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)8, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Backspace.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)301, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Capslock.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)127, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Delete.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)279, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.End.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)13, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Enter.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)271, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Keypad_Enter.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)47, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Forwardslash.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)62, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.GreaterThan.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)278, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Home.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)277, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Insert.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)60, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.LessThan.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)45, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Minus.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)269, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Minus.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)268, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Multiply.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)300, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Numlock.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)281, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.PageDown.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)280, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.PageUp.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)43, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Plus.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)316, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.PrintScreen.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)63, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Question.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)39, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Quotation.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)32, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Space.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)9, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Tab.png", false, (Assembly)null));
				keyTextures.Add((KeyCode)126, Images.LoadTexture2DFromFile("Blueprints.Images.Keys.Tilde.png", false, (Assembly)null));
				GUIStyle val = new GUIStyle
				{
					fontSize = 16,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
				val.normal.textColor = Color.yellow;
				labelStyle = val;
				shaderTile = Images.LoadTexture2DFromFile("Blueprints.Images.ShaderTile.png", false, (Assembly)null);
			}
		}

		private static void RefreshControls()
		{
			controlsToRender.Clear();
			if (!MachineCopier.isCopying && !MachinePaster.isPasting)
			{
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.copyShortcut, "Start Copying"));
				if (BlueprintsPlugin.clipboard != null)
				{
					controlsToRender.Add(new DynamicControl(BlueprintsPlugin.pasteShortcut, "Start Pasting"));
				}
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.blueprintsShortcut, "Open Blueprints Library"));
			}
			else if (MachineCopier.isCopying)
			{
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.copyShortcut, "Finish Copying"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.cancelShortcut, "Cancel Copying"));
				controlsToRender.Add(null);
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeForwardShortcut, "Expand Forwards"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeBackwardShortcut, "Expand Backwards"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeLeftShortcut, "Expand Left"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeRightShortcut, "Expand Right"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeUpShortcut, "Expand Up"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeDownShortcut, "Expand Down"));
				controlsToRender.Add(null);
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.shrinkForwardShortcut, "Shrink Forwards"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.shrinkBackwardShortcut, "Shrink Backwards"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.shrinkLeftShortcut, "Shrink Left"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.shrinkRightShortcut, "Shrink Right"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.shrinkUpShortcut, "Shrink Up"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.shrinkDownShortcut, "Shrink Down"));
			}
			else if (MachinePaster.isPasting)
			{
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.pasteShortcut, "Place Blueprint"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.cancelShortcut, "Cancel Pasting"));
				controlsToRender.Add(null);
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.cwRotateShortcut, "Rotate CW"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.ccwRotateShortcut, "Rotate CCW"));
				controlsToRender.Add(null);
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.lockPositionShortcut, "Lock Mouse Aiming"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeForwardShortcut, "Nudge Forwards"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeBackwardShortcut, "Nudge Backwards"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeLeftShortcut, "Nudge Left"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeRightShortcut, "Nudge Right"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeUpShortcut, "Nudge Up"));
				controlsToRender.Add(new DynamicControl(BlueprintsPlugin.nudgeDownShortcut, "Nudge Down"));
			}
		}

		private static void DrawControl(DynamicControl control, int index)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			float num = Screen.height - (controlsToRender.Count - index) * 45;
			float num2 = 5f;
			for (int num3 = control.keyCodes.Length - 1; num3 >= 0; num3--)
			{
				Texture2D val = keyTextures[control.keyCodes[num3]];
				int num4 = (int)((double)((Texture)val).width * (40.0 / (double)((Texture)val).height));
				num2 += (float)(num4 + 5);
				GUIStyle val2 = new GUIStyle();
				val2.normal.background = val;
				GUIStyle val3 = val2;
				GUI.Box(new Rect((float)Screen.width - num2, num, (float)num4, 40f), "", val3);
			}
			float x = labelStyle.CalcSize(new GUIContent(control.action)).x;
			float num5 = (float)Screen.width - num2 - x - 10f;
			GUI.Label(new Rect(num5, num, x, 40f), control.action, labelStyle);
		}
	}
	public class DynamicControl
	{
		public KeyCode[] keyCodes;

		public string action;

		public DynamicControl(KeyCode[] _keyCodes, string _action)
		{
			keyCodes = _keyCodes;
			action = _action;
		}

		public DynamicControl(KeyCode keyCode, string _action)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected I4, but got Unknown
			keyCodes = (KeyCode[])(object)new KeyCode[1] { (KeyCode)(int)keyCode };
			action = _action;
		}

		public DynamicControl(KeyCode[] modifiers, KeyCode keyCode, string _action)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected I4, but got Unknown
			KeyCode[] array = (KeyCode[])(object)new KeyCode[modifiers.Length + 1];
			for (int i = 0; i < modifiers.Length; i++)
			{
				array[i] = modifiers[i];
			}
			array[^1] = (KeyCode)(int)keyCode;
			keyCodes = array;
			action = _action;
		}

		public DynamicControl(ConfigEntry<KeyboardShortcut> configEntry, string _action)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected I4, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_009a: Expected I4, but got Unknown
			action = _action;
			KeyboardShortcut value = configEntry.Value;
			if (((KeyboardShortcut)(ref value)).Modifiers == null)
			{
				KeyCode[] array = new KeyCode[1];
				value = configEntry.Value;
				array[0] = (KeyCode)(int)((KeyboardShortcut)(ref value)).MainKey;
				keyCodes = (KeyCode[])(object)array;
				return;
			}
			value = configEntry.Value;
			KeyCode[] array2 = ((KeyboardShortcut)(ref value)).Modifiers.ToArray();
			KeyCode[] array3 = (KeyCode[])(object)new KeyCode[array2.Length + 1];
			for (int i = 0; i < array2.Length; i++)
			{
				array3[i] = array2[i];
			}
			int num = array3.Length - 1;
			value = configEntry.Value;
			array3[num] = (KeyCode)(int)((KeyboardShortcut)(ref value)).MainKey;
			keyCodes = array3;
		}
	}
	public static class MachineCopier
	{
		public static bool isCopying;

		private static Vector3 copyRegionStart;

		private static Vector3 copyRegionEnd;

		private static Vector3 copyRegionAnchor;

		private static Bounds copyRegionBounds;

		private static GameObject copyRegionDisplayBox;

		private static Vector3 copyRegionMinExpansion;

		private static Vector3 copyRegionMaxExpansion;

		public static void StartCopying()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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)
			bool flag = false;
			Vector3? lookedAtMachinePos = AimingHelper.getLookedAtMachinePos();
			if (!lookedAtMachinePos.HasValue)
			{
				BlueprintsPlugin.Notify("Aim at a buildable to copy.");
				return;
			}
			copyRegionStart = lookedAtMachinePos.Value;
			if ((double)Mathf.Abs(copyRegionStart.y % 1f) == 0.5)
			{
				copyRegionStart.y -= 0.49f;
			}
			if (flag)
			{
				Debug.Log((object)$"startCopying() copyRegionStart: {copyRegionStart}");
			}
			InitialiseCopying();
			GetAndShowDisplayBox();
		}

		public static void UpdateEndPosition()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			KeyboardShortcut value = BlueprintsPlugin.cancelShortcut.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				CancelCopying(notify: true);
			}
			Vector3? lookedAtMachinePos = AimingHelper.getLookedAtMachinePos();
			if (!lookedAtMachinePos.HasValue)
			{
				return;
			}
			Vector3 value2 = lookedAtMachinePos.Value;
			if (flag)
			{
				Debug.Log((object)$"updateEndPosition() currentEndPos: {value2}");
			}
			Vector3 val = value2 - copyRegionStart;
			copyRegionBounds = new Bounds(copyRegionStart, Vector3.zero);
			((Bounds)(ref copyRegionBounds)).Encapsulate(copyRegionStart + val);
			if (flag)
			{
				Debug.Log((object)$"updateEndPosition() size: {val}");
			}
			HashSet<GenericMachineInstanceRef> machineRefsInBounds = GetMachineRefsInBounds();
			foreach (GenericMachineInstanceRef item in machineRefsInBounds)
			{
				FHG_Utils.EncapsulateMachine(ref copyRegionBounds, item);
			}
			UpdateExpansion();
			UpdateDisplayBox();
		}

		public static void EndCopying()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			Vector3? lookedAtMachinePos = AimingHelper.getLookedAtMachinePos();
			if (!lookedAtMachinePos.HasValue)
			{
				BlueprintsPlugin.Notify("Aim at a buildable to end.");
				return;
			}
			copyRegionEnd = lookedAtMachinePos.Value;
			CancelCopying(notify: false);
			if (flag)
			{
				Debug.Log((object)$"endCopying() copyRegionEnd: {copyRegionEnd}");
			}
			Vector3 finalCopyRegionValues = GetFinalCopyRegionValues();
			if (flag)
			{
				Debug.Log((object)$"endCopying() size: {finalCopyRegionValues}");
			}
			Blueprint blueprint = new Blueprint();
			blueprint.SetSize(finalCopyRegionValues);
			BlueprintsPlugin.clipboard = blueprint;
			bool flag2 = false;
			HashSet<IMachineInstanceRef> machinesToCopy = GetMachinesToCopy();
			foreach (IMachineInstanceRef item in machinesToCopy)
			{
				if (!EMUBuilder.SupportedMachineTypes.Contains(item.typeIndex))
				{
					flag2 = true;
					continue;
				}
				BlueprintsPlugin.machinesToCopy.Add(item);
				Vector3 val = ((GridInfo)(ref item.GetGridInfo())).BottomCenter - copyRegionAnchor;
				if (flag)
				{
					Debug.Log((object)$"endCopying() relativePosition: {val}");
				}
				blueprint.machineRelativePositions.Add(new MyVector3(val).ToString());
			}
			if (flag2)
			{
				BlueprintsPlugin.Notify("Unsupported machines were not copied");
				if (BlueprintsPlugin.machinesToCopy.Count == 0)
				{
					BlueprintsPlugin.clipboard = null;
				}
			}
		}

		private static void InitialiseCopying()
		{
			//IL_0006: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			copyRegionMinExpansion = default(Vector3);
			copyRegionMaxExpansion = default(Vector3);
			copyRegionBounds = new Bounds(copyRegionStart, Vector3.zero);
			isCopying = true;
		}

		private static void GetAndShowDisplayBox()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			if ((Object)(object)copyRegionDisplayBox == (Object)null)
			{
				FieldInfo field = ((object)Player.instance.interaction).GetType().GetField("takeResourcesBox", BindingFlags.Instance | BindingFlags.NonPublic);
				GameObject val = (GameObject)field.GetValue(Player.instance.interaction);
				copyRegionDisplayBox = Object.Instantiate<GameObject>(val);
			}
			copyRegionDisplayBox.SetActive(true);
			UpdateDisplayBox();
		}

		private static void CancelCopying(bool notify)
		{
			isCopying = false;
			copyRegionDisplayBox.SetActive(false);
			if (notify)
			{
				BlueprintsPlugin.Notify("Canceled copying");
			}
		}

		private static void UpdateExpansion()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			Vector3 forward = ((Component)Player.instance.cam).transform.forward;
			Vector3 val = Vector3.zero;
			Vector3 val2 = Vector3.Cross(Vector3.up, forward);
			Vector3 vector = -((Vector3)(ref val2)).normalized;
			val2 = Vector3.Cross(Vector3.up, forward);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			Vector3 vector2 = forward;
			Vector3 vector3 = -forward;
			vector2.y = 0f;
			vector3.y = 0f;
			bool flag = false;
			KeyboardShortcut value = BlueprintsPlugin.nudgeLeftShortcut.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				val = AimingHelper.ClampToAxis(vector);
			}
			else
			{
				value = BlueprintsPlugin.nudgeRightShortcut.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					val = AimingHelper.ClampToAxis(normalized);
				}
				else
				{
					value = BlueprintsPlugin.nudgeForwardShortcut.Value;
					if (((KeyboardShortcut)(ref value)).IsDown())
					{
						val = AimingHelper.ClampToAxis(((Vector3)(ref vector2)).normalized);
					}
					else
					{
						value = BlueprintsPlugin.nudgeBackwardShortcut.Value;
						if (((KeyboardShortcut)(ref value)).IsDown())
						{
							val = AimingHelper.ClampToAxis(((Vector3)(ref vector3)).normalized);
						}
						else
						{
							value = BlueprintsPlugin.nudgeUpShortcut.Value;
							if (((KeyboardShortcut)(ref value)).IsDown())
							{
								val = Vector3.up;
							}
							else
							{
								value = BlueprintsPlugin.nudgeDownShortcut.Value;
								if (((KeyboardShortcut)(ref value)).IsDown())
								{
									val = Vector3.down;
								}
								else
								{
									value = BlueprintsPlugin.shrinkLeftShortcut.Value;
									if (((KeyboardShortcut)(ref value)).IsDown())
									{
										val = AimingHelper.ClampToAxis(vector);
										flag = true;
									}
									else
									{
										value = BlueprintsPlugin.shrinkRightShortcut.Value;
										if (((KeyboardShortcut)(ref value)).IsDown())
										{
											val = AimingHelper.ClampToAxis(normalized);
											flag = true;
										}
										else
										{
											value = BlueprintsPlugin.shrinkForwardShortcut.Value;
											if (((KeyboardShortcut)(ref value)).IsDown())
											{
												val = AimingHelper.ClampToAxis(vector2);
												flag = true;
											}
											else
											{
												value = BlueprintsPlugin.shrinkBackwardShortcut.Value;
												if (((KeyboardShortcut)(ref value)).IsDown())
												{
													val = AimingHelper.ClampToAxis(vector3);
													flag = true;
												}
												else
												{
													value = BlueprintsPlugin.shrinkUpShortcut.Value;
													if (((KeyboardShortcut)(ref value)).IsDown())
													{
														val = AimingHelper.ClampToAxis(Vector3.up);
														flag = true;
													}
													else
													{
														value = BlueprintsPlugin.shrinkDownShortcut.Value;
														if (((KeyboardShortcut)(ref value)).IsDown())
														{
															val = AimingHelper.ClampToAxis(Vector3.down);
															flag = true;
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			float num = ((!flag) ? 1 : (-1));
			if (val.x < 0f || val.y < 0f || val.z < 0f)
			{
				copyRegionMinExpansion += num * val;
			}
			else if (val.x > 0f || val.y > 0f || val.z > 0f)
			{
				copyRegionMaxExpansion += num * val;
			}
			if (copyRegionMinExpansion.x > 0f)
			{
				copyRegionMinExpansion.x = 0f;
			}
			if (copyRegionMinExpansion.y > 0f)
			{
				copyRegionMinExpansion.y = 0f;
			}
			if (copyRegionMinExpansion.z > 0f)
			{
				copyRegionMinExpansion.z = 0f;
			}
			if (copyRegionMaxExpansion.x < 0f)
			{
				copyRegionMaxExpansion.x = 0f;
			}
			if (copyRegionMaxExpansion.y < 0f)
			{
				copyRegionMaxExpansion.y = 0f;
			}
			if (copyRegionMaxExpansion.z < 0f)
			{
				copyRegionMaxExpansion.z = 0f;
			}
			((Bounds)(ref copyRegionBounds)).SetMinMax(((Bounds)(ref copyRegionBounds)).min + copyRegionMinExpansion, ((Bounds)(ref copyRegionBounds)).max + copyRegionMaxExpansion);
		}

		private static void UpdateDisplayBox()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			copyRegionDisplayBox.transform.localScale = ((Bounds)(ref copyRegionBounds)).size;
			copyRegionDisplayBox.transform.position = ((Bounds)(ref copyRegionBounds)).min;
			copyRegionDisplayBox.transform.rotation = Quaternion.identity;
		}

		private static Vector3 GetFinalCopyRegionValues()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = copyRegionEnd - copyRegionStart;
			((Bounds)(ref copyRegionBounds)).Encapsulate(copyRegionStart + val);
			val.x = ((val.x >= 0f) ? ((Bounds)(ref copyRegionBounds)).size.x : (0f - ((Bounds)(ref copyRegionBounds)).size.x));
			val.y = ((Bounds)(ref copyRegionBounds)).size.y;
			val.z = ((val.z >= 0f) ? ((Bounds)(ref copyRegionBounds)).size.z : (0f - ((Bounds)(ref copyRegionBounds)).size.z));
			Vector3 val2 = default(Vector3);
			val2.x = ((Bounds)(ref copyRegionBounds)).center.x;
			val2.y = ((Bounds)(ref copyRegionBounds)).center.y - ((Bounds)(ref copyRegionBounds)).extents.y;
			val2.z = ((Bounds)(ref copyRegionBounds)).center.z;
			copyRegionAnchor = val2;
			return val;
		}

		private static HashSet<GenericMachineInstanceRef> GetMachineRefsInBounds()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			((Bounds)(ref copyRegionBounds)).extents = ((Bounds)(ref copyRegionBounds)).extents - new Vector3(0.01f, 0.01f, 0.01f);
			if (flag)
			{
				Debug.Log((object)$"getMachineRefsInBounds() copyRegionBounds.center: {((Bounds)(ref copyRegionBounds)).center}");
				Debug.Log((object)$"getMachineRefsInBounds() copyRegionBounds.extents: {(