Decompiled source of Blueprints v3.0.2

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 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", "3.0.1")]
	public class BlueprintsPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.equinox.Blueprints";

		private const string PluginName = "Blueprints";

		private const string VersionString = "3.0.1";

		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: 3.0.1 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: 3.0.1 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
		}

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

		private void FixedUpdate()
		{
			//IL_0095: 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++)
			{
				if (ShouldBuild(i))
				{
					BuildQueue.HideHologram(i);
					List<Vector3Int> list = new List<Vector3Int>();
					if (GridManager.instance.CheckBuildableAt(BuildQueue.queuedBuildings[i].gridInfo, ref list))
					{
						BuildBuilding(BuildQueue.queuedBuildings[i]);
					}
					BuildQueue.queuedBuildings.RemoveAt(i);
					sSinceLastBuild = 0f;
					break;
				}
			}
			if (BuildQueue.queuedBuildings.Count == 0 && BuildQueue.holograms.Count != 0)
			{
				BuildQueue.ClearHolograms();
			}
		}

		private void OnGUI()
		{
			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;
				ModUtils.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_0009: 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_0013: 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_003d: 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_0050: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_01c6: Expected I4, but got Unknown
			//IL_00b8: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: 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_022f: 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_01eb: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			MachineTypeEnum val = (MachineTypeEnum)building.type;
			GridInfo gridInfo = building.gridInfo;
			ChainData val2 = default(ChainData);
			val2.count = 1;
			val2.height = building.conveyorHeight;
			val2.shape = (BeltShape)building.conveyorShape;
			val2.rotation = gridInfo.yawRot;
			val2.start = gridInfo.minPos;
			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 5:
			case 7:
			case 9:
			case 11:
			case 15:
			case 16:
			case 18:
			case 20:
			case 21:
			case 23:
			case 25:
			case 31:
				ModUtils.BuildMachine(building.resID, gridInfo, false, -1, -1, (ChainData?)null, false);
				break;
			case 30:
				ModUtils.BuildMachine(building.resID, gridInfo, false, building.variationIndex, -1, (ChainData?)null, false);
				break;
			case 0:
			case 6:
				ModUtils.BuildMachine(building.resID, gridInfo, false, -1, building.recipe, (ChainData?)null, false);
				break;
			case 3:
				ModUtils.BuildMachine(building.resID, gridInfo, false, -1, -1, (ChainData?)value, building.conveyorBuildBackwards);
				break;
			default:
				Debug.Log((object)"Unsupported Machine type");
				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 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_00c6: 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_00d5: 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_00e3: 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;
			HashSet<IMachineInstanceRef> machinesToCopy = GetMachinesToCopy();
			foreach (IMachineInstanceRef item in machinesToCopy)
			{
				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());
			}
		}

		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: {((Bounds)(ref copyRegionBounds)).extents}");
				Debug.Log((object)$"getMachineRefsInBounds() copyRegionBounds.min: {((Bounds)(ref copyRegionBounds)).min}");
				Debug.Log((object)$"getMachineRefsInBounds() copyRegionBounds.max: {((Bounds)(ref copyRegionBounds)).max}");
			}
			HashSet<GenericMachineInstanceRef> hashSet = new HashSet<GenericMachineInstanceRef>();
			Collider[] array = Physics.OverlapBox(((Bounds)(ref copyRegionBounds)).center, ((Bounds)(ref copyRegionBounds)).extents, Quaternion.identity, LayerMask.op_Implicit(AimingHelper.buildablesMask.Value));
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				GenericMachineInstanceRef item = FHG_Utils.FindMachineRef(((Component)val).gameObject);
				if (((GenericMachineInstanceRef)(ref item)).IsValid())
				{
					hashSet.Add(item);
				}
			}
			return hashSet;
		}

		private static HashSet<IMachineInstanceRef> GetMachinesToCopy()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			HashSet<GenericMachineInstanceRef> machineRefsInBounds = GetMachineRefsInBounds();
			HashSet<IMachineInstanceRef> hashSet = new HashSet<IMachineInstanceRef>();
			foreach (GenericMachineInstanceRef item in machineRefsInBounds)
			{
				GenericMachineInstanceRef current = item;
				if (((GenericMachineInstanceRef)(ref current)).IsValid())
				{
					if ((int)((GenericMachineInstanceRef)(ref current)).typeIndex == 20)
					{
						Debug.Log((object)"Skipping monorail track");
					}
					else if ((int)((GenericMachineInstanceRef)(ref current)).typeIndex == 24)
					{
						hashSet.Add((IMachineInstanceRef)(object)new MachineInstanceRef<AccumulatorInstance>(ref current));
					}
					else
					{
						hashSet.Add(((GenericMachineInstanceRef)(ref current)).CastToInterface());
					}
				}
			}
			return hashSet;
		}
	}
	public static class MachinePaster
	{
		public static bool isPasting = false;

		public static bool isPositionLocked = false;

		public static List<Vector3> rotatedRelativePositions;

		public static Vector3 finalAimLocation;

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

		private static Vector3 nudgeOffset;

		public static Vector3 lockedPosition;

		private static Blueprint clipboard => BlueprintsPlugin.clipboard;

		public static void StartPasting()
		{
			//IL_0032: 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_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_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)
			bool flag = false;
			if (clipboard == null)
			{
				BlueprintsPlugin.Notify("Nothing to paste!");
				return;
			}
			rotatedRelativePositions = clipboard.GetMachineRelativePositions();
			isPasting = true;
			nudgeOffset = Vector3.zero;
			finalAimLocation = AimingHelper.getAimedLocationForPasting();
			lockedPosition = finalAimLocation;
			renderHolograms();
		}

		public static void updateHolograms()
		{
			//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_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_0055: 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_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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_01f3: 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)
			KeyboardShortcut value = BlueprintsPlugin.cancelShortcut.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				hideHolograms();
				isPasting = false;
				isPositionLocked = false;
				BlueprintsPlugin.Notify("Canceled pasting");
			}
			Vector3 aimedLocationForPasting = AimingHelper.getAimedLocationForPasting();
			if (!isPositionLocked)
			{
				lockedPosition = aimedLocationForPasting;
			}
			Vector3Int rotatedSize = clipboard.GetRotatedSize();
			if (((Vector3Int)(ref rotatedSize)).x % 2 == 0)
			{
				aimedLocationForPasting.x += 0.5f;
			}
			if (((Vector3Int)(ref rotatedSize)).z % 2 == 0)
			{
				aimedLocationForPasting.z += 0.5f;
			}
			checkForNudging();
			aimedLocationForPasting += nudgeOffset;
			for (int i = 0; i < holograms.Count; i++)
			{
				Vector3 val = aimedLocationForPasting + rotatedRelativePositions[i];
				int num = clipboard.machineRotations[i] + clipboard.GetMachineRotation(clipboard.machineIDs[i]);
				num %= 360;
				if (num < 0)
				{
					num += 360;
				}
				StreamedHologramData obj = holograms[i];
				Quaternion val2 = Quaternion.Euler(0f, (float)num, 0f);
				obj.SetTransform(ref val, ref val2, false);
				StreamedHologramData obj2 = holograms[i];
				ConveyorHologramData val3 = (ConveyorHologramData)(object)((obj2 is ConveyorHologramData) ? obj2 : null);
				if (val3 != null)
				{
					val3.topYawRot = clipboard.conveyorTopYawRots[i] + clipboard.rotation * 90;
				}
			}
			value = BlueprintsPlugin.cwRotateShortcut.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && !BlueprintsLibraryGUI.shouldShow)
			{
				clipboard.RotateCW();
				rotatedRelativePositions = clipboard.GetMachineRelativePositions();
				return;
			}
			value = BlueprintsPlugin.ccwRotateShortcut.Value;
			if (((KeyboardShortcut)(ref value)).IsDown() && !BlueprintsLibraryGUI.shouldShow)
			{
				clipboard.RotateCCW();
				rotatedRelativePositions = clipboard.GetMachineRelativePositions();
			}
		}

		public static void endPasting()
		{
			//IL_0007: 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_01b7: 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)
			isPasting = false;
			finalAimLocation = AimingHelper.getAimedLocationForPasting();
			for (int i = 0; i < clipboard.machineIDs.Count; i++)
			{
				BuildQueue.holograms.Add(holograms[i]);
				BuildQueue.queuedBuildings.Add(new QueuedBuilding
				{
					machineID = clipboard.machineIDs[i],
					index = clipboard.machineIndexes[i],
					resID = clipboard.machineResIDs[i],
					type = clipboard.machineTypes[i],
					rotation = clipboard.machineTypes[i],
					recipe = clipboard.machineRecipes[i],
					variationIndex = clipboard.machineVariationIndexes[i],
					dimensions = new MyVector3(clipboard.machineDimensions[i]),
					conveyorShape = clipboard.conveyorShapes[i],
					conveyorBuildBackwards = clipboard.conveyorBuildBackwards[i],
					conveyorHeight = clipboard.conveyorHeights[i],
					conveyorInputBottom = clipboard.conveyorInputBottoms[i],
					conveyorTopYawRot = clipboard.conveyorTopYawRots[i] + clipboard.rotation * 90,
					chestSize = clipboard.chestSizes[i],
					gridInfo = getNewGridInfo(rotatedRelativePositions, i, clipboard.machineRotations[i], clipboard.machineIDs[i], clipboard.machineVariationIndexes[i])
				});
			}
			holograms.Clear();
			postPaste();
		}

		public static GridInfo getNewGridInfo(List<Vector3> rotatedRelativePositions, int index, int yawRotation, uint id, int variationIndex)
		{
			//IL_0005: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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_01a6: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: 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_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			GridInfo result = default(GridInfo);
			Vector3 val = finalAimLocation;
			if (flag)
			{
				Debug.Log((object)$"getNewGridInfo() aimLocation before nudge: {val}");
			}
			if (flag && isPositionLocked)
			{
				Debug.Log((object)$"getNewGridInfo() lockedPosition: {lockedPosition}");
			}
			val += nudgeOffset;
			if (flag)
			{
				Debug.Log((object)$"getNewGridInfo() nudgeOffset: {nudgeOffset}");
			}
			if (flag)
			{
				Debug.Log((object)$"getNewGridInfo() aimLocation after nudge: {val}");
			}
			Vector3Int rotatedSize = clipboard.GetRotatedSize();
			if (flag)
			{
				Debug.Log((object)$"getNewGridInfo() blueprintSize: {rotatedSize}");
			}
			if (((Vector3Int)(ref rotatedSize)).x % 2 == 0)
			{
				val.x += 0.5f;
			}
			if (((Vector3Int)(ref rotatedSize)).z % 2 == 0)
			{
				val.z += 0.5f;
			}
			if (flag)
			{
				Debug.Log((object)$"getNewGridInfo() aimLocation after size offset: {val}");
			}
			Vector3 machineDimensions = clipboard.GetMachineDimensions(index);
			Vector3 val2 = val + rotatedRelativePositions[index];
			Vector3 val3 = default(Vector3);
			val3.x = val2.x - machineDimensions.x / 2f;
			val3.y = val2.y;
			val3.z = val2.z - machineDimensions.z / 2f;
			Vector3 val4 = val3;
			Vector3Int minPos = default(Vector3Int);
			((Vector3Int)(ref minPos)).x = Mathf.RoundToInt(val4.x);
			((Vector3Int)(ref minPos)).y = Mathf.RoundToInt(val4.y);
			((Vector3Int)(ref minPos)).z = Mathf.RoundToInt(val4.z);
			Vector3Int val5 = (result.minPos = minPos);
			if (flag)
			{
				Debug.Log((object)$"getNewGridInfo() machine dimensions: {machineDimensions}");
				Debug.Log((object)$"getNewGridInfo() newMachineenter: {val2}");
				Debug.Log((object)$"getNewGridInfo() newMinPos: {val4}");
				Debug.Log((object)$"getNewGridInfo() newMinPosInts: {val5}");
			}
			int num = yawRotation + clipboard.GetMachineRotation(id);
			if (num >= 360)
			{
				num -= 360;
			}
			else if (num < 0)
			{
				num += 360;
			}
			FHG_Utils.SetYawRotation(ref result, ref num);
			((GridInfo)(ref result)).SetVariationIndex(variationIndex);
			return result;
		}

		public static void postPaste()
		{
			isPositionLocked = false;
			clipboard.rotation = 0;
			clipboard.ClearMachineRotations();
		}

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

		private static void renderHolograms()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0019: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00fc: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Invalid comparison between Unknown and I4
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: 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_0218: Invalid comparison between Unknown and I4
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: 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_02b5: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			Vector3 val = (lockedPosition = AimingHelper.getAimedLocationForPasting());
			if (flag)
			{
				Debug.Log((object)$"renderHolograms() aimLocation: {val}");
			}
			Vector3Int rotatedSize = clipboard.GetRotatedSize();
			if (((Vector3Int)(ref rotatedSize)).x % 2 == 0)
			{
				val.x += 0.5f;
			}
			if (((Vector3Int)(ref rotatedSize)).z % 2 == 0)
			{
				val.z += 0.5f;
			}
			if (flag)
			{
				Debug.Log((object)$"renderHolograms() blueprintSize: {rotatedSize}");
				Debug.Log((object)$"renderHolograms() aimLocation after size offset: {val}");
			}
			for (int i = 0; i < clipboard.machineIDs.Count; i++)
			{
				int num = clipboard.machineResIDs[i];
				int num2 = clipboard.machineIndexes[i];
				MachineTypeEnum val2 = (MachineTypeEnum)clipboard.machineTypes[i];
				Vector3 val3 = rotatedRelativePositions[i];
				float num3 = clipboard.machineRotations[i];
				int num4 = clipboard.machineVariationIndexes[i];
				ResourceInfo resInfoFromId = SaveState.GetResInfoFromId(num);
				BuilderInfo val4 = (BuilderInfo)(object)((resInfoFromId is BuilderInfo) ? resInfoFromId : null);
				if (flag)
				{
					Debug.Log((object)$"renderHolograms() machineIndex: {num2}");
					Debug.Log((object)$"renderHolograms() machineType: {val2}");
					Debug.Log((object)$"renderHolograms() offset: {val3}");
				}
				Vector3 val5 = val + val3;
				if (flag)
				{
					Debug.Log((object)$"renderHolograms() thisHologramPos before dim offset: {val5}");
				}
				if ((int)val2 == 4)
				{
					if (flag)
					{
						Debug.Log((object)"renderingHolograms() rendering conveyor");
					}
					StreamedHologramData obj = val4.GenerateUnbuiltHologramData();
					ConveyorHologramData val6 = (ConveyorHologramData)(object)((obj is ConveyorHologramData) ? obj : null);
					val6.buildBackwards = clipboard.conveyorBuildBackwards[i];
					val6.curShape = (BeltShape)clipboard.conveyorShapes[i];
					val6.numBelts = 1;
					if ((int)val6.curShape == 6)
					{
						val6.numBelts = clipboard.conveyorHeights[i];
						val6.verticalHeight = clipboard.conveyorHeights[i];
						val6.inputBottom = clipboard.conveyorInputBottoms[i];
						val6.topYawRot = clipboard.conveyorTopYawRots[i] + clipboard.rotation * 90;
					}
					num3 = clipboard.machineRotations[i];
					Quaternion val7 = Quaternion.Euler(0f, num3, 0f);
					((StreamedHologramData)val6).SetTransform(ref val5, ref val7, false);
					((StreamedHologramData)val6).ShowUnbuilt(true, true);
					holograms.Add((StreamedHologramData)(object)val6);
					if (flag)
					{
						Debug.Log((object)"renderHolograms() added conveyor to holograms");
					}
				}
				else
				{
					if (flag)
					{
						Debug.Log((object)"renderingHolograms() rendering non-conveyor");
					}
					StreamedHologramData val8 = val4.GenerateUnbuiltHologramData();