Decompiled source of MassRecipePaste v1.1.1

MassRecipePaste.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CommonAPI;
using CommonAPI.Systems;
using CommonAPI.Systems.ModLocalization;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MassRecipePaste")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
namespace MassRecipePaste;

public class DragPasteTool : BuildTool
{
	public bool isEnable;

	public bool isSelecting;

	public bool isPasting;

	public int pastedCount;

	private bool castTerrain;

	private bool castGround;

	private Vector3 castGroundPos = Vector3.zero;

	private Vector3 castGroundPosSnapped = Vector3.zero;

	private int castObjectId;

	private Vector3 castObjectPos;

	private bool cursorValid;

	private Vector3 cursorTarget;

	private Vector3 startGroundPosSnapped = Vector3.zero;

	private Vector3 lastGroundPosSnapped = Vector3.zero;

	public BPGratBox selectGratBox = BPGratBox.zero;

	private BPGratBox lastSelectGratBox = BPGratBox.zero;

	private BPGratBox selectArcBox = BPGratBox.zero;

	private HashSet<int> selectObjIds;

	private BuildPreview[] bpPool;

	private AnimData[] animPool;

	private ComputeBuffer animBuffer;

	private int bpCursor = 1;

	private int bpPoolCapacity;

	private int[] bpRecycle;

	private int bpRecycleCursor;

	public override void _OnInit()
	{
		selectObjIds = new HashSet<int>();
		SetDisplayPreviewCapacity(256);
	}

	public override void _OnFree()
	{
		selectObjIds = null;
		FreeBuildPreviews();
		isEnable = false;
		isSelecting = false;
		isPasting = false;
	}

	public override void _OnOpen()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//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_002e: 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_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_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_003d: 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_0051: 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_0053: 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_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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_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)
		ClearSelection();
		ResetBuildPreviews();
		castTerrain = false;
		castGround = false;
		castGroundPos = Vector3.zero;
		startGroundPosSnapped = (lastGroundPosSnapped = (castGroundPosSnapped = Vector3.zero));
		lastSelectGratBox = (selectGratBox = (selectArcBox = BPGratBox.zero));
		castObjectId = 0;
		castObjectPos = Vector3.zero;
		cursorValid = false;
		cursorTarget = Vector3.zero;
		isSelecting = false;
	}

	public override void _OnClose()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_001d: 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_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: 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_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0039: 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_0040: 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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		ClearSelection();
		ResetBuildPreviews();
		startGroundPosSnapped = (lastGroundPosSnapped = (castGroundPosSnapped = Vector3.zero));
		lastSelectGratBox = (selectGratBox = (selectArcBox = BPGratBox.zero));
		castObjectId = 0;
		castObjectPos = Vector3.zero;
		cursorValid = false;
		cursorTarget = Vector3.zero;
		isEnable = false;
		isSelecting = false;
		isPasting = false;
	}

	public override void _OnTick(long time)
	{
		UpdateRaycast();
		Operating();
		if (((BuildTool)this).active)
		{
			((BuildTool)this).UpdatePreviewModels(((BuildTool)this).actionBuild.model);
		}
	}

	public override bool DetermineActive()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		if (isEnable && (int)((BuildTool)this).actionBuild.blueprintMode == 0)
		{
			return ((BuildTool)this).controller.cmd.mode == 0;
		}
		return false;
	}

	public override void EscLogic()
	{
		//IL_001a: 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)
		bool flag = !VFInput.onGUI && VFInput.inScreen && !VFInput.inputing;
		bool flag2 = VFInput.escKey.onDown || VFInput.escape;
		bool num = !VFInput._godModeMechaMove && VFInput.rtsCancel.onDown && flag;
		if (num || flag2)
		{
			((BuildTool)this).player.SetHandItems(0, 0, 0);
			((BuildTool)this)._Close();
			((BuildTool)this).actionBuild.Close();
		}
		if (flag2)
		{
			VFInput.UseEscape();
		}
		if (num)
		{
			VFInput.UseMouseRight();
		}
	}

	public override void UpdatePreviewModels(BuildModel model)
	{
		//IL_008e: 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_00c0: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 1; i < bpCursor; i++)
		{
			BuildPreview val = bpPool[i];
			if (val == null || val.bpgpuiModelId <= 0 || !val.isConnNode)
			{
				continue;
			}
			if (val.objId > 0)
			{
				base.factory.cargoTraffic.SetBeltSelected(base.factory.entityPool[val.objId].beltId);
			}
			else
			{
				uint beltSpeed = (uint)val.desc.beltSpeed;
				if (val.outputObjId == 0 || val.inputObjId == 0 || val.coverbp != null)
				{
					model.connRenderer.AddBlueprintBeltMajorPoint(val.lpos, val.lrot, beltSpeed);
				}
				else
				{
					model.connRenderer.AddBlueprintBeltPoint(val.lpos, val.lrot, beltSpeed);
				}
			}
			model.connRenderer.AddXSign(val.lpos, val.lrot);
		}
	}

	public void UpdateRaycast()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: 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_0031: 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)
		//IL_0043: 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_0096: 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_009d: Invalid comparison between Unknown and I4
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Invalid comparison between Unknown and I4
		//IL_037b: 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)
		//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_00cb: 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_00d2: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: 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_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: 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_0200: Invalid comparison between Unknown and I4
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: 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_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: 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_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: 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_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: 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_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Unknown result type (might be due to invalid IL or missing references)
		castTerrain = false;
		castGround = false;
		castGroundPos = Vector3.zero;
		castGroundPosSnapped = Vector3.zero;
		castObjectId = 0;
		castObjectPos = Vector3.zero;
		cursorValid = false;
		cursorTarget = Vector3.zero;
		if (!VFInput.onGUI && VFInput.inScreen)
		{
			RaycastHit val = default(RaycastHit);
			castGround = Physics.Raycast(base.mouseRay, ref val, 800f, 8720, (QueryTriggerInteraction)2);
			if (castGround)
			{
				Layer val2 = (Layer)((Component)((RaycastHit)(ref val)).collider).gameObject.layer;
				castTerrain = (int)val2 == 9 || (int)val2 == 4;
				castGroundPos = (((BuildTool)this).controller.cmd.test = (((BuildTool)this).controller.cmd.target = ((RaycastHit)(ref val)).point));
				castGroundPosSnapped = ((BuildTool)this).actionBuild.planetAux.Snap(castGroundPos, castTerrain);
				castGroundPosSnapped = ((Vector3)(ref castGroundPosSnapped)).normalized * (base.planet.realRadius + 0.2f);
				((BuildTool)this).controller.cmd.test = castGroundPosSnapped;
				Vector3 normalized = ((Vector3)(ref castGroundPosSnapped)).normalized;
				if (Physics.Raycast(new Ray(castGroundPosSnapped + normalized * 10f, -normalized), ref val, 20f, 8720, (QueryTriggerInteraction)2))
				{
					((BuildTool)this).controller.cmd.test = ((RaycastHit)(ref val)).point;
				}
				cursorTarget = castGroundPosSnapped;
				cursorValid = true;
			}
			int castAllCount = ((BuildTool)this).controller.cmd.raycast.castAllCount;
			RaycastData[] castAll = ((BuildTool)this).controller.cmd.raycast.castAll;
			int num = 0;
			for (int i = 0; i < castAllCount; i++)
			{
				if ((int)castAll[i].objType == 0 || (int)castAll[i].objType == 3)
				{
					num = (((int)castAll[i].objType == 0) ? castAll[i].objId : (-castAll[i].objId));
					break;
				}
			}
			if (num != 0)
			{
				castObjectId = num;
				castObjectPos = ((BuildTool)this).GetObjectPose(num).position;
				cursorTarget = castObjectPos;
				((BuildTool)this).controller.cmd.test = castObjectPos;
				castGroundPosSnapped = (castGroundPos = castObjectPos);
				castGroundPosSnapped = ((Vector3)(ref castGroundPosSnapped)).normalized * (base.planet.realRadius + 0.2f);
				((BuildTool)this).controller.cmd.test = castGroundPosSnapped;
				Vector3 normalized2 = ((Vector3)(ref castGroundPosSnapped)).normalized;
				if (Physics.Raycast(new Ray(castGroundPosSnapped + normalized2 * 10f, -normalized2), ref val, 20f, 8720, (QueryTriggerInteraction)2))
				{
					((BuildTool)this).controller.cmd.test = ((RaycastHit)(ref val)).point;
				}
				cursorTarget = castGroundPosSnapped;
				cursorValid = true;
			}
		}
		((BuildTool)this).controller.cmd.state = (cursorValid ? 1 : 0);
		((BuildTool)this).controller.cmd.target = (cursorValid ? cursorTarget : Vector3.zero);
	}

	public void Operating()
	{
		//IL_0047: 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_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_0066: 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_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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_0031: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: 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_010c: 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_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: 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_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Invalid comparison between Unknown and I4
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Invalid comparison between Unknown and I4
		if (!isSelecting && VFInput.blueprintCopyOperate0.onDown && cursorValid)
		{
			isSelecting = true;
			startGroundPosSnapped = castGroundPosSnapped;
			lastGroundPosSnapped = startGroundPosSnapped;
			InitSelectGratBox();
			VFInput.UseMouseLeft();
		}
		Vector3 val = castGroundPosSnapped - startGroundPosSnapped;
		bool num = ((Vector3)(ref val)).sqrMagnitude > 0.01f;
		bool flag = VFInput.blueprintCopyOperate0.onDown || VFInput.blueprintCopyOperate1.onDown;
		if (isSelecting && flag && cursorValid)
		{
			PasteAction();
			ResetBuildPreviews();
			isSelecting = false;
			VFInput.UseMouseLeft();
			VFInput.UseEnterConfirm();
			((BuildTool)this)._Close();
		}
		else if (isSelecting && VFInput.rtsCancel.onUp)
		{
			isSelecting = false;
			startGroundPosSnapped = castGroundPosSnapped;
			lastGroundPosSnapped = startGroundPosSnapped;
			ClearSelection();
			ResetBuildPreviews();
		}
		if (isSelecting)
		{
			DetermineSelectGratBox();
			if (lastSelectGratBox != selectGratBox)
			{
				DetermineAddSelection();
				lastSelectGratBox = selectGratBox;
			}
		}
		else
		{
			startGroundPosSnapped = castGroundPosSnapped;
			ReDeterminePreviews();
		}
		if (num)
		{
			ReDeterminePreviews();
		}
		if (((int)BuildingParameters.clipboard.type == 5 || (int)BuildingParameters.clipboard.type == 8) && BuildingParameters.clipboard.recipeId != 0)
		{
			((BuildTool)this).actionBuild.model.cursorText = "MassRecipePaste\r\n" + ((object)(ERecipeType)(ref BuildingParameters.clipboard.recipeType)).ToString() + " (" + LDB.RecipeName(BuildingParameters.clipboard.recipeId) + ") : " + selectObjIds.Count;
		}
		else
		{
			((BuildTool)this).actionBuild.model.cursorText = "MassRecipePaste\r\n" + ((object)(BuildingType)(ref BuildingParameters.clipboard.type)).ToString() + " : " + selectObjIds.Count;
		}
	}

	public void PasteAction()
	{
		Plugin.Log.LogInfo((object)("PasteAction " + ((object)(BuildingType)(ref BuildingParameters.clipboard.type)).ToString() + " - " + ((object)(ERecipeType)(ref BuildingParameters.clipboard.recipeType)).ToString()));
		isPasting = true;
		pastedCount = 0;
		foreach (int selectObjId in selectObjIds)
		{
			base.factory.PasteBuildingSetting(selectObjId);
		}
		isPasting = false;
		isSelecting = false;
		ClearSelection();
		if (pastedCount > 0)
		{
			string text = ((BuildingParameters)(ref BuildingParameters.clipboard)).PastedTipText() + " (" + pastedCount + ")";
			UIRealtimeTip.Popup(text, false, 0);
			Plugin.Log.LogDebug((object)text);
		}
	}

	private void InitSelectGratBox()
	{
		//IL_0006: 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_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		BlueprintUtils.GetMinimumGratBox(((Vector3)(ref startGroundPosSnapped)).normalized, ref selectGratBox);
		selectArcBox = selectGratBox;
		if (selectArcBox.y >= 1.5707864f)
		{
			selectArcBox.y = (selectArcBox.w = (float)Math.PI / 2f);
			selectArcBox.z = selectArcBox.x + (float)Math.PI * 200f;
		}
		else if (selectArcBox.y <= -1.5707864f)
		{
			selectArcBox.y = (selectArcBox.w = -(float)Math.PI / 2f);
			selectArcBox.z = selectArcBox.x + (float)Math.PI * 200f;
		}
		lastSelectGratBox = selectGratBox;
	}

	public void DetermineSelectGratBox()
	{
		//IL_0011: 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_0033: 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_02df: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_030c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0311: Unknown result type (might be due to invalid IL or missing references)
		if (!cursorValid)
		{
			return;
		}
		float longitudeRad = BlueprintUtils.GetLongitudeRad(((Vector3)(ref castGroundPosSnapped)).normalized);
		float longitudeRad2 = BlueprintUtils.GetLongitudeRad(((Vector3)(ref lastGroundPosSnapped)).normalized);
		float latitudeRad = BlueprintUtils.GetLatitudeRad(((Vector3)(ref castGroundPosSnapped)).normalized);
		int num;
		float num2;
		if (!(latitudeRad >= 1.5707864f))
		{
			num = ((latitudeRad <= -1.5707864f) ? 1 : 0);
			if (num == 0)
			{
				num2 = longitudeRad - longitudeRad2;
				goto IL_0061;
			}
		}
		else
		{
			num = 1;
		}
		num2 = 0f;
		goto IL_0061;
		IL_0061:
		float num3 = num2;
		num3 = Mathf.Repeat(num3 + (float)Math.PI, (float)Math.PI * 2f) - (float)Math.PI;
		ref BPGratBox reference = ref selectArcBox;
		((BPGratBox)(ref reference)).endLongitudeRad = ((BPGratBox)(ref reference)).endLongitudeRad + num3;
		((BPGratBox)(ref selectArcBox)).endLatitudeRad = latitudeRad;
		selectGratBox = selectArcBox;
		selectGratBox.x = ((selectArcBox.x < selectArcBox.z) ? selectArcBox.x : selectArcBox.z);
		selectGratBox.z = ((selectArcBox.x > selectArcBox.z) ? selectArcBox.x : selectArcBox.z);
		if (selectArcBox.x < selectArcBox.z)
		{
			if (selectGratBox.z > selectGratBox.x + (float)Math.PI * 2f - 1E-05f - 4E-06f)
			{
				selectGratBox.z = selectGratBox.x + (float)Math.PI * 2f - 1E-05f - 4E-06f;
			}
			selectGratBox.z = Mathf.Repeat(selectGratBox.z + (float)Math.PI, (float)Math.PI * 2f) - (float)Math.PI;
		}
		else
		{
			if (selectGratBox.x < selectGratBox.z - (float)Math.PI * 2f + 1E-05f + 4E-06f)
			{
				selectGratBox.x = selectGratBox.z - (float)Math.PI * 2f + 1E-05f + 4E-06f;
			}
			selectGratBox.x = Mathf.Repeat(selectGratBox.x + (float)Math.PI, (float)Math.PI * 2f) - (float)Math.PI;
		}
		selectGratBox.y = ((selectArcBox.y < selectArcBox.w) ? selectArcBox.y : selectArcBox.w);
		selectGratBox.w = ((selectArcBox.y > selectArcBox.w) ? selectArcBox.y : selectArcBox.w);
		float num4 = BlueprintUtils.GetLongitudeRadPerGrid((Mathf.Abs(castGroundPosSnapped.y) < Mathf.Abs(startGroundPosSnapped.y)) ? ((Vector3)(ref castGroundPosSnapped)).normalized : ((Vector3)(ref startGroundPosSnapped)).normalized, 200) * 0.33f;
		((BPGratBox)(ref selectGratBox)).Extend(num4, 0.002f);
		if (num == 0)
		{
			lastGroundPosSnapped = castGroundPosSnapped;
		}
	}

	public void DetermineAddSelection()
	{
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		selectObjIds.Clear();
		if (Mathf.Abs(selectArcBox.x - selectArcBox.z) < 0.01f && Mathf.Abs(selectArcBox.y - selectArcBox.w) < 0.01f && castObjectId != 0)
		{
			if (ShouldAddObject(castObjectId))
			{
				selectObjIds.Add(castObjectId);
			}
		}
		else
		{
			EntityData[] entityPool = base.factory.entityPool;
			int entityCursor = base.factory.entityCursor;
			for (int i = 1; i < entityCursor; i++)
			{
				int num = i;
				if (entityPool[i].id == i && ((BPGratBox)(ref selectGratBox)).InGratBox(entityPool[i].pos) && ShouldAddObject(num))
				{
					selectObjIds.Add(num);
				}
			}
			PrebuildData[] prebuildPool = base.factory.prebuildPool;
			int prebuildCursor = base.factory.prebuildCursor;
			for (int j = 1; j < prebuildCursor; j++)
			{
				int num2 = -j;
				if (prebuildPool[j].id == j && ((BPGratBox)(ref selectGratBox)).InGratBox(prebuildPool[j].pos) && ShouldAddObject(num2))
				{
					selectObjIds.Add(num2);
				}
			}
		}
		DeterminePreviews();
	}

	public bool ShouldAddObject(int objId)
	{
		return ((BuildingParameters)(ref BuildingParameters.clipboard)).CanPasteToFactoryObject(objId, base.factory);
	}

	public void ClearSelection()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: 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_001a: 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_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_0023: Unknown result type (might be due to invalid IL or missing references)
		selectObjIds.Clear();
		lastSelectGratBox = (selectGratBox = (selectArcBox = BPGratBox.zero));
	}

	public void ReDeterminePreviews()
	{
		ResetBuildPreviews();
		foreach (int selectObjId in selectObjIds)
		{
			BuildPreview buildPreview = GetBuildPreview(selectObjId);
			AddBPGPUIModel(buildPreview);
		}
		SyncAnimBuffer();
		base.planet.factoryModel.bpgpuiManager.animBuffer = animBuffer;
		base.planet.factoryModel.bpgpuiManager.SyncAllGPUBuffer();
	}

	public void DeterminePreviews()
	{
		HashSet<int> hashSet = new HashSet<int>(selectObjIds);
		for (int i = 1; i < bpCursor; i++)
		{
			BuildPreview val = bpPool[i];
			if (val == null || val.bpgpuiModelId <= 0)
			{
				continue;
			}
			if (!selectObjIds.Contains(val.objId))
			{
				if (val.bpgpuiModelInstIndex >= 0)
				{
					base.planet.factoryModel.bpgpuiManager.RemoveBuildPreviewModel(val.desc.modelIndex, val.bpgpuiModelInstIndex, false);
				}
				RemoveBuildPreview(i);
			}
			else
			{
				hashSet.Remove(val.objId);
			}
		}
		foreach (int item in hashSet)
		{
			BuildPreview buildPreview = GetBuildPreview(item);
			AddBPGPUIModel(buildPreview);
		}
		if (castObjectId != 0)
		{
			BuildPreview buildPreview2 = GetBuildPreview(castObjectId);
			AddBPGPUIModel(buildPreview2);
		}
		SyncAnimBuffer();
		base.planet.factoryModel.bpgpuiManager.animBuffer = animBuffer;
		base.planet.factoryModel.bpgpuiManager.SyncAllGPUBuffer();
	}

	public void AddBPGPUIModel(BuildPreview preview)
	{
		//IL_0031: 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_0094: 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_00a7: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: 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_00f6: 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_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: 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_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: 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_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		if (preview == null || preview.bpgpuiModelId <= 0 || !preview.needModel)
		{
			return;
		}
		ModelProto val = ((ProtoSet<ModelProto>)(object)LDB.models).Select(preview.desc.modelIndex);
		Color32 pasteConfirmOkColor = Configs.builtin.pasteConfirmOkColor;
		if (val.RendererType == 2)
		{
			bool flag = default(bool);
			bool flag2 = default(bool);
			((BuildTool)this).GetInserterT1T2(preview.objId, ref flag, ref flag2);
			if (preview.objId > 0)
			{
				animPool[preview.bpgpuiModelId] = base.factory.entityAnimPool[preview.objId];
			}
			animPool[preview.bpgpuiModelId].state = (uint)((pasteConfirmOkColor.r << 24) + (pasteConfirmOkColor.g << 16) + (pasteConfirmOkColor.b << 8) + pasteConfirmOkColor.a);
			base.planet.factoryModel.bpgpuiManager.AddBuildPreviewModel(preview.desc.modelIndex, ref preview.bpgpuiModelInstIndex, preview.bpgpuiModelId, preview.lpos, preview.lrot, preview.lpos2, preview.lrot2, flag ? 1 : 0, flag2 ? 1 : 0, false);
			return;
		}
		if (val.RendererType == 3)
		{
			bool flag3 = default(bool);
			int num = default(int);
			int num2 = default(int);
			base.factory.ReadObjectConn(preview.objId, 14, ref flag3, ref num, ref num2);
			if (preview.objId > 0)
			{
				animPool[preview.bpgpuiModelId] = base.factory.entityAnimPool[preview.objId];
			}
			animPool[preview.bpgpuiModelId].state = (uint)((pasteConfirmOkColor.r << 24) + (pasteConfirmOkColor.g << 16) + (pasteConfirmOkColor.b << 8) + pasteConfirmOkColor.a);
			base.planet.factoryModel.bpgpuiManager.AddBuildPreviewModel(preview.desc.modelIndex, ref preview.bpgpuiModelInstIndex, preview.bpgpuiModelId, preview.lpos, preview.lrot, (num != 0) ? 1u : 0u, false);
			return;
		}
		if (preview.objId > 0)
		{
			animPool[preview.bpgpuiModelId] = base.factory.entityAnimPool[preview.objId];
		}
		animPool[preview.bpgpuiModelId].state = (uint)((pasteConfirmOkColor.r << 24) + (pasteConfirmOkColor.g << 16) + (pasteConfirmOkColor.b << 8) + pasteConfirmOkColor.a);
		if (preview.objId > 0 && preview.desc.isEjector)
		{
			animPool[preview.bpgpuiModelId].power = base.factory.factorySystem.ejectorPool[base.factory.entityPool[preview.objId].ejectorId].localDir.z;
		}
		base.planet.factoryModel.bpgpuiManager.AddBuildPreviewModel(preview.desc.modelIndex, ref preview.bpgpuiModelInstIndex, preview.bpgpuiModelId, preview.lpos, preview.lrot, false);
	}

	public void GeneratePreviewByObjId(BuildPreview preview, int objId)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: 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_0047: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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_0071: 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_0135: 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_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		ItemProto itemProto = ((BuildTool)this).GetItemProto(objId);
		PrefabDesc prefabDesc = ((BuildTool)this).GetPrefabDesc(objId);
		if (prefabDesc == null || itemProto == null)
		{
			preview.ResetAll();
			return;
		}
		Pose objectPose = ((BuildTool)this).GetObjectPose(objId);
		Pose val = (prefabDesc.isInserter ? ((BuildTool)this).GetObjectPose2(objId) : objectPose);
		preview.item = itemProto;
		preview.desc = prefabDesc;
		preview.lpos = objectPose.position;
		preview.lrot = objectPose.rotation;
		preview.lpos2 = objectPose.position;
		preview.lrot2 = objectPose.rotation;
		preview.objId = objId;
		preview.genNearColliderArea2 = 0f;
		if (preview.desc.lodCount > 0 && preview.desc.lodMeshes != null && (Object)(object)preview.desc.lodMeshes[0] != (Object)null)
		{
			preview.needModel = true;
		}
		else
		{
			preview.needModel = false;
		}
		preview.isConnNode = prefabDesc.isBelt;
		if (prefabDesc.isBelt)
		{
			bool flag = default(bool);
			int num = default(int);
			int num2 = default(int);
			for (int i = 0; i < 4; i++)
			{
				base.factory.ReadObjectConn(objId, i, ref flag, ref num, ref num2);
				if (num != 0)
				{
					if (flag)
					{
						preview.outputObjId = num;
					}
					else if (preview.inputObjId == 0)
					{
						preview.inputObjId = num;
					}
					else
					{
						preview.coverbp = preview;
					}
				}
			}
		}
		if (prefabDesc.isInserter)
		{
			preview.lpos2 = val.position;
			preview.lrot2 = val.rotation;
		}
	}

	public void ResetBuildPreviews()
	{
		if (base.planet != null && (Object)(object)base.planet.factoryModel != (Object)null && base.planet.factoryModel.bpgpuiManager != null)
		{
			base.planet.factoryModel.bpgpuiManager.Reset();
		}
		for (int i = 0; i < bpPool.Length; i++)
		{
			if (bpPool[i] != null)
			{
				bpPool[i].ResetAll();
			}
		}
		Array.Clear(animPool, 0, bpPoolCapacity);
		Array.Clear(bpRecycle, 0, bpPoolCapacity);
		bpCursor = 1;
		bpRecycleCursor = 0;
		animBuffer.SetData((Array)animPool);
	}

	public void FreeBuildPreviews()
	{
		if (base.planet != null && (Object)(object)base.planet.factoryModel != (Object)null && base.planet.factoryModel.bpgpuiManager != null)
		{
			base.planet.factoryModel.bpgpuiManager.Reset();
		}
		for (int i = 0; i < bpPool.Length; i++)
		{
			if (bpPool[i] != null)
			{
				bpPool[i].Free();
				bpPool[i] = null;
			}
		}
		animPool = null;
		bpPool = null;
		bpCursor = 1;
		bpPoolCapacity = 0;
		bpRecycle = null;
		bpRecycleCursor = 0;
		if (animBuffer != null)
		{
			animBuffer.Release();
			animBuffer = null;
		}
	}

	private void SetDisplayPreviewCapacity(int newCapacity)
	{
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		BuildPreview[] array = bpPool;
		AnimData[] sourceArray = animPool;
		bpPool = (BuildPreview[])(object)new BuildPreview[newCapacity];
		animPool = (AnimData[])(object)new AnimData[newCapacity];
		bpRecycle = new int[newCapacity];
		if (array != null)
		{
			Array.Copy(array, bpPool, (newCapacity > bpPoolCapacity) ? bpPoolCapacity : newCapacity);
			Array.Copy(sourceArray, animPool, (newCapacity > bpPoolCapacity) ? bpPoolCapacity : newCapacity);
		}
		bpPoolCapacity = newCapacity;
		ComputeBuffer obj = animBuffer;
		if (obj != null)
		{
			obj.Release();
		}
		animBuffer = new ComputeBuffer(newCapacity, 20, (ComputeBufferType)0);
	}

	public void RemoveBuildPreview(int id)
	{
		if (bpPool[id] != null && bpPool[id].bpgpuiModelInstIndex >= 0)
		{
			animPool[id].time = 0f;
			animPool[id].prepare_length = 0f;
			animPool[id].working_length = 0f;
			animPool[id].state = 0u;
			animPool[id].power = 0f;
			bpPool[id].ResetAll();
			bpRecycle[bpRecycleCursor++] = id;
		}
	}

	public BuildPreview GetBuildPreview(int objId)
	{
		//IL_0056: 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: Expected O, but got Unknown
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Expected O, but got Unknown
		if (bpRecycleCursor > 0)
		{
			int num = bpRecycle[--bpRecycleCursor];
			BuildPreview val = bpPool[num];
			if (val == null)
			{
				val = new BuildPreview();
				bpPool[num] = val;
			}
			GeneratePreviewByObjId(val, objId);
			animPool[num] = default(AnimData);
			val.previewIndex = num;
			val.bpgpuiModelId = num;
			return val;
		}
		int num2 = bpCursor++;
		if (num2 == bpPoolCapacity)
		{
			SetDisplayPreviewCapacity(bpPoolCapacity * 2);
		}
		BuildPreview val2 = bpPool[num2];
		if (val2 == null)
		{
			val2 = new BuildPreview();
			bpPool[num2] = val2;
		}
		GeneratePreviewByObjId(val2, objId);
		animPool[num2] = default(AnimData);
		val2.previewIndex = num2;
		val2.bpgpuiModelId = num2;
		return val2;
	}

	public void SyncAnimBuffer()
	{
		ComputeBuffer obj = animBuffer;
		if (obj != null)
		{
			obj.SetData((Array)animPool);
		}
	}
}
public class ExtraCopy
{
	[HarmonyPostfix]
	[HarmonyPatch(typeof(UIOptionWindow), "OnApplyClick")]
	internal static void OnApplyClick()
	{
		try
		{
			((BaseUnityPlugin)Plugin.instance).Config.Reload();
			Plugin.instance.LoadConfigs();
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)ex);
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PlanetFactory), "CopyBuildingSetting")]
	public static void CopyExtraClipborad(PlanetFactory __instance, int objectId)
	{
		if (objectId > 0 && __instance.entityPool[objectId].id == objectId)
		{
			int stationId = __instance.entityPool[objectId].stationId;
			if (stationId != 0)
			{
				StationComponent station = __instance.transport.stationPool[stationId];
				StationParameters.Copy(__instance, station);
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PlanetFactory), "PasteBuildingSetting")]
	public static void PasteExtraClipborad(PlanetFactory __instance, int objectId)
	{
		if (objectId > 0 && Patches.tool.isPasting && __instance.entityPool[objectId].id == objectId)
		{
			int stationId = __instance.entityPool[objectId].stationId;
			if (stationId != 0)
			{
				StationComponent station = __instance.transport.stationPool[stationId];
				StationParameters.Paste(__instance, station);
			}
		}
	}
}
internal static class StationParameters
{
	private static string name;

	private static long remoteGroupMask;

	private static ERemoteRoutePriority routePriority;

	private static readonly List<int> addGids = new List<int>();

	public static void Copy(PlanetFactory factory, StationComponent station)
	{
		//IL_0015: 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)
		if (!station.isStellar)
		{
			return;
		}
		remoteGroupMask = station.remoteGroupMask;
		routePriority = station.routePriority;
		if (Plugin.CopyStationName.Value)
		{
			name = factory.ReadExtraInfoOnEntity(station.entityId);
		}
		if (!Plugin.CopyStationP2P.Value)
		{
			return;
		}
		addGids.Clear();
		GalacticTransport galacticTransport = GameMain.data.galacticTransport;
		for (int i = 1; i < galacticTransport.stationCursor; i++)
		{
			if (galacticTransport.stationPool[i] != null && galacticTransport.stationPool[i].id > 0 && galacticTransport.stationPool[i].gid == i)
			{
				long item = galacticTransport.CalculateStation2StationKey(station.gid, i);
				if (galacticTransport.station2stationRoutes.Contains(item))
				{
					addGids.Add(i);
				}
			}
		}
	}

	public static void Paste(PlanetFactory factory, StationComponent station)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		if (!station.isStellar)
		{
			return;
		}
		if (Plugin.CopyStationGroup.Value)
		{
			station.remoteGroupMask = remoteGroupMask;
		}
		if (Plugin.CopyStationPriorityBehavior.Value)
		{
			station.routePriority = routePriority;
		}
		if (Plugin.CopyStationName.Value)
		{
			factory.WriteExtraInfoOnEntity(station.entityId, name);
		}
		if (!Plugin.CopyStationP2P.Value)
		{
			return;
		}
		GameMain.data.galacticTransport.RemoveStation2StationRoute(station.gid);
		foreach (int addGid in addGids)
		{
			GameMain.data.galacticTransport.AddStation2StationRoute(station.gid, addGid);
		}
	}
}
public class Patches
{
	public static bool isCustomHotkey = false;

	public static DragPasteTool tool;

	private static readonly int cursorGratBox = Shader.PropertyToID("_CursorGratBox");

	private static readonly int selectColor = Shader.PropertyToID("_SelectColor");

	private static readonly int tintColor = Shader.PropertyToID("_TintColor");

	private static readonly int showDivideLine = Shader.PropertyToID("_ShowDivideLine");

	[HarmonyPostfix]
	[HarmonyAfter(new string[] { "org.kremnev8.plugin.BlueprintTweaks" })]
	[HarmonyPatch(typeof(PlayerAction_Build), "Init")]
	public static void InitTool(PlayerAction_Build __instance)
	{
		BuildTool[] tools = __instance.tools;
		if (tools != null)
		{
			BuildTool[] array = (BuildTool[])(object)new BuildTool[tools.Length + 1];
			tools.CopyTo(array, 0);
			tool = new DragPasteTool();
			array[^1] = (BuildTool)(object)tool;
			__instance.tools = array;
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(PlayerAction_Build), "DetermineActive")]
	public static void UpdateCommandState(PlayerAction_Build __instance, ref bool __result)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		if (tool.isEnable && __instance.activeTool == tool)
		{
			__result = true;
		}
		else if (VFInput.readyToBuild && VFInput.inScreen && IsHotKey() && (int)__instance.blueprintMode == 0)
		{
			Plugin.Log.LogDebug((object)("Enter PasteMode: " + ((object)(BuildingType)(ref BuildingParameters.clipboard.type)).ToString() + " - " + ((object)(ERecipeType)(ref BuildingParameters.clipboard.recipeType)).ToString()));
			((CommandState)(ref ((PlayerAction)__instance).player.controller.cmd)).SetNoneCommand();
			tool.isEnable = true;
			__result = true;
		}
	}

	private static bool IsHotKey()
	{
		//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_0063: 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)
		if (PluginCAPIcompat.IsRegisiter)
		{
			return PluginCAPIcompat.IsPressed();
		}
		if (isCustomHotkey)
		{
			KeyboardShortcut value = Plugin.MassPasteKey.Value;
			return ((KeyboardShortcut)(ref value)).IsPressed();
		}
		if (!((CombineKey)(ref VFInput.override_keys[31])).IsNull())
		{
			if (VFInput.control)
			{
				return VFInput._InputValueNoCombatOrFullscreen(VFInput.axis_combine_key, 31).onDown;
			}
			return false;
		}
		if (VFInput.control)
		{
			return VFInput._InputValueNoCombatOrFullscreen(VFInput.axis_button, 33).onDown;
		}
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIRealtimeTip), "Popup", new Type[]
	{
		typeof(string),
		typeof(bool),
		typeof(int)
	})]
	public static bool Blocker()
	{
		if (tool.isPasting)
		{
			tool.pastedCount++;
			return false;
		}
		return true;
	}

	[HarmonyPostfix]
	[HarmonyPriority(0)]
	[HarmonyPatch(typeof(UIBuildingGrid), "Update")]
	public static void UpdateGrid(UIBuildingGrid __instance)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Invalid comparison between Unknown and I4
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_008b: 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_00a6: 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)
		Player mainPlayer = GameMain.mainPlayer;
		if (GameMain.localPlanet?.factory == null || (int)GameMain.localPlanet.type == 5)
		{
			return;
		}
		PlayerAction_Build val = ((mainPlayer != null) ? mainPlayer.controller.actionBuild : null);
		if (val != null && (int)val.blueprintMode == 0 && ((BuildTool)tool).active)
		{
			if (tool.isSelecting)
			{
				__instance.blueprintMaterial.SetColor(tintColor, __instance.blueprintColor);
				__instance.blueprintMaterial.SetVector(cursorGratBox, (Vector4)tool.selectGratBox);
				__instance.blueprintMaterial.SetVector(selectColor, Color.op_Implicit(__instance.buildColor));
				__instance.blueprintMaterial.SetFloat(showDivideLine, 0f);
				__instance.blueprintGridRnd.enabled = true;
			}
			else
			{
				__instance.blueprintMaterial.SetColor(tintColor, __instance.blueprintColor);
				__instance.blueprintMaterial.SetVector(cursorGratBox, Vector4.zero);
				__instance.blueprintMaterial.SetVector(selectColor, Vector4.one);
				__instance.blueprintMaterial.SetFloat(showDivideLine, 0f);
				__instance.blueprintGridRnd.enabled = false;
			}
			for (int i = 0; i < 64; i++)
			{
				__instance.blueprintMaterial.SetVector($"_CursorGratBox{i}", Vector4.zero);
				__instance.blueprintMaterial.SetFloat($"_CursorGratBoxInfo{i}", 0f);
			}
		}
	}
}
[BepInPlugin("starfi5h.plugin.MassRecipePaste", "MassRecipePaste", "1.1.1")]
public class Plugin : BaseUnityPlugin
{
	public const string GUID = "starfi5h.plugin.MassRecipePaste";

	public const string NAME = "MassRecipePaste";

	public const string VERSION = "1.1.1";

	public static ManualLogSource Log;

	public static Plugin instance;

	private static Harmony harmony;

	public static ConfigEntry<KeyboardShortcut> MassPasteKey;

	public static ConfigEntry<bool> CopyStationName;

	public static ConfigEntry<bool> CopyStationPriorityBehavior;

	public static ConfigEntry<bool> CopyStationGroup;

	public static ConfigEntry<bool> CopyStationP2P;

	public void Awake()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		instance = this;
		harmony = new Harmony("starfi5h.plugin.MassRecipePaste");
		harmony.PatchAll(typeof(Patches));
		harmony.PatchAll(typeof(ExtraCopy));
		LoadConfigs();
	}

	public void LoadConfigs()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: 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)
		//IL_0043: 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_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_0079: 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)
		MassPasteKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("KeyBinds", "MassPasteKey", new KeyboardShortcut((KeyCode)46, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Custom keybind. Default is ctrl + >(paste recipe)\n没有设置时, 默认为Ctrl + >(配方黏贴键)");
		KeyboardShortcut value = MassPasteKey.Value;
		if (!((object)(KeyboardShortcut)(ref value)).Equals((object)default(KeyboardShortcut)))
		{
			value = MassPasteKey.Value;
			if (!((object)(KeyboardShortcut)(ref value)).Equals((object)new KeyboardShortcut((KeyCode)46, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 })))
			{
				Patches.isCustomHotkey = true;
				ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
				value = MassPasteKey.Value;
				logger.LogDebug((object)("MassPasteKey: " + ((object)(KeyboardShortcut)(ref value)).ToString()));
			}
		}
		CopyStationName = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraCopy", "CopyStationName", false, "复制物流站名称");
		CopyStationPriorityBehavior = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraCopy", "CopyStationPriorityBehavior", true, "复制物流站优先行为");
		CopyStationGroup = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraCopy", "CopyStationGroup", true, "复制物流站分组设置");
		CopyStationP2P = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraCopy", "CopyStationP2P", true, "复制物流站点对点设置");
	}

	public void OnDestroy()
	{
		harmony.UnpatchSelf();
		harmony = null;
	}
}
[BepInPlugin("starfi5h.plugin.MassRecipePaste.CAPIcompat", "MassRecipePasteCAPIcompat", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[CommonAPISubmoduleDependency(new string[] { "LocalizationModule", "CustomKeyBindSystem" })]
public class PluginCAPIcompat : BaseUnityPlugin
{
	public const string GUID = "starfi5h.plugin.MassRecipePaste.CAPIcompat";

	public const string NAME = "MassRecipePasteCAPIcompat";

	public const string VERSION = "1.0.0";

	public static bool IsRegisiter;

	public void Awake()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		BuiltinKey val = default(BuiltinKey);
		val.key = new CombineKey(46, (byte)2, (ECombineKeyAction)0, false);
		val.conflictGroup = 2048;
		val.name = "MassRecipePaste";
		val.canOverride = true;
		CustomKeyBindSystem.RegisterKeyBind<PressKeyBind>(val);
		LocalizationModule.RegisterTranslation("KEYMassRecipePaste", "(Mod) Mass Recipe Paste", "(Mod) 范围配方黏贴", "Mass Recipe Paste");
		IsRegisiter = true;
	}

	public static bool IsPressed()
	{
		return CustomKeyBindSystem.GetKeyBind("MassRecipePaste").keyValue;
	}
}