Decompiled source of SphereEditorTools v2.2.3

SphereEditorTools.dll

Decompiled 10 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SphereEditorTools")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SphereEditorTools")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5c6f6fb6-a5c8-40be-b244-861f8232abf0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.0.0")]
[module: UnverifiableCode]
namespace SphereEditorTools;

internal class Comm
{
	public static UIDysonEditor dysonEditor;

	private static string infoString;

	private static int infoCounter;

	public static int DisplayMode;

	public static bool SymmetricMode = true;

	public static int MirrorMode;

	public static int RadialCount = 1;

	public static int MaxRadialCount = 90;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UIDysonEditor), "_OnOpen")]
	public static void Init(UIDysonEditor __instance)
	{
		dysonEditor = __instance;
		Stringpool.Set();
		if (SphereEditorTools.EnableGUI.Value)
		{
			UIWindow.OnOpen();
		}
		HideLayer.SetDisplayMode(DisplayMode);
		HideLayer.SetMask(HideLayer.EnableMask);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UIDysonEditor), "_OnClose")]
	public static void Free()
	{
		dysonEditor = null;
		if (SphereEditorTools.EnableGUI.Value)
		{
			UIWindow.OnClose();
		}
		HideLayer.Free();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameMain), "Resume")]
	public static void OnResume()
	{
		UIWindow.SaveWindowPos();
		SphereEditorTools.Config.Reload();
		Stringpool.Set();
		UIWindow.LoadWindowPos();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameMain), "End")]
	public static void OnGameEnd()
	{
		if (SphereEditorTools.EnableGUI.Value)
		{
			UIWindow.SaveWindowPos();
		}
		SphereEditorTools.Config.Save();
	}

	public static void SetInfoString(string str, int counter)
	{
		infoString = str;
		infoCounter = counter;
	}

	public static void ShowSymmetricToolStatus()
	{
		string str = ((!SymmetricMode) ? $"{Stringpool.SymmetricTool} OFF" : $"{Stringpool.SymmetricTool} {Stringpool.Rotation}:{RadialCount,-2} {Stringpool.Mirror}:{Stringpool.MirrorModes[MirrorMode]}");
		SetInfoString(str, 120);
	}

	public static void SetSymmetricMode(bool state)
	{
		SymmetricMode = state;
		if (SymmetricMode)
		{
			SymmetryTool.ChangeParameters(MirrorMode, RadialCount);
		}
		else
		{
			SymmetryTool.ChangeParameters(0, 1);
		}
		ShowSymmetricToolStatus();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UIDysonEditor), "UpdateBrushes")]
	public static void Update_CheckKeyDown(UIDysonEditor __instance)
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Invalid comparison between Unknown and I4
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Invalid comparison between Unknown and I4
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Invalid comparison between Unknown and I4
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Invalid comparison between Unknown and I4
		if (infoCounter > 0)
		{
			__instance.controlPanel.toolbox.brushError = infoString;
			infoCounter--;
		}
		if (!Input.anyKeyDown)
		{
			return;
		}
		infoCounter = 0;
		DysonSphereLayer singleSelectedLayer = __instance.selection.singleSelectedLayer;
		if (singleSelectedLayer != null && SphereEditorTools.EnableToolboxHotkey.Value)
		{
			if (Input.GetKeyDown(SphereEditorTools.KeySelect.Value))
			{
				__instance.brushMode = (EBrushMode)1;
			}
			else if (Input.GetKeyDown(SphereEditorTools.KeyNode.Value))
			{
				__instance.brushMode = (EBrushMode)(((int)__instance.brushMode == 2) ? 1 : 2);
			}
			else if (Input.GetKeyDown(SphereEditorTools.KeyFrameGeo.Value))
			{
				__instance.brushMode = (EBrushMode)(((int)__instance.brushMode == 3) ? 1 : 3);
			}
			else if (Input.GetKeyDown(SphereEditorTools.KeyFrameEuler.Value))
			{
				__instance.brushMode = (EBrushMode)(((int)__instance.brushMode == 4) ? 1 : 4);
			}
			else if (Input.GetKeyDown(SphereEditorTools.KeyShell.Value))
			{
				__instance.brushMode = (EBrushMode)(((int)__instance.brushMode == 5) ? 1 : 5);
			}
			else if (Input.GetKeyDown(SphereEditorTools.KeyGrid.Value))
			{
				singleSelectedLayer.drawingGridMode = (singleSelectedLayer.drawingGridMode + 1) % 5;
			}
		}
		if (Input.GetKeyDown(SphereEditorTools.KeyHideMode.Value))
		{
			DisplayMode = (DisplayMode + 1) % 4;
			HideLayer.SetDisplayMode(DisplayMode);
			SetInfoString(Stringpool.DisplayMode[DisplayMode], 120);
		}
		if (!SphereEditorTools.EnableSymmetryTool.Value)
		{
			return;
		}
		if (Input.GetKeyDown(SphereEditorTools.KeySymmetryTool.Value))
		{
			SetSymmetricMode(!SymmetricMode);
		}
		else if (Input.GetKeyDown(SphereEditorTools.KeyMirroring.Value))
		{
			SymmetricMode = true;
			MirrorMode = (MirrorMode + 1) % 3;
			SymmetryTool.ChangeParameters(MirrorMode, RadialCount);
			ShowSymmetricToolStatus();
		}
		else if (Input.GetKeyDown(SphereEditorTools.KeyRotationInc.Value))
		{
			SymmetricMode = true;
			if (RadialCount < MaxRadialCount)
			{
				SymmetryTool.ChangeParameters(MirrorMode, ++RadialCount);
			}
			ShowSymmetricToolStatus();
		}
		else if (Input.GetKeyDown(SphereEditorTools.KeyRotationDec.Value))
		{
			SymmetricMode = true;
			if (RadialCount > 1)
			{
				SymmetryTool.ChangeParameters(MirrorMode, --RadialCount);
			}
			ShowSymmetricToolStatus();
		}
	}
}
public class EditOrbit
{
	public static bool EnableAnchorMode;

	public static float AuglarSpeed;

	private static DysonSphereLayer selectedLayer;

	public static bool Toggle(bool enable)
	{
		if (enable && selectedLayer != null)
		{
			selectedLayer.orbitAngularSpeed = 0f;
			EnableAnchorMode = true;
		}
		else if (!enable && selectedLayer != null)
		{
			selectedLayer.orbitAngularSpeed = AuglarSpeed;
			EnableAnchorMode = false;
		}
		return EnableAnchorMode;
	}

	public static void TrySetAngularSpeed(float angularSpeed)
	{
		if (selectedLayer != null)
		{
			if (angularSpeed < 0f)
			{
				AuglarSpeed = Mathf.Sqrt(selectedLayer.dysonSphere.gravity / selectedLayer.orbitRadius) / selectedLayer.orbitRadius * 57.29578f;
			}
			else
			{
				AuglarSpeed = angularSpeed;
			}
			Log.LogInfo($"Set angular speed of layer[{selectedLayer.id}]: {selectedLayer.orbitAngularSpeed} => {AuglarSpeed}");
			selectedLayer.orbitAngularSpeed = AuglarSpeed;
			UIWindow.SpeedInput = AuglarSpeed.ToString();
			EnableAnchorMode = false;
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(DESelection), "NotifySelectionChange")]
	public static void DESelection_Postfix(DESelection __instance)
	{
		if (__instance.singleSelectedLayer != selectedLayer)
		{
			if (EnableAnchorMode)
			{
				selectedLayer.orbitAngularSpeed = AuglarSpeed;
				EnableAnchorMode = false;
			}
			if (__instance.singleSelectedLayer != null)
			{
				AuglarSpeed = __instance.singleSelectedLayer.orbitAngularSpeed;
				UIWindow.SpeedInput = AuglarSpeed.ToString();
			}
			selectedLayer = __instance.singleSelectedLayer;
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(DysonSphereLayer), "InitOrbitRotation")]
	public static bool InitOrbitRotation_Prefix(DysonSphereLayer __instance, Quaternion __1)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		if (EnableAnchorMode)
		{
			ChangeLayer(__instance, __1);
			return false;
		}
		return true;
	}

	public static void ConvertQuaternion(Quaternion rotation, out float inclination, out float longitude)
	{
		//IL_0003: 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_0031: 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)
		inclination = ((((Quaternion)(ref rotation)).eulerAngles.z == 0f) ? 0f : (360f - ((Quaternion)(ref rotation)).eulerAngles.z));
		longitude = ((((Quaternion)(ref rotation)).eulerAngles.y == 0f) ? 0f : (360f - ((Quaternion)(ref rotation)).eulerAngles.y));
	}

	public static void ChangeLayer(DysonSphereLayer layer, Quaternion rotation)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: 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_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_00a4: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		Quaternion orbitRotation = rotation;
		Quaternion orbitRotation2 = layer.orbitRotation;
		layer.orbitRotation = orbitRotation;
		rotation = orbitRotation2;
		ConvertQuaternion(rotation, out var inclination, out var longitude);
		Log.LogInfo($"Previous Layer[{layer.id}]: ({inclination},{longitude})");
		ConvertQuaternion(layer.orbitRotation, out inclination, out longitude);
		Log.LogInfo($" Current Layer[{layer.id}]: ({inclination},{longitude})");
		Quaternion currentRotation = layer.currentRotation;
		layer.currentAngle = 0f;
		layer.currentRotation = layer.orbitRotation * Quaternion.Euler(0f, 0f - layer.currentAngle, 0f);
		MoveStructure(layer, currentRotation);
	}

	public static void MoveStructure(DysonSphereLayer layer, Quaternion previousRotation)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		DysonSphere dysonSphere = layer.dysonSphere;
		MoveNodes(layer, previousRotation);
		SyncNodeBuffer(layer);
		MoveFrames(layer);
		dysonSphere.CheckAutoNodes();
		for (int i = dysonSphere.autoNodeCount; i < 8; i++)
		{
			dysonSphere.PickAutoNode();
		}
		dysonSphere.modelRenderer.RebuildModels();
		MoveShells(layer);
	}

	public static void SyncNodeBuffer(DysonSphereLayer layer)
	{
		//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)
		DysonSphere dysonSphere = layer.dysonSphere;
		for (int i = 0; i < layer.nodeCursor; i++)
		{
			DysonNode val = layer.nodePool[i];
			if (val != null && val.id == i)
			{
				dysonSphere.nrdPool[val.rid].pos = val.pos;
				dysonSphere.nrdPool[val.rid].angularVel = layer.orbitAngularSpeed;
			}
		}
		dysonSphere.nrdBuffer.SetData((Array)dysonSphere.nrdPool);
	}

	public static void MoveNodes(DysonSphereLayer layer, Quaternion previousRotation)
	{
		//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_002c: 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_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_003d: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < layer.nodeCursor; i++)
		{
			DysonNode val = layer.nodePool[i];
			if (val != null && val.id == i && EnableAnchorMode)
			{
				val.pos = Quaternion.Inverse(layer.currentRotation) * previousRotation * val.pos;
			}
		}
	}

	public static void MoveFrames(DysonSphereLayer layer)
	{
		for (int i = 0; i < layer.frameCursor; i++)
		{
			DysonFrame val = layer.framePool[i];
			if (val != null && val.id == i)
			{
				int spMax = val.spMax;
				int spReqOrder = val.nodeA.spReqOrder;
				int spReqOrder2 = val.nodeB.spReqOrder;
				val.spMax = val.segCount * 10;
				val.nodeA.RecalcSpReq();
				val.nodeB.RecalcSpReq();
				Log.LogDebug($"Frame[{i}]: spMax {spMax}->{val.spMax}; " + $"ReqSP nodeA[{val.nodeA.id}]:{spReqOrder}->{val.nodeA.spReqOrder}, nodeB[{val.nodeB.id}]:{spReqOrder2}->{val.nodeB.spReqOrder}");
				val.segPoints = null;
			}
		}
	}

	public static void MoveShells(DysonSphereLayer layer)
	{
		List<int> list = new List<int>(6);
		List<int> list2 = new List<int>(6);
		for (int i = 0; i < layer.shellCursor; i++)
		{
			DysonShell val = layer.shellPool[i];
			if (val == null || i != val.id)
			{
				continue;
			}
			list.Clear();
			list2.Clear();
			for (int j = 0; j < val.nodes.Count; j++)
			{
				list.Add(val.nodes[j].id);
			}
			for (int k = 0; k < val.nodes.Count + 1; k++)
			{
				list2.Add(val.nodecps[k]);
				val.nodecps[k] = 0;
			}
			int vertexCount = val.vertexCount;
			int protoId = val.protoId;
			layer.RemoveDysonShell(val.id);
			int num = layer.NewDysonShell(protoId, list);
			val = layer.shellPool[num];
			for (int l = 0; l < val.nodes.Count; l++)
			{
				int num2 = list2[l];
				while (num2 > 0 && val.Construct(l, false))
				{
					num2--;
				}
				val.nodes[l].RecalcCpReq();
				val.nodecps[l] += num2;
			}
			Log.LogDebug($"Shell[{i}]:Vertex {vertexCount}->{val.vertexCount}; Total CP {list2[val.nodes.Count]}->{val.nodecps[val.nodes.Count]}");
			val.nodecps[val.nodes.Count] = list2[val.nodes.Count];
		}
	}
}
internal class HideLayer : MonoBehaviour
{
	private static int displayMode;

	public static bool EnableMask;

	private static GameObject blackmask;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(DESelection), "SetViewStar")]
	public static void SetViewStar_Postfix()
	{
		Free();
		SetDisplayMode(displayMode);
		SetMask(EnableMask);
	}

	public static void Free()
	{
		if ((Object)(object)blackmask != (Object)null)
		{
			Object.Destroy((Object)(object)blackmask);
			blackmask = null;
		}
	}

	public static void SetDisplayMode(int mode)
	{
		displayMode = mode;
		GameObject obj = GameObject.Find("UI Root/Dyson Map/Star");
		if (obj != null)
		{
			obj.SetActive(displayMode < 2);
		}
		SetMask((mode & 1) == 1);
	}

	public static void SetMask(bool enable)
	{
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: 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)
		if ((Object)(object)blackmask == (Object)null)
		{
			GameObject val = GameObject.Find("UI Root/Dyson Map/Star/black-mask");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			blackmask = Object.Instantiate<GameObject>(val, val.transform.parent.parent);
			Object.Destroy((Object)(object)blackmask.GetComponent<SphereCollider>());
			GameObject val2 = GameObject.Find("UI Root/Dyson Map/preview/compass");
			blackmask.transform.localScale = new Vector3(val2.transform.localScale.x, val2.transform.localScale.y, 0f);
		}
		blackmask.SetActive(enable);
		EnableMask = enable;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(DysonMapCamera), "_OnLateUpdate")]
	public static void UpdateMask(DysonMapCamera __instance)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		if (EnableMask && (Object)(object)blackmask != (Object)null)
		{
			blackmask.transform.rotation = ((Component)__instance.editorCamera).transform.rotation;
		}
	}
}
internal class Stringpool
{
	public static string Tool;

	public static string Display_options;

	public static string Star;

	public static string Mask;

	public static string SymmetryTool;

	public static string None;

	public static string Equatorial;

	public static string Antipodal;

	public static string[] MirrorModes;

	public static string LAYER;

	public static string[] DisplayMode;

	public static string SymmetricTool;

	public static string Rotation;

	public static string Mirror;

	public static string OrbitTool;

	public static string AnchorMode;

	public static string AngularSpeed;

	public static string Set1;

	public static string Reset;

	public static void Set()
	{
		if (Localization.isZHCN)
		{
			LAYER = "层级";
			SymmetricTool = "[对称工具]";
			Rotation = "旋转";
			Mirror = "镜像";
			Tool = "工具";
			Display_options = "显示选项";
			Star = "恒星";
			Mask = "遮罩";
			SymmetryTool = "对称工具";
			None = "无";
			Equatorial = "赤道对称";
			Antipodal = "对跖点";
			OrbitTool = "轨道工具";
			AnchorMode = "锚定模式";
			AngularSpeed = "角速度";
			Set1 = "设置";
			Reset = "还原";
		}
		else
		{
			LAYER = Localization.Translate("LAYER");
			SymmetricTool = Localization.Translate("[Symmetry]");
			Rotation = Localization.Translate("Rotation");
			Mirror = Localization.Translate("Mirror");
			Tool = Localization.Translate("Tool");
			Display_options = Localization.Translate("Display");
			Star = Localization.Translate("Star");
			Mask = Localization.Translate("Mask");
			SymmetryTool = Localization.Translate("Symmetry Tool");
			None = Localization.Translate("None");
			Equatorial = Localization.Translate("Equatorial");
			Antipodal = Localization.Translate("Antipodal");
			OrbitTool = Localization.Translate("Orbit Tool");
			AnchorMode = Localization.Translate("Anchor Mode");
			AngularSpeed = Localization.Translate("Angular Speed");
			Set1 = Localization.Translate("Set");
			Reset = Localization.Translate("Reset");
		}
		MirrorModes = new string[3] { None, Equatorial, Antipodal };
		DisplayMode = new string[4]
		{
			Display_options + " : " + Star,
			Display_options + " : " + Star + "," + Mask,
			Display_options + " : " + None,
			Display_options + " : " + Mask
		};
	}
}
internal class SymmetryTool : MonoBehaviour
{
	private static UIDysonEditor dysnoEditor;

	private static List<UIDysonBrush>[] brushes;

	private static int brushId;

	private static int mirrorMode;

	private static int rdialCount;

	private static bool overwrite;

	private static Vector3 dataPoint;

	private static float castRadius;

	private static bool resultSnap;

	private static Vector3 clickPoint;

	private static float castDist;

	private static Vector3 rayOrigin;

	private static Ray castRay;

	private static bool paint_gridMode;

	private static int paint_cast_type;

	private static int tick;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UIDysonEditor), "_OnOpen")]
	public static void Init(UIDysonEditor __instance)
	{
		dysnoEditor = __instance;
		brushes = new List<UIDysonBrush>[dysnoEditor.brushes.Length];
		for (int i = 0; i < brushes.Length; i++)
		{
			brushes[i] = new List<UIDysonBrush> { null };
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UIDysonEditor), "_OnClose")]
	public static void Free()
	{
		if (brushes != null)
		{
			for (int i = 0; i < brushes.Length; i++)
			{
				foreach (UIDysonBrush item in brushes[i])
				{
					if (item != null)
					{
						((ManualBehaviour)item)._OnClose();
					}
					if ((Object)(object)((item != null) ? ((Component)item).gameObject : null) != (Object)null)
					{
						Object.Destroy((Object)(object)((item != null) ? ((Component)item).gameObject : null));
					}
				}
			}
			brushes = null;
		}
		Comm.SymmetricMode = false;
	}

	public static void ChangeParameters(int newMirrorMode, int newRadialCount)
	{
		int num = rdialCount * ((mirrorMode <= 0) ? 1 : 2);
		mirrorMode = newMirrorMode;
		rdialCount = newRadialCount;
		int num2 = rdialCount * ((mirrorMode <= 0) ? 1 : 2);
		while (brushes[2].Count < num2)
		{
			AddBrushes();
		}
		for (int i = 0; i < brushes.Length; i++)
		{
			if (brushes[i].Count < num)
			{
				continue;
			}
			for (int j = num2; j < num; j++)
			{
				UIDysonBrush obj = brushes[i][j];
				if (obj != null)
				{
					((ManualBehaviour)obj)._OnClose();
				}
				UIDysonBrush obj2 = brushes[i][j];
				if (obj2 != null)
				{
					((Component)obj2).gameObject.SetActive(false);
				}
			}
		}
	}

	private static void AddBrushes()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_0057: 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_00bc: Expected O, but got Unknown
		//IL_00e4: 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_0149: Expected O, but got Unknown
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Expected O, but got Unknown
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Expected O, but got Unknown
		//IL_029c: 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_0303: Expected O, but got Unknown
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_038d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0394: Expected O, but got Unknown
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		int num = 1;
		UIDysonBrush_Select val = (UIDysonBrush_Select)Object.Instantiate<UIDysonBrush>(dysnoEditor.brushes[num], ((Component)dysnoEditor.brushes[num]).transform.parent);
		brushes[num].Add((UIDysonBrush)(object)val);
		foreach (Transform item in ((Component)val).gameObject.transform)
		{
			Object.Destroy((Object)(object)((Component)item).gameObject);
		}
		((ManualBehaviour)val)._OnInit();
		num = 2;
		UIDysonBrush_Node val2 = (UIDysonBrush_Node)Object.Instantiate<UIDysonBrush>(dysnoEditor.brushes[num], ((Component)dysnoEditor.brushes[num]).transform.parent);
		brushes[num].Add((UIDysonBrush)(object)val2);
		foreach (Transform item2 in ((Component)val2).gameObject.transform)
		{
			Object.Destroy((Object)(object)((Component)item2).gameObject);
		}
		((ManualBehaviour)val2)._OnInit();
		num = 3;
		UIDysonBrush_Frame val3 = (UIDysonBrush_Frame)Object.Instantiate<UIDysonBrush>(dysnoEditor.brushes[num], ((Component)dysnoEditor.brushes[num]).transform.parent);
		brushes[num].Add((UIDysonBrush)(object)val3);
		foreach (Transform item3 in ((Component)val3).gameObject.transform)
		{
			Object.Destroy((Object)(object)((Component)item3).gameObject);
		}
		((ManualBehaviour)val3)._OnInit();
		val3.isEuler = false;
		num = 4;
		val3 = (UIDysonBrush_Frame)Object.Instantiate<UIDysonBrush>(dysnoEditor.brushes[num], ((Component)dysnoEditor.brushes[num]).transform.parent);
		brushes[num].Add((UIDysonBrush)(object)val3);
		foreach (Transform item4 in ((Component)val3).gameObject.transform)
		{
			Object.Destroy((Object)(object)((Component)item4).gameObject);
		}
		((ManualBehaviour)val3)._OnInit();
		val3.isEuler = true;
		num = 5;
		UIDysonBrush_Shell val4 = (UIDysonBrush_Shell)Object.Instantiate<UIDysonBrush>(dysnoEditor.brushes[num], ((Component)dysnoEditor.brushes[num]).transform.parent);
		brushes[num].Add((UIDysonBrush)(object)val4);
		foreach (Transform item5 in ((Component)val4).gameObject.transform)
		{
			Object.Destroy((Object)(object)((Component)item5).gameObject);
		}
		((ManualBehaviour)val4)._OnInit();
		num = 6;
		UIDysonBrush_Paint val5 = (UIDysonBrush_Paint)Object.Instantiate<UIDysonBrush>(dysnoEditor.brushes[num], ((Component)dysnoEditor.brushes[num]).transform.parent);
		brushes[num].Add((UIDysonBrush)(object)val5);
		foreach (Transform item6 in ((Component)val5).gameObject.transform)
		{
			Object.Destroy((Object)(object)((Component)item6).gameObject);
		}
		((ManualBehaviour)val5)._OnInit();
		num = 7;
		UIDysonBrush_Remove val6 = (UIDysonBrush_Remove)Object.Instantiate<UIDysonBrush>(dysnoEditor.brushes[num], ((Component)dysnoEditor.brushes[num]).transform.parent);
		brushes[num].Add((UIDysonBrush)(object)val6);
		foreach (Transform item7 in ((Component)val6).gameObject.transform)
		{
			Object.Destroy((Object)(object)((Component)item7).gameObject);
		}
		((ManualBehaviour)val6)._OnInit();
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIDysonEditor), "UpdateBrushes")]
	public static void Brushes_Prepare()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Invalid comparison between I4 and Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected I4, but got Unknown
		if (rdialCount * ((mirrorMode <= 0) ? 1 : 2) <= 1 || brushId == (int)dysnoEditor.brushMode)
		{
			return;
		}
		foreach (UIDysonBrush item in brushes[brushId])
		{
			if (item != null)
			{
				((ManualBehaviour)item)._OnClose();
			}
			if (item != null)
			{
				((Component)item).gameObject.SetActive(false);
			}
		}
		brushId = (int)dysnoEditor.brushMode;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(UIDysonEditor), "UpdateBrushes")]
	public static void Brushes_OnUpdate()
	{
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: 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_01fb: 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_020c: 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_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Invalid comparison between Unknown and I4
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: 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_0655: Unknown result type (might be due to invalid IL or missing references)
		//IL_065a: Unknown result type (might be due to invalid IL or missing references)
		//IL_065f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0664: Unknown result type (might be due to invalid IL or missing references)
		//IL_033f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_0346: Unknown result type (might be due to invalid IL or missing references)
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_034a: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0360: Unknown result type (might be due to invalid IL or missing references)
		//IL_0365: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: 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_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_0436: Unknown result type (might be due to invalid IL or missing references)
		//IL_0442: Unknown result type (might be due to invalid IL or missing references)
		//IL_044f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0459: Unknown result type (might be due to invalid IL or missing references)
		//IL_0467: Unknown result type (might be due to invalid IL or missing references)
		//IL_0473: Unknown result type (might be due to invalid IL or missing references)
		//IL_0480: Unknown result type (might be due to invalid IL or missing references)
		//IL_048a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_04da: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0500: Unknown result type (might be due to invalid IL or missing references)
		//IL_050c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0517: 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_02e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0547: Unknown result type (might be due to invalid IL or missing references)
		//IL_054c: Unknown result type (might be due to invalid IL or missing references)
		//IL_054e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0550: Unknown result type (might be due to invalid IL or missing references)
		//IL_0552: Unknown result type (might be due to invalid IL or missing references)
		//IL_0557: Unknown result type (might be due to invalid IL or missing references)
		//IL_055c: Unknown result type (might be due to invalid IL or missing references)
		//IL_055e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0563: Unknown result type (might be due to invalid IL or missing references)
		//IL_0568: Unknown result type (might be due to invalid IL or missing references)
		//IL_056d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0571: Unknown result type (might be due to invalid IL or missing references)
		//IL_0576: Unknown result type (might be due to invalid IL or missing references)
		//IL_057b: Unknown result type (might be due to invalid IL or missing references)
		//IL_057f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0584: Unknown result type (might be due to invalid IL or missing references)
		//IL_0589: Unknown result type (might be due to invalid IL or missing references)
		//IL_058e: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (brushId == 6)
			{
				if (dysnoEditor.brush_paint.castNodeGizmo != null)
				{
					paint_cast_type = 1;
				}
				else if (dysnoEditor.brush_paint.castFrameGizmo != null)
				{
					paint_cast_type = 2;
				}
				else if (dysnoEditor.brush_paint.castShellGizmo != null)
				{
					paint_cast_type = 3;
				}
				else
				{
					paint_cast_type = 0;
				}
			}
			int num = rdialCount * ((mirrorMode <= 0) ? 1 : 2);
			if (num > 1)
			{
				if (Input.GetMouseButton(0))
				{
					foreach (UIDysonBrush item in brushes[brushId])
					{
						if (!((Object)(object)item != (Object)null))
						{
							continue;
						}
						switch (brushId)
						{
						case 1:
						{
							UIDysonBrush obj = ((item is UIDysonBrush_Select) ? item : null);
							UIDysonBrush obj2 = dysnoEditor.brushes[brushId];
							UIDysonBrush_Select val2 = (UIDysonBrush_Select)(object)((obj2 is UIDysonBrush_Select) ? obj2 : null);
							((UIDysonBrush_Select)obj).selectedLayerId = val2.selectedLayerId;
							break;
						}
						case 3:
						case 4:
							((UIDysonBrush_Frame)((item is UIDysonBrush_Frame) ? item : null)).frameProtoId = dysnoEditor.frameProtoId;
							break;
						case 5:
							((UIDysonBrush_Shell)((item is UIDysonBrush_Shell) ? item : null)).shellProtoId = dysnoEditor.shellProtoId;
							break;
						case 6:
						{
							UIDysonBrush_Paint val = (UIDysonBrush_Paint)(object)((item is UIDysonBrush_Paint) ? item : null);
							if (dysnoEditor.brush_paint.pickColorMode)
							{
								return;
							}
							val.paint = dysnoEditor.brush_paint.paint;
							val.eraseMode = dysnoEditor.brush_paint.eraseMode;
							val.size = dysnoEditor.brush_paint.size;
							break;
						}
						}
					}
				}
				DysonSphere viewDysonSphere = dysnoEditor.selection.viewDysonSphere;
				DysonSphereLayer singleSelectedLayer = dysnoEditor.selection.singleSelectedLayer;
				string brushError = dysnoEditor.controlPanel.toolbox.brushError;
				overwrite = true;
				Vector3 val3 = dataPoint;
				Quaternion val4 = Quaternion.identity;
				Ray val5 = dysnoEditor.screenCamera.ScreenPointToRay(Input.mousePosition);
				paint_gridMode = (int)dysnoEditor.brushMode == 6 && dysnoEditor.brush_paint.isGridMode;
				if (clickPoint != Vector3.zero)
				{
					Vector3 origin = ((Ray)(ref val5)).origin;
					castRadius = ((Vector3)(ref origin)).magnitude * 4000f / ((Vector3)(ref rayOrigin)).magnitude;
					bool flag = Vector3.Dot(((Ray)(ref val5)).direction, clickPoint) < 0f;
					for (int num2 = viewDysonSphere.layersSorted.Length - 1; num2 >= 0; num2--)
					{
						DysonSphereLayer val6 = viewDysonSphere.layersSorted[flag ? num2 : (viewDysonSphere.layersSorted.Length - 1 - num2)];
						if (val6 != null && Mathf.Abs(val6.orbitRadius - castRadius) < 1f)
						{
							castRadius = 0f;
							val4 = val6.currentRotation;
							val3 = Quaternion.Inverse(val4) * clickPoint;
							break;
						}
					}
				}
				if (brushes[brushId].Count >= num)
				{
					for (int i = 1; i < rdialCount; i++)
					{
						Quaternion val7 = Quaternion.Euler(0f, 360f * (float)i / (float)rdialCount, 0f);
						dataPoint = val7 * val3;
						clickPoint = val4 * dataPoint;
						castRay = new Ray(val7 * ((Ray)(ref val5)).origin, val7 * ((Ray)(ref val5)).direction);
						brushes[brushId][i].SetDysonSphere(viewDysonSphere);
						brushes[brushId][i].layer = singleSelectedLayer;
						((ManualBehaviour)brushes[brushId][i])._Open();
						((Component)brushes[brushId][i]).gameObject.SetActive(true);
						((ManualBehaviour)brushes[brushId][i])._OnUpdate();
					}
					if (mirrorMode > 0)
					{
						val3.y = 0f - val3.y;
						((Ray)(ref val5)).origin = new Vector3(((Ray)(ref val5)).origin.x, 0f - ((Ray)(ref val5)).origin.y, ((Ray)(ref val5)).origin.z);
						((Ray)(ref val5)).direction = new Vector3(((Ray)(ref val5)).direction.x, 0f - ((Ray)(ref val5)).direction.y, ((Ray)(ref val5)).direction.z);
						if (mirrorMode == 2)
						{
							val3.x = 0f - val3.x;
							val3.z = 0f - val3.z;
							((Ray)(ref val5)).origin = new Vector3(0f - ((Ray)(ref val5)).origin.x, ((Ray)(ref val5)).origin.y, 0f - ((Ray)(ref val5)).origin.z);
							((Ray)(ref val5)).direction = new Vector3(0f - ((Ray)(ref val5)).direction.x, ((Ray)(ref val5)).direction.y, 0f - ((Ray)(ref val5)).direction.z);
						}
						for (int j = rdialCount; j < 2 * rdialCount; j++)
						{
							Quaternion val8 = Quaternion.Euler(0f, 360f * (float)j / (float)rdialCount, 0f);
							dataPoint = val8 * val3;
							clickPoint = val4 * dataPoint;
							castRay = new Ray(val8 * ((Ray)(ref val5)).origin, val8 * ((Ray)(ref val5)).direction);
							brushes[brushId][j].SetDysonSphere(viewDysonSphere);
							brushes[brushId][j].layer = singleSelectedLayer;
							((ManualBehaviour)brushes[brushId][j]).active = true;
							((ManualBehaviour)brushes[brushId][j])._Open();
							((Component)brushes[brushId][j]).gameObject.SetActive(true);
							((ManualBehaviour)brushes[brushId][j])._OnUpdate();
						}
					}
				}
				overwrite = false;
				dysnoEditor.controlPanel.toolbox.brushError = brushError;
				clickPoint = Vector3.zero;
				dataPoint = Vector3.zero;
			}
		}
		catch (Exception obj3)
		{
			Log.LogError(obj3);
			Comm.SetInfoString(Stringpool.SymmetricTool + " Error. The function is now disable", 120);
			ChangeParameters(0, 1);
		}
		tick = (tick + 1) % 600;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIDysonBrush_Node), "RecalcCollides")]
	public static void ForceUpdate(UIDysonBrush_Node __instance)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetMouseButtonDown(0))
		{
			__instance.lastCalcPos = Vector3.zero;
		}
	}

	[HarmonyTranspiler]
	[HarmonyPatch(typeof(UIDysonBrush_Node), "_OnUpdate")]
	[HarmonyPatch(typeof(UIDysonBrush_Frame), "_OnUpdate")]
	[HarmonyPatch(typeof(UIDysonBrush_Shell), "_OnUpdate")]
	[HarmonyPatch(typeof(UIDysonBrush_Select), "_OnUpdate")]
	[HarmonyPatch(typeof(UIDysonBrush_Remove), "_OnUpdate")]
	[HarmonyPatch(typeof(UIDysonBrush_Paint), "_OnUpdate")]
	public static IEnumerable<CodeInstruction> Transpiler_OnUpdate(IEnumerable<CodeInstruction> instructions)
	{
		List<CodeInstruction> list = instructions.ToList();
		List<CodeInstruction> list2 = new List<CodeInstruction>(list);
		try
		{
			MethodInfo method = typeof(UIDysonDrawingGrid).GetMethod("RaySnap", new Type[2]
			{
				typeof(Ray),
				typeof(Vector3).MakeByRefType()
			});
			MethodInfo method2 = typeof(UIDysonDrawingGrid).GetMethod("RaySnap", new Type[3]
			{
				typeof(Ray),
				typeof(Vector3).MakeByRefType(),
				typeof(int).MakeByRefType()
			});
			MethodInfo method3 = typeof(UIDysonDrawingGrid).GetMethod("RayCast");
			MethodInfo method4 = typeof(Phys).GetMethod("RayCastSphere", new Type[6]
			{
				typeof(Vector3),
				typeof(Vector3),
				typeof(float),
				typeof(Vector3),
				typeof(float),
				typeof(RCHCPU)
			});
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].operand is MethodInfo methodInfo)
				{
					if (list[i].opcode == OpCodes.Call && methodInfo == method4)
					{
						list[i].operand = typeof(SymmetryTool).GetMethod("Overwrite_RayCastSphere");
					}
					if (list[i].opcode == OpCodes.Callvirt && methodInfo == method)
					{
						list[i].opcode = OpCodes.Call;
						list[i].operand = typeof(SymmetryTool).GetMethod("Overwrite_RaySnap");
					}
					else if (list[i].opcode == OpCodes.Callvirt && methodInfo == method2)
					{
						list[i].opcode = OpCodes.Call;
						list[i].operand = typeof(SymmetryTool).GetMethod("Overwrite_RaySnap2");
					}
					else if (list[i].opcode == OpCodes.Callvirt && methodInfo == method3)
					{
						list[i].opcode = OpCodes.Call;
						list[i].operand = typeof(SymmetryTool).GetMethod("Overwrite_RayCast");
					}
				}
			}
		}
		catch (Exception obj)
		{
			Log.LogError(obj);
			list = list2;
			Log.LogWarning("Brush transpiler failed. Restore backup IL");
			SphereEditorTools.ErrorMessage += "SymmetryTool ";
		}
		return list.AsEnumerable();
	}

	public static bool Overwrite_RayCastSphere(Vector3 origin, Vector3 dir, float length, Vector3 center, float radius, out RCHCPU rch)
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: 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_000e: 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_001f: 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_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: 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_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		if (overwrite)
		{
			rch.point = Vector3.zero;
			rch.normal = Vector3.zero;
			if (origin == rayOrigin)
			{
				Vector3 val = center - clickPoint;
				if ((double)((Vector3)(ref val)).sqrMagnitude < 1E-06)
				{
					rch.dist = castDist;
					return true;
				}
			}
			rch.dist = 0f;
			return false;
		}
		bool num = Phys.RayCastSphere(origin, dir, length, center, radius, ref rch);
		if (num)
		{
			rayOrigin = origin;
			clickPoint = center;
			castDist = rch.dist;
		}
		return num;
	}

	public static bool Overwrite_RayCast(UIDysonDrawingGrid uidysonDrawingGrid, Ray lookRay, Quaternion rotation, float radius, out Vector3 cast, bool front = true)
	{
		//IL_002c: 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_0043: 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_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_0011: 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)
		if (overwrite)
		{
			if (radius == castRadius)
			{
				cast = dataPoint;
				return true;
			}
			cast = Vector3.zero;
			return false;
		}
		bool num = uidysonDrawingGrid.RayCast(lookRay, rotation, radius, ref cast, front);
		if (num)
		{
			castRadius = radius;
			dataPoint = cast;
		}
		return num;
	}

	public static bool Overwrite_RaySnap(UIDysonDrawingGrid uidysonDrawingGrid, Ray lookRay, out Vector3 snap)
	{
		//IL_0019: 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)
		//IL_002b: 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_000d: Unknown result type (might be due to invalid IL or missing references)
		if (overwrite)
		{
			snap = dataPoint;
			return resultSnap;
		}
		resultSnap = uidysonDrawingGrid.RaySnap(lookRay, ref snap);
		dataPoint = snap;
		return resultSnap;
	}

	public static bool Overwrite_RaySnap2(UIDysonDrawingGrid uidysonDrawingGrid, Ray lookRay, out Vector3 snap, out int triIdx)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: 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_000f: Unknown result type (might be due to invalid IL or missing references)
		if (overwrite)
		{
			if (paint_gridMode)
			{
				return uidysonDrawingGrid.RaySnap(castRay, ref snap, ref triIdx);
			}
			snap = dataPoint;
			triIdx = 0;
			return resultSnap;
		}
		resultSnap = uidysonDrawingGrid.RaySnap(lookRay, ref snap, ref triIdx);
		dataPoint = snap;
		return resultSnap;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIDysonPaintingGrid), "RayCastAndHightlight")]
	public static void Overwrite_RayCastAndHightlight(ref Ray lookRay)
	{
		//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)
		if (overwrite)
		{
			lookRay = castRay;
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIDysonBrush_Shell), "AddNodeGizmo")]
	public static bool Overwrite_AddNodeGizmo()
	{
		return !overwrite;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIDysonPaintingGrid), "SetCursorCellsGraticule")]
	[HarmonyPatch(typeof(UIDysonPaintingGrid), "SetCursorCells")]
	public static bool Overwrite_Paint()
	{
		if (overwrite)
		{
			return Input.GetMouseButton(0);
		}
		return true;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(DESelection), "OnNodeClick")]
	public static bool Overwrite_OnNodeClick(DESelection __instance, DysonNode node)
	{
		if (!overwrite || node == null)
		{
			return true;
		}
		if (!__instance.selectedNodes.Contains(node))
		{
			__instance.AddNodeSelection(node);
		}
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(DESelection), "OnFrameClick")]
	public static bool Overwrite_OnFrameClick(DESelection __instance, DysonFrame frame)
	{
		if (!overwrite || frame == null)
		{
			return true;
		}
		if (!__instance.selectedFrames.Contains(frame))
		{
			__instance.AddFrameSelection(frame);
		}
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(DESelection), "OnShellClick")]
	public static bool Overwrite_OnFrameClick(DESelection __instance, DysonShell shell)
	{
		if (!overwrite || shell == null)
		{
			return true;
		}
		if (!__instance.selectedShells.Contains(shell))
		{
			__instance.AddShellSelection(shell);
		}
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(UIDysonBrush_Paint), "_OnUpdate")]
	public static bool UIDysonBrush_Paint_OnUpdate(UIDysonBrush_Paint __instance)
	{
		//IL_0070: 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)
		//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_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: 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_012c: 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)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: 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_0626: Unknown result type (might be due to invalid IL or missing references)
		//IL_062b: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_065a: Unknown result type (might be due to invalid IL or missing references)
		//IL_064f: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0553: Unknown result type (might be due to invalid IL or missing references)
		//IL_0548: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d2: 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_05da: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0558: Unknown result type (might be due to invalid IL or missing references)
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		//IL_0365: Unknown result type (might be due to invalid IL or missing references)
		//IL_0370: 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)
		//IL_0379: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0380: Unknown result type (might be due to invalid IL or missing references)
		//IL_0382: Unknown result type (might be due to invalid IL or missing references)
		//IL_05df: Unknown result type (might be due to invalid IL or missing references)
		//IL_040a: Unknown result type (might be due to invalid IL or missing references)
		if (!overwrite)
		{
			return true;
		}
		__instance.size = ((__instance.size > __instance.maxPainterBrushSize) ? __instance.maxPainterBrushSize : __instance.size);
		UIDysonDrawingGrid[] drawingGrids = ((UIDysonBrush)__instance).editor.drawingGrids;
		Camera screenCamera = ((UIDysonBrush)__instance).editor.screenCamera;
		UIDysonPaintingGrid val = ((UIDysonBrush)__instance).editor.paintingGrids[((UIDysonBrush)__instance).layer.paintingGridMode];
		if (!RectTransformUtility.RectangleContainsScreenPoint(((UIDysonBrush)__instance).editor.controlPanel.inspector.selfRect, Vector2.op_Implicit(Input.mousePosition), ((UIDysonBrush)__instance).editor.uiCamera) && !RectTransformUtility.RectangleContainsScreenPoint(((UIDysonBrush)__instance).editor.controlPanel.hierarchy.selfRect, Vector2.op_Implicit(Input.mousePosition), ((UIDysonBrush)__instance).editor.uiCamera))
		{
			if (__instance.eraseMode)
			{
				UICursor.SetCursor((ECursor)12);
			}
			else if (__instance.pickColorMode)
			{
				UICursor.SetCursor((ECursor)11);
			}
			else
			{
				UICursor.SetCursor((ECursor)10);
			}
		}
		if (!UIBlockZone.blocked && !UIDysonEditor.onGUIOperate)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			if (((UIDysonBrush)__instance).layer != null)
			{
				int id = ((UIDysonBrush)__instance).layer.id;
				Ray val2 = screenCamera.ScreenPointToRay(Input.mousePosition);
				Ray val3 = val2;
				((Ray)(ref val3)).origin = ((Ray)(ref val3)).origin / (float)((double)((UIDysonBrush)__instance).layer.orbitRadius * 0.00025);
				if (paint_cast_type == 1)
				{
					for (int i = 1; i < ((UIDysonBrush)__instance).layer.nodeCursor; i++)
					{
						if (((UIDysonBrush)__instance).layer.nodePool[i] != null && ((UIDysonBrush)__instance).layer.nodePool[i].id == i && Vector3.SqrMagnitude(((Vector3)(ref ((UIDysonBrush)__instance).layer.nodePool[i].pos)).normalized - dataPoint) < 0.001f)
						{
							num2 = i;
							num = id;
						}
					}
				}
				__instance._tmp_frame_list.Clear();
				__instance._tmp_shell_list.Clear();
				if (Overwrite_RayCast(drawingGrids[0], val2, ((UIDysonBrush)__instance).layer.currentRotation, ((UIDysonBrush)__instance).layer.orbitRadius, out var cast))
				{
					double num5 = 0.16099441051483154;
					Vector3 val5;
					for (int j = 1; j < ((UIDysonBrush)__instance).layer.nodeCursor; j++)
					{
						DysonNode val4 = ((UIDysonBrush)__instance).layer.nodePool[j];
						if (val4 == null || val4.id != j)
						{
							continue;
						}
						val5 = ((Vector3)(ref ((UIDysonBrush)__instance).layer.nodePool[j].pos)).normalized - cast;
						if (!((double)((Vector3)(ref val5)).sqrMagnitude < num5))
						{
							continue;
						}
						List<DysonFrame> frames = val4.frames;
						for (int k = 0; k < frames.Count; k++)
						{
							if (!__instance._tmp_frame_list.Contains(frames[k]))
							{
								__instance._tmp_frame_list.Add(frames[k]);
							}
						}
						List<DysonShell> shells = val4.shells;
						for (int l = 0; l < shells.Count; l++)
						{
							if (!__instance._tmp_shell_list.Contains(shells[l]))
							{
								__instance._tmp_shell_list.Add(shells[l]);
							}
						}
					}
					float num6 = 0.00028900002f;
					DysonFrame val6 = null;
					DysonShell val7 = null;
					foreach (DysonFrame item in __instance._tmp_frame_list)
					{
						List<Vector3> segments = item.GetSegments();
						for (int m = 0; m < segments.Count - 1; m++)
						{
							val5 = segments[m];
							Vector3 normalized = ((Vector3)(ref val5)).normalized;
							val5 = segments[m + 1];
							Vector3 normalized2 = ((Vector3)(ref val5)).normalized;
							float num7 = UIDysonBrush_Paint.PointToSegmentSqr(normalized, normalized2, cast);
							if (num7 < num6)
							{
								num6 = num7;
								val6 = item;
							}
						}
					}
					VectorLF3 val8 = VectorLF3.op_Implicit(cast * ((UIDysonBrush)__instance).layer.orbitRadius);
					if (val6 != null)
					{
						num3 = val6.id;
						num = id;
					}
					else
					{
						foreach (DysonShell item2 in __instance._tmp_shell_list)
						{
							if (item2.IsPointInShell(val8))
							{
								val7 = item2;
								break;
							}
						}
						if (val7 != null)
						{
							num4 = val7.id;
							num = id;
						}
					}
				}
				__instance._tmp_frame_list.Clear();
			}
			if (num > 0 && ((UIDysonBrush)__instance).layer != null)
			{
				if (num2 > 0 && (__instance.targetFilter & 1) > 0)
				{
					DysonNode val10 = (__instance.castNodeGizmo = ((UIDysonBrush)__instance).layer.nodePool[num2]);
					DysonNode val11 = val10;
					__instance.castFrameGizmo = null;
					__instance.castShellGizmo = null;
					if (__instance.pickColorMode)
					{
						return false;
					}
					if (Input.GetMouseButton(0))
					{
						val11.color = (Color32)(__instance.eraseMode ? new Color32((byte)0, (byte)0, (byte)0, (byte)0) : __instance.paint);
						((UIDysonBrush)__instance).editor.selection.viewDysonSphere.UpdateColor(val11);
					}
				}
				else if (num3 > 0 && (__instance.targetFilter & 2) > 0)
				{
					__instance.castNodeGizmo = null;
					DysonFrame val13 = (__instance.castFrameGizmo = ((UIDysonBrush)__instance).layer.framePool[num3]);
					DysonFrame val14 = val13;
					__instance.castShellGizmo = null;
					if (__instance.pickColorMode)
					{
						return false;
					}
					if (Input.GetMouseButton(0))
					{
						val14.color = (Color32)(__instance.eraseMode ? new Color32((byte)0, (byte)0, (byte)0, (byte)0) : __instance.paint);
						((UIDysonBrush)__instance).editor.selection.viewDysonSphere.UpdateColor(val14);
					}
				}
				else if (num4 > 0 && (__instance.targetFilter & 4) > 0)
				{
					__instance.castNodeGizmo = null;
					__instance.castFrameGizmo = null;
					DysonShell val16 = (__instance.castShellGizmo = ((UIDysonBrush)__instance).layer.shellPool[num4]);
					DysonShell val17 = val16;
					if (__instance.pickColorMode)
					{
						return false;
					}
					if (Input.GetMouseButton(0))
					{
						val17.color = (Color32)(__instance.eraseMode ? new Color32((byte)0, (byte)0, (byte)0, (byte)0) : __instance.paint);
					}
				}
				else
				{
					__instance.castNodeGizmo = null;
					__instance.castFrameGizmo = null;
					__instance.castShellGizmo = null;
				}
			}
			else
			{
				__instance.castNodeGizmo = null;
				__instance.castFrameGizmo = null;
				__instance.castShellGizmo = null;
			}
			if (__instance.isGridMode)
			{
				if (__instance.pickColorMode)
				{
					return false;
				}
				if (val.RayCastAndHightlight(screenCamera.ScreenPointToRay(Input.mousePosition), __instance.size) && Input.GetMouseButton(0))
				{
					val.PaintCells((Color32)(__instance.eraseMode ? new Color32((byte)0, (byte)0, (byte)0, (byte)0) : __instance.paint));
				}
			}
			if (__instance.pickColorMode && Input.GetMouseButtonUp(0))
			{
				__instance.pickColorMode = false;
			}
			if (Input.GetMouseButtonDown(1))
			{
				if (!__instance.isGridMode)
				{
					((UIDysonBrush)__instance).editor.brushMode = (EBrushMode)1;
					((ManualBehaviour)__instance)._Close();
					return false;
				}
				__instance.paintingbox.SwitchPaintingGrid();
			}
			if (Input.GetKeyDown((KeyCode)101))
			{
				__instance.eraseMode = !__instance.eraseMode;
				return false;
			}
		}
		else
		{
			__instance.castNodeGizmo = null;
			__instance.castFrameGizmo = null;
			__instance.castShellGizmo = null;
			val.ClearCursorCells();
		}
		return false;
	}
}
[BepInPlugin("com.starfi5h.plugin.SphereEditorTools", "SphereEditorTools", "2.2.3")]
public class SphereEditorTools : BaseUnityPlugin
{
	private Harmony harmony;

	internal static string ErrorMessage;

	internal static ConfigFile Config;

	public static ConfigEntry<bool> EnableToolboxHotkey;

	public static ConfigEntry<bool> EnableDisplayOptions;

	public static ConfigEntry<bool> EnableSymmetryTool;

	public static ConfigEntry<bool> EnableOrbitTool;

	public static ConfigEntry<bool> EnableVisualEffect;

	public static ConfigEntry<bool> EnableGUI;

	public static ConfigEntry<string> WindowPosition;

	public static ConfigEntry<string> WindowSize;

	public static ConfigEntry<string> KeySelect;

	public static ConfigEntry<string> KeyNode;

	public static ConfigEntry<string> KeyFrameGeo;

	public static ConfigEntry<string> KeyFrameEuler;

	public static ConfigEntry<string> KeyShell;

	public static ConfigEntry<string> KeyGrid;

	public static ConfigEntry<string> KeyShowAllLayers;

	public static ConfigEntry<string> KeyHideMode;

	public static ConfigEntry<string> KeySymmetryTool;

	public static ConfigEntry<string> KeyMirroring;

	public static ConfigEntry<string> KeyRotationInc;

	public static ConfigEntry<string> KeyRotationDec;

	public static ConfigEntry<string> VFXchainedSequence;

	private void BindConfig()
	{
		EnableToolboxHotkey = Config.Bind<bool>("- General -", "EnableToolboxHotkey", true, "Switch between build plan tools with hotkeys.\n启用工具箱热键");
		EnableDisplayOptions = Config.Bind<bool>("- General -", "EnableDisplayOptions", true, "Enable display control of star and black mask.\n启用显示控制(恒星/黑色遮罩)");
		EnableSymmetryTool = Config.Bind<bool>("- General -", "EnableSymmetryTool", true, "Enable mirror and rotation symmetry of building tools.\n启用对称建造工具(镜像/旋转)");
		EnableOrbitTool = Config.Bind<bool>("- General -", "EnableOrbitTool", true, "Enable dyson sphere layer orbit modifiy tool.\n启用壳层轨道工具");
		EnableGUI = Config.Bind<bool>("GUI", "EnableGUI", true, "Show a simple window to use the tools. \n启用图形操作界面窗口");
		WindowPosition = Config.Bind<string>("GUI", "WindowPosition", "300, 250", "Position of the window. Format: x,y\n窗口的位置 格式: x,y");
		WindowSize = Config.Bind<string>("GUI", "WindowSize", "240, 200", "Size of the window. Format: width,height\n窗口的大小 格式: 宽度,高度");
		KeySelect = Config.Bind<string>("Hotkeys - Toolbox", "KeySelect", "space", "Inspect / 查看");
		KeyNode = Config.Bind<string>("Hotkeys - Toolbox", "KeyNode", "q", "Build Node / 修建节点");
		KeyFrameGeo = Config.Bind<string>("Hotkeys - Toolbox", "KeyFrameGeo", "w", "Build Frame(Geodesic) / 修建测地线框架");
		KeyFrameEuler = Config.Bind<string>("Hotkeys - Toolbox", "KeyFrameEuler", "e", "Build Frame(Euler) / 修建经纬度框架");
		KeyShell = Config.Bind<string>("Hotkeys - Toolbox", "KeyShell", "r", "Build Shell / 修建壳");
		KeyGrid = Config.Bind<string>("Hotkeys - Toolbox", "KeyGrid", "g", "Toggle Grid / 切换网格");
		KeyHideMode = Config.Bind<string>("Hotkeys - Visibility", "KeyHideMode", "h", "Toggle mask & star display mode / 切换遮罩與恒星显示模式");
		KeySymmetryTool = Config.Bind<string>("Hotkeys - Symmetry Tool", "KeySymmetryTool", "tab", "Toggle symmetry tool / 开关对称建造工具");
		KeyMirroring = Config.Bind<string>("Hotkeys - Symmetry Tool", "KeyMirroring", "m", "Toggle mirroring mode / 切换镜像对称模式");
		KeyRotationInc = Config.Bind<string>("Hotkeys - Symmetry Tool", "KeyRotationInc", "[+]", "Increase the degree of rotational symmetry / 增加旋转对称的个数");
		KeyRotationDec = Config.Bind<string>("Hotkeys - Symmetry Tool", "KeyRotationDec", "[-]", "Decrease the degree of rotational symmetry / 减少旋转对称的个数");
	}

	public void Start()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		harmony = new Harmony("com.starfi5h.plugin.SphereEditorTools");
		Config = ((BaseUnityPlugin)this).Config;
		BindConfig();
		Log.Init(((BaseUnityPlugin)this).Logger);
		TryPatch(typeof(Comm));
		if (EnableDisplayOptions.Value)
		{
			TryPatch(typeof(HideLayer));
		}
		if (EnableSymmetryTool.Value)
		{
			TryPatch(typeof(SymmetryTool));
		}
		if (EnableOrbitTool.Value)
		{
			TryPatch(typeof(EditOrbit));
		}
		if (EnableGUI.Value)
		{
			UIWindow.LoadWindowPos();
			UIWindow.LoadWindowSize();
		}
	}

	public void TryPatch(Type type)
	{
		try
		{
			harmony.PatchAll(type);
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Patch " + type.Name + " error"));
			((BaseUnityPlugin)this).Logger.LogError((object)ex);
			throw new Exception("SphereEditorTools: " + type.Name + " patch error. Disable this function in the config file.\n" + ex.ToString());
		}
	}

	public void OnGUI()
	{
		if (UIWindow.isShow)
		{
			UIWindow.OnGUI();
		}
	}

	public void OnDestroy()
	{
		harmony.UnpatchSelf();
		HideLayer.Free();
		SymmetryTool.Free();
	}
}
public static class Log
{
	private static ManualLogSource _logger;

	public static void Init(ManualLogSource logger)
	{
		_logger = logger;
	}

	public static void LogError(object obj)
	{
		_logger.LogError(obj);
	}

	public static void LogWarning(object obj)
	{
		_logger.LogWarning(obj);
	}

	public static void LogInfo(object obj)
	{
		_logger.LogInfo(obj);
	}

	public static void LogDebug(object obj)
	{
		_logger.LogDebug(obj);
	}

	public static void LogPeriod(object obj)
	{
		if (GameMain.gameTick % 600 == 0L)
		{
			_logger.LogDebug(obj);
		}
	}
}
internal class UIWindow
{
	public static bool isShow;

	private static bool isMin;

	private static Rect normalSize = new Rect(0f, 0f, 240f, 200f);

	private static Rect miniSize = new Rect(0f, 0f, 75f, 20f);

	private static Rect windowRect = new Rect(300f, 250f, 240f, 200f);

	private static GUIStyle textStyle;

	public static string SpeedInput;

	public static void LoadWindowPos()
	{
		try
		{
			string[] array = SphereEditorTools.WindowPosition.Value.Split(new char[1] { ',' });
			int num = int.Parse(array[0].Trim());
			int num2 = int.Parse(array[^1].Trim());
			((Rect)(ref windowRect)).x = num;
			((Rect)(ref windowRect)).y = num2;
		}
		catch (Exception obj)
		{
			Log.LogWarning("WindowPos parse error, use defualt position (300, 250)");
			Log.LogWarning(obj);
		}
	}

	public static void LoadWindowSize()
	{
		try
		{
			string[] array = SphereEditorTools.WindowSize.Value.Split(new char[1] { ',' });
			int num = int.Parse(array[0].Trim());
			int num2 = int.Parse(array[^1].Trim());
			((Rect)(ref normalSize)).width = num;
			((Rect)(ref normalSize)).height = num2;
			Log.LogDebug($"window size: {num},{num2}");
		}
		catch (Exception obj)
		{
			Log.LogWarning("WindowPos parse error, use defualt size (240, 200)");
			Log.LogWarning(obj);
			((Rect)(ref normalSize)).width = 240f;
			((Rect)(ref normalSize)).height = 200f;
		}
		((Rect)(ref windowRect)).width = ((Rect)(ref normalSize)).width;
		((Rect)(ref windowRect)).height = ((Rect)(ref normalSize)).height;
	}

	public static void SaveWindowPos()
	{
		string value = $"{((Rect)(ref windowRect)).x}, {((Rect)(ref windowRect)).y}";
		SphereEditorTools.WindowPosition.Value = value;
	}

	public static void OnOpen()
	{
		isShow = true;
		SpeedInput = "";
	}

	public static void OnClose()
	{
		isShow = false;
	}

	public static void OnGUI()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_0049: 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_000c: 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_0027: Expected O, but got Unknown
		//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_0053: Unknown result type (might be due to invalid IL or missing references)
		if (isMin)
		{
			windowRect = GUI.Window(1297890671, windowRect, new WindowFunction(MinWindowFun), Stringpool.Tool);
		}
		else
		{
			windowRect = GUI.Window(1297890671, windowRect, new WindowFunction(NormalWindowFun), Stringpool.Tool);
		}
		EatInputInRect(windowRect);
	}

	private static void MinWindowFun(int id)
	{
		//IL_0014: 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)
		GUILayout.BeginArea(new Rect(10f, 1f, 40f, 16f));
		GUILayout.Label(Stringpool.Tool, Array.Empty<GUILayoutOption>());
		GUILayout.EndArea();
		GUILayout.BeginArea(new Rect(((Rect)(ref windowRect)).width - 27f, 1f, 25f, 16f));
		if (GUILayout.Button("▼", Array.Empty<GUILayoutOption>()))
		{
			isMin = false;
			((Rect)(ref windowRect)).height = ((Rect)(ref normalSize)).height;
			((Rect)(ref windowRect)).width = ((Rect)(ref normalSize)).width;
			((Rect)(ref windowRect)).x = ((Rect)(ref windowRect)).x - (((Rect)(ref normalSize)).width - ((Rect)(ref miniSize)).width);
		}
		GUILayout.EndArea();
		GUI.DragWindow();
	}

	private static void NormalWindowFun(int id)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: 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_028c: Expected O, but got Unknown
		GUILayout.BeginArea(new Rect(((Rect)(ref windowRect)).width - 27f, 1f, 25f, 16f));
		if (GUILayout.Button("▲", Array.Empty<GUILayoutOption>()))
		{
			isMin = true;
			((Rect)(ref windowRect)).height = ((Rect)(ref miniSize)).height;
			((Rect)(ref windowRect)).width = ((Rect)(ref miniSize)).width;
			((Rect)(ref windowRect)).x = ((Rect)(ref windowRect)).x + (((Rect)(ref normalSize)).width - ((Rect)(ref miniSize)).width);
			return;
		}
		GUILayout.EndArea();
		if (SphereEditorTools.EnableDisplayOptions.Value)
		{
			GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(Stringpool.Display_options, Array.Empty<GUILayoutOption>());
			bool flag = Comm.DisplayMode < 2;
			if (flag != GUILayout.Toggle(flag, Stringpool.Star, Array.Empty<GUILayoutOption>()))
			{
				Comm.DisplayMode ^= 2;
				HideLayer.SetDisplayMode(Comm.DisplayMode);
			}
			if (HideLayer.EnableMask != GUILayout.Toggle(HideLayer.EnableMask, Stringpool.Mask, Array.Empty<GUILayoutOption>()))
			{
				HideLayer.SetMask(!HideLayer.EnableMask);
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}
		if (SphereEditorTools.EnableSymmetryTool.Value)
		{
			GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(Stringpool.SymmetryTool, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(180f) });
			if (GUILayout.Toggle(Comm.SymmetricMode, "", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(20f) }) != Comm.SymmetricMode)
			{
				Comm.SetSymmetricMode(!Comm.SymmetricMode);
			}
			GUILayout.EndHorizontal();
			int result = GUILayout.Toolbar(Comm.MirrorMode, Stringpool.MirrorModes, Array.Empty<GUILayoutOption>());
			if (result != Comm.MirrorMode)
			{
				Comm.MirrorMode = result;
				SymmetryTool.ChangeParameters(Comm.MirrorMode, Comm.RadialCount);
				Comm.SymmetricMode = true;
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("<<", Array.Empty<GUILayoutOption>()))
			{
				Comm.RadialCount = Math.Max(Comm.RadialCount - 10, 1);
				SymmetryTool.ChangeParameters(Comm.MirrorMode, Comm.RadialCount);
				Comm.SymmetricMode = true;
			}
			if (GUILayout.Button("-", Array.Empty<GUILayoutOption>()))
			{
				if (Comm.RadialCount > 1)
				{
					SymmetryTool.ChangeParameters(Comm.MirrorMode, --Comm.RadialCount);
				}
				Comm.SymmetricMode = true;
			}
			if (textStyle == null)
			{
				textStyle = new GUIStyle(GUI.skin.textField)
				{
					alignment = (TextAnchor)4
				};
			}
			if (int.TryParse(GUILayout.TextField(Comm.RadialCount.ToString(), 3, textStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(35f) }), out result) && result != Comm.RadialCount && result < Comm.MaxRadialCount && result > 0)
			{
				Comm.RadialCount = result;
				SymmetryTool.ChangeParameters(Comm.MirrorMode, Comm.RadialCount);
				Comm.SymmetricMode = true;
			}
			if (GUILayout.Button("+", Array.Empty<GUILayoutOption>()))
			{
				if (Comm.RadialCount < Comm.MaxRadialCount)
				{
					SymmetryTool.ChangeParameters(Comm.MirrorMode, ++Comm.RadialCount);
				}
				Comm.SymmetricMode = true;
			}
			if (GUILayout.Button(">>", Array.Empty<GUILayoutOption>()))
			{
				Comm.RadialCount = Math.Min(Comm.RadialCount + 10, Comm.MaxRadialCount);
				SymmetryTool.ChangeParameters(Comm.MirrorMode, Comm.RadialCount);
				Comm.SymmetricMode = true;
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}
		if (SphereEditorTools.EnableOrbitTool.Value)
		{
			GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(Stringpool.OrbitTool, Array.Empty<GUILayoutOption>());
			bool flag = EditOrbit.EnableAnchorMode;
			if (flag != GUILayout.Toggle(flag, Stringpool.AnchorMode, Array.Empty<GUILayoutOption>()))
			{
				EditOrbit.Toggle(!flag);
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(Stringpool.AngularSpeed, Array.Empty<GUILayoutOption>());
			SpeedInput = GUILayout.TextField(SpeedInput, 7, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(35f) });
			if (GUILayout.Button(Stringpool.Set1, Array.Empty<GUILayoutOption>()))
			{
				if (float.TryParse(SpeedInput, out var result2) && result2 >= 0f)
				{
					EditOrbit.TrySetAngularSpeed(result2);
				}
				else if (SpeedInput == "")
				{
					EditOrbit.TrySetAngularSpeed(-1f);
				}
				else
				{
					SpeedInput = EditOrbit.AuglarSpeed.ToString();
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}
		GUI.DragWindow();
	}

	public static void EatInputInRect(Rect eatRect)
	{
		//IL_0013: 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_002e: Unknown result type (might be due to invalid IL or missing references)
		if ((Input.GetMouseButton(0) || Input.GetMouseButtonDown(0)) && ((Rect)(ref eatRect)).Contains(new Vector2(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y)))
		{
			Input.ResetInputAxes();
		}
	}
}