Decompiled source of Star System Explorer v2.5.5

BepInEx/plugins/StarSystemExplorer/Star.System.Explorer.v.2.5.5.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("2.5.5.0")]
[assembly: AssemblyInformationalVersion("2.5.5")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("2.5.5.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace StarSystemExplorer
{
	[BepInPlugin("com.lokimoonlabs.starsystemexplorer", "Star System Explorer", "2.5.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		private enum ExplorerContext
		{
			None,
			InGame,
			Preview
		}

		private sealed class TableLayoutItem
		{
			public bool IsGroupHeader;

			public Row Row;

			public string StarName;

			public bool Collapsed;

			public int GroupCount;

			public float Y;

			public float Height;

			public int RowStripeIndex;

			public string[] ResourceLines;

			public static TableLayoutItem ForGroup(float y, float height, string starName, bool collapsed, int groupCount)
			{
				return new TableLayoutItem
				{
					IsGroupHeader = true,
					StarName = (starName ?? string.Empty),
					Collapsed = collapsed,
					GroupCount = groupCount,
					Y = y,
					Height = height,
					RowStripeIndex = -1
				};
			}

			public static TableLayoutItem ForRow(float y, float height, Row row, int stripeIndex, string[] resourceLines)
			{
				return new TableLayoutItem
				{
					IsGroupHeader = false,
					Row = row,
					Y = y,
					Height = height,
					RowStripeIndex = stripeIndex,
					ResourceLines = resourceLines
				};
			}
		}

		private sealed class Row
		{
			public string StarSystem = "";

			public string Planet = "";

			public string Type = "";

			public string Ocean = "";

			public string Solar = "";

			public string Wind = "";

			public string Distance = "";

			public string Resources = "";

			public object StarObject;

			public object PlanetObject;

			public bool HasResources;

			public bool ResourcesKnown;
		}

		private const int WindowId = 38127;

		private const float DesignWidth = 1850f;

		private const float DesignHeight = 1050f;

		private const float SidebarWidth = 220f;

		private static Plugin Instance;

		private static readonly List<Rect> inputRectsCollecting = new List<Rect>(1);

		private static readonly List<Rect> inputRectsPublished = new List<Rect>(1);

		private static int inputRectPassFrame = -1;

		private static int inputStateFrame = -1;

		private static bool inputCursorOver;

		private Harmony inputHarmony;

		private GameObject inputBlockerCanvasObject;

		private Canvas inputBlockerCanvas;

		private GraphicRaycaster inputBlockerRaycaster;

		private Image inputBlockerImage;

		private RectTransform inputBlockerRect;

		private const KeyCode ToggleKey = (KeyCode)287;

		private const int MaxVirtualizedRowsPerFrame = 48;

		private const float InitialWindowScale = 0.95f;

		private bool visible;

		private bool showVeinAmount = true;

		private string search = string.Empty;

		private Vector2 scroll;

		private Rect windowRect;

		private bool cacheBuilt;

		private bool cacheDirty = true;

		private bool sortingDirty;

		private bool building;

		private string status = "Loading...";

		private string sortKey = "StarSystem";

		private bool sortAscending = true;

		private int lastRowCount;

		private double nextAutoRefresh;

		private double nextContextCheck;

		private double nextPreviewScanPoll;

		private ExplorerContext currentContext;

		private object cachedGalaxySource;

		private string previewContextText = string.Empty;

		private readonly List<object> previewPendingScans = new List<object>(16);

		private readonly Dictionary<string, object> starObjectsByName = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);

		private float[] cachedColumnWidths;

		private int cachedColumnRowCount = -1;

		private int cachedColumnAreaWidth = -1;

		private float[] manualColumnWidths;

		private int activeColumnDivider = -1;

		private float columnResizeStartMouseX;

		private float columnResizeStartLeftWidth;

		private const float ColumnResizeHandleHalfWidth = 6f;

		private const int ColumnResizeControlHint = 3812701;

		private readonly List<TableLayoutItem> tableLayout = new List<TableLayoutItem>(4096);

		private bool tableLayoutDirty = true;

		private float cachedTableContentHeight;

		private float cachedLayoutResourceWidth = -1f;

		private const float TableMinimumRowHeight = 37f;

		private const float TableResourceLineHeight = 22f;

		private const float TableRowVerticalPadding = 8f;

		private const float TableGroupHeaderHeight = 30f;

		private const float TableVirtualizationOverscan = 74f;

		private readonly List<Row> allRows = new List<Row>(2048);

		private readonly List<Row> allStarRows = new List<Row>(1024);

		private readonly List<Row> visibleRows = new List<Row>(2048);

		private readonly Dictionary<string, MemberInfo> memberCache = new Dictionary<string, MemberInfo>();

		private readonly Dictionary<Type, Dictionary<string, MemberInfo>> typeMemberCache = new Dictionary<Type, Dictionary<string, MemberInfo>>();

		private readonly Dictionary<string, int> visibleStarGroupCounts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

		private readonly Dictionary<int, string> itemNameCache = new Dictionary<int, string>();

		private int cachedStarSystemCount;

		private GUIStyle titleStyle;

		private GUIStyle windowTitleStyle;

		private GUIStyle headerStyle;

		private GUIStyle cellStyle;

		private GUIStyle smallStyle;

		private GUIStyle sidebarSectionTitleStyle;

		private GUIStyle sectionStyle;

		private GUIStyle toolbarButtonStyle;

		private GUIStyle searchStyle;

		private GUIStyle navStyle;

		private GUIStyle navSelectedStyle;

		private GUIStyle statusStyle;

		private GUIStyle rowAltStyle;

		private GUIStyle locateStyle;

		private GUIStyle filterButtonStyle;

		private GUIStyle filterDropdownItemStyle;

		private GUIStyle filterDropdownArrowStyle;

		private GUIStyle closeButtonStyle;

		private Texture2D searchIconTexture;

		private Texture2D panelTexture;

		private Texture2D panelAltTexture;

		private Texture2D borderTexture;

		private Texture2D accentTexture;

		private Texture2D selectedTexture;

		private int navMode;

		private const float ResizeGrip = 12f;

		private const float MinWindowWidth = 900f;

		private const float MinWindowHeight = 520f;

		private bool resizing;

		private bool resizeLeft;

		private bool resizeRight;

		private bool resizeTop;

		private bool resizeBottom;

		private Vector2 resizeStartMouse;

		private Rect resizeStartRect;

		private string filterPlanetType = "All";

		private string filterStarSystem = "All";

		private int openSidebarDropdown = -1;

		private Vector2 sidebarDropdownScroll = Vector2.zero;

		private readonly HashSet<string> collapsedStarSystems = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static readonly string[] ResourceNames = new string[14]
		{
			"Iron", "Copper", "Silicon", "Titanium", "Stone", "Coal", "Crude Oil", "Fire Ice", "Kimberlite", "Fractal Silicon",
			"Organic Crystal", "Optical Grating Crystal", "Spiniform Stalagmite Crystal", "Unipolar Magnet"
		};

		private static readonly int[] ResourceVeinTypes = new int[14]
		{
			1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
			11, 12, 13, 14
		};

		private void Awake()
		{
			//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)
			Instance = this;
			windowRect = CenterRect(1757.5f, 997.5f);
			InstallDspInputGuard();
			EnsureInputBlocker();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Star System Explorer 2.5.5 loaded. Explorer supports live-game and Galaxy Select preview data while preserving the DSPCalculator-style input blockers.");
		}

		private void OnDestroy()
		{
			try
			{
				if (inputHarmony != null)
				{
					inputHarmony.UnpatchSelf();
				}
			}
			catch
			{
			}
			inputRectsCollecting.Clear();
			inputRectsPublished.Clear();
			inputCursorOver = false;
			DestroyInputBlocker();
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		private void InstallDspInputGuard()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			try
			{
				inputHarmony = new Harmony("com.lokimoonlabs.starsystemexplorer.inputguard");
				inputHarmony.Patch((MethodBase)AccessTools.Method(typeof(VFInput), "UpdateGameStates", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "VFInputUpdateGameStatesPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				MethodInfo methodInfo = AccessTools.Method(typeof(UIGalaxySelect), "SetStarmapGalaxy", (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					inputHarmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "UIGalaxySelectSetStarmapGalaxyPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)"DSP input guard and Galaxy Select preview invalidation patches installed successfully.");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failed to install DSP VFInput input guard: " + ex));
			}
		}

		[HarmonyAfter(new string[] { "dsp.galactic-scale.2" })]
		private static void UIGalaxySelectSetStarmapGalaxyPostfix()
		{
			Plugin instance = Instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.MarkPreviewGalaxyDirty();
			}
		}

		[HarmonyAfter(new string[] { "com.livinginstinkt.dsp.cruiseassistplus" })]
		private static void VFInputUpdateGameStatesPostfix()
		{
			Plugin instance = Instance;
			if ((Object)(object)instance == (Object)null || !instance.visible)
			{
				inputCursorOver = false;
				return;
			}
			UpdateInputCursorState();
			if (inputCursorOver)
			{
				VFInput.onGUI = true;
				bool num = Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetMouseButton(2);
				bool flag = Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2);
				if (!num || flag)
				{
					VFInput.onGUIOperate = true;
				}
				VFInput.inScrollView = true;
			}
		}

		private void EnsureInputBlocker()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)inputBlockerCanvasObject != (Object)null))
			{
				inputBlockerCanvasObject = new GameObject("Star System Explorer - Input Blocker");
				Object.DontDestroyOnLoad((Object)(object)inputBlockerCanvasObject);
				inputBlockerCanvas = inputBlockerCanvasObject.AddComponent<Canvas>();
				inputBlockerCanvas.renderMode = (RenderMode)0;
				inputBlockerCanvas.overrideSorting = true;
				inputBlockerCanvas.sortingOrder = 32767;
				inputBlockerRaycaster = inputBlockerCanvasObject.AddComponent<GraphicRaycaster>();
				GameObject val = new GameObject("ExplorerWindowRaycastTarget");
				val.transform.SetParent(inputBlockerCanvasObject.transform, false);
				inputBlockerRect = val.AddComponent<RectTransform>();
				inputBlockerImage = val.AddComponent<Image>();
				((Graphic)inputBlockerImage).color = new Color(1f, 1f, 1f, 0f);
				((Graphic)inputBlockerImage).raycastTarget = true;
				inputBlockerRect.anchorMin = new Vector2(0.5f, 0.5f);
				inputBlockerRect.anchorMax = new Vector2(0.5f, 0.5f);
				inputBlockerRect.pivot = new Vector2(0.5f, 0.5f);
				((Transform)inputBlockerRect).localScale = Vector3.one;
				inputBlockerRect.anchoredPosition = Vector2.zero;
				inputBlockerRect.sizeDelta = Vector2.zero;
				inputBlockerCanvasObject.SetActive(false);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Created uGUI input blockers using GraphicRaycaster + transparent Image.raycastTarget=true.");
			}
		}

		private void UpdateInputBlocker()
		{
			//IL_0045: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)inputBlockerCanvas == (Object)null || (Object)(object)inputBlockerRect == (Object)null)
			{
				return;
			}
			if (!visible)
			{
				if (inputBlockerCanvasObject.activeSelf)
				{
					inputBlockerCanvasObject.SetActive(false);
				}
				return;
			}
			Camera val = (((int)inputBlockerCanvas.renderMode == 0) ? null : inputBlockerCanvas.worldCamera);
			Vector2 val2 = new Vector2(((Rect)(ref windowRect)).x, (float)Screen.height - ((Rect)(ref windowRect)).y);
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(((Rect)(ref windowRect)).x + ((Rect)(ref windowRect)).width, (float)Screen.height - (((Rect)(ref windowRect)).y + ((Rect)(ref windowRect)).height));
			Vector2 val4 = (val2 + val3) * 0.5f;
			Transform transform = ((Component)inputBlockerCanvas).transform;
			Vector2 anchoredPosition = default(Vector2);
			if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((transform is RectTransform) ? transform : null), val4, val, ref anchoredPosition))
			{
				inputBlockerRect.anchoredPosition = anchoredPosition;
				inputBlockerRect.sizeDelta = new Vector2(((Rect)(ref windowRect)).width, ((Rect)(ref windowRect)).height);
				if (!inputBlockerCanvasObject.activeSelf)
				{
					inputBlockerCanvasObject.SetActive(true);
				}
			}
		}

		private void DestroyInputBlocker()
		{
			if ((Object)(object)inputBlockerCanvasObject != (Object)null)
			{
				try
				{
					Object.Destroy((Object)(object)inputBlockerCanvasObject);
				}
				catch
				{
				}
			}
			inputBlockerCanvasObject = null;
			inputBlockerCanvas = null;
			inputBlockerRaycaster = null;
			inputBlockerImage = null;
			inputBlockerRect = null;
		}

		private static void BeginInputPass()
		{
			int frameCount = Time.frameCount;
			if (frameCount != inputRectPassFrame)
			{
				inputRectsPublished.Clear();
				inputRectsPublished.AddRange(inputRectsCollecting);
				inputRectPassFrame = frameCount;
			}
			inputRectsCollecting.Clear();
		}

		private static void RegisterInputRect(Rect rect)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			inputRectsCollecting.Add(rect);
		}

		private static void UpdateInputCursorState()
		{
			//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_0030: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			int frameCount = Time.frameCount;
			if (frameCount == inputStateFrame)
			{
				return;
			}
			inputStateFrame = frameCount;
			if (inputRectsPublished.Count == 0)
			{
				inputCursorOver = false;
				return;
			}
			Vector3 mousePosition = Input.mousePosition;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(mousePosition.x, (float)Screen.height - mousePosition.y);
			bool flag = false;
			for (int i = 0; i < inputRectsPublished.Count; i++)
			{
				Rect val2 = inputRectsPublished[i];
				if (((Rect)(ref val2)).Contains(val))
				{
					flag = true;
					break;
				}
			}
			inputCursorOver = flag;
		}

		private void Update()
		{
			//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_002f: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown((KeyCode)287))
			{
				visible = !visible;
				if (visible)
				{
					windowRect = ClampRect(windowRect);
					EnsureCache();
				}
			}
			UpdateInputBlocker();
			if (!visible || building)
			{
				return;
			}
			double realtimeSinceStartupAsDouble = Time.realtimeSinceStartupAsDouble;
			if (realtimeSinceStartupAsDouble > nextContextCheck)
			{
				nextContextCheck = realtimeSinceStartupAsDouble + 0.5;
				RefreshActiveGalaxyContext();
			}
			if (currentContext == ExplorerContext.Preview && realtimeSinceStartupAsDouble > nextPreviewScanPoll)
			{
				nextPreviewScanPoll = realtimeSinceStartupAsDouble + 0.25;
				PollPreviewScans();
			}
			if (cacheBuilt && realtimeSinceStartupAsDouble > nextAutoRefresh)
			{
				nextAutoRefresh = realtimeSinceStartupAsDouble + 5.0;
				if (cacheDirty)
				{
					EnsureCache();
				}
			}
		}

		private void MarkPreviewGalaxyDirty()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			cacheDirty = true;
			cacheBuilt = false;
			cachedGalaxySource = null;
			previewPendingScans.Clear();
			scroll = Vector2.zero;
			status = "Galaxy preview updated";
		}

		private void OnGUI()
		{
			//IL_001f: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0090: 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_0039: Invalid comparison between Unknown and I4
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			if (!visible)
			{
				inputRectsCollecting.Clear();
				return;
			}
			EnsureStyles();
			BeginInputPass();
			RegisterInputRect(windowRect);
			Event current = Event.current;
			if (current != null && (int)current.type == 4 && (int)current.keyCode == 27)
			{
				visible = false;
				current.Use();
			}
			else
			{
				windowRect = GUI.Window(38127, windowRect, new WindowFunction(DrawWindow), GUIContent.none, GUI.skin.window);
				windowRect = ClampRect(windowRect);
				UpdateInputBlocker();
			}
		}

		private void DrawResizeGrips()
		{
			//IL_0014: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: 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)
			GUI.color = new Color(0.62f, 0.66f, 0.72f, 0.78f);
			GUI.DrawTexture(new Rect(4f, 4f, 13f, 3f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(4f, 4f, 3f, 13f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref windowRect)).width - 4f - 13f, 4f, 13f, 3f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref windowRect)).width - 4f - 3f, 4f, 3f, 13f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(4f, ((Rect)(ref windowRect)).height - 4f - 3f, 13f, 3f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(4f, ((Rect)(ref windowRect)).height - 4f - 13f, 3f, 13f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref windowRect)).width - 4f - 13f, ((Rect)(ref windowRect)).height - 4f - 3f, 13f, 3f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref windowRect)).width - 4f - 3f, ((Rect)(ref windowRect)).height - 4f - 13f, 3f, 13f), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = Color.white;
		}

		private void HandleWindowResize(Event e)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Invalid comparison between Unknown and I4
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Invalid comparison between Unknown and I4
			//IL_002c: 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_005a: 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_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Invalid comparison between Unknown and I4
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			if (e == null)
			{
				return;
			}
			Vector2 mousePosition = e.mousePosition;
			if (!resizing && (int)e.type == 0 && e.button == 0)
			{
				bool flag = mousePosition.x <= 12f;
				bool flag2 = mousePosition.x >= ((Rect)(ref windowRect)).width - 12f;
				bool flag3 = mousePosition.y <= 12f;
				bool flag4 = mousePosition.y >= ((Rect)(ref windowRect)).height - 12f;
				if (flag || flag2 || flag3 || flag4)
				{
					resizing = true;
					resizeLeft = flag;
					resizeRight = flag2;
					resizeTop = flag3;
					resizeBottom = flag4;
					resizeStartMouse = GUIUtility.GUIToScreenPoint(mousePosition);
					resizeStartRect = windowRect;
					GUIUtility.hotControl = 38127;
					e.Use();
					return;
				}
			}
			if (resizing && (int)e.type == 3 && e.button == 0)
			{
				Vector2 val = GUIUtility.GUIToScreenPoint(mousePosition) - resizeStartMouse;
				Rect r = resizeStartRect;
				if (resizeLeft)
				{
					float num = ((Rect)(ref resizeStartRect)).x + val.x;
					float num2 = ((Rect)(ref resizeStartRect)).xMax - 900f;
					num = (((Rect)(ref r)).x = Mathf.Min(num, num2));
					((Rect)(ref r)).width = ((Rect)(ref resizeStartRect)).xMax - num;
				}
				if (resizeRight)
				{
					((Rect)(ref r)).width = Mathf.Max(900f, ((Rect)(ref resizeStartRect)).width + val.x);
				}
				if (resizeTop)
				{
					float num4 = ((Rect)(ref resizeStartRect)).y + val.y;
					float num5 = ((Rect)(ref resizeStartRect)).yMax - 520f;
					num4 = (((Rect)(ref r)).y = Mathf.Min(num4, num5));
					((Rect)(ref r)).height = ((Rect)(ref resizeStartRect)).yMax - num4;
				}
				if (resizeBottom)
				{
					((Rect)(ref r)).height = Mathf.Max(520f, ((Rect)(ref resizeStartRect)).height + val.y);
				}
				windowRect = ClampResizeRect(r);
				e.Use();
			}
			else if (resizing && ((int)e.type == 1 || (int)e.rawType == 1))
			{
				resizing = false;
				resizeLeft = (resizeRight = (resizeTop = (resizeBottom = false)));
				GUIUtility.hotControl = 0;
				e.Use();
			}
		}

		private Rect ClampResizeRect(Rect r)
		{
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			((Rect)(ref r)).width = Mathf.Max(900f, ((Rect)(ref r)).width);
			((Rect)(ref r)).height = Mathf.Max(520f, ((Rect)(ref r)).height);
			if (((Rect)(ref r)).x < 0f)
			{
				((Rect)(ref r)).width = ((Rect)(ref r)).width + ((Rect)(ref r)).x;
				((Rect)(ref r)).x = 0f;
			}
			if (((Rect)(ref r)).y < 0f)
			{
				((Rect)(ref r)).height = ((Rect)(ref r)).height + ((Rect)(ref r)).y;
				((Rect)(ref r)).y = 0f;
			}
			if (((Rect)(ref r)).xMax > (float)Screen.width)
			{
				((Rect)(ref r)).x = Mathf.Max(0f, (float)Screen.width - ((Rect)(ref r)).width);
			}
			if (((Rect)(ref r)).yMax > (float)Screen.height)
			{
				((Rect)(ref r)).y = Mathf.Max(0f, (float)Screen.height - ((Rect)(ref r)).height);
			}
			((Rect)(ref r)).width = Mathf.Min(((Rect)(ref r)).width, (float)Screen.width);
			((Rect)(ref r)).height = Mathf.Min(((Rect)(ref r)).height, (float)Screen.height);
			return r;
		}

		private void EnsureStyles()
		{
			//IL_001f: 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_0069: 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_00b3: 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_012f: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			//IL_01d2: 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_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			//IL_01eb: Expected O, but got Unknown
			//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_0203: 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_0214: Expected O, but got Unknown
			//IL_0219: Expected O, but got Unknown
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			//IL_0247: Expected O, but got Unknown
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Expected O, but got Unknown
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Expected O, but got Unknown
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Expected O, but got Unknown
			//IL_02e9: Expected O, but got Unknown
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Expected O, but got Unknown
			//IL_031d: Expected O, but got Unknown
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Expected O, but got Unknown
			if (titleStyle == null)
			{
				panelTexture = MakeTexture(new Color(0.075f, 0.085f, 0.105f, 0.985f));
				panelAltTexture = MakeTexture(new Color(0.095f, 0.105f, 0.13f, 1f));
				borderTexture = MakeTexture(new Color(0.2f, 0.22f, 0.27f, 1f));
				accentTexture = MakeTexture(new Color(0.2f, 0.48f, 0.9f, 1f));
				selectedTexture = MakeTexture(new Color(0.14f, 0.23f, 0.38f, 1f));
				titleStyle = MakeStyle(GUI.skin.label, 23, "Bold", "MiddleLeft");
				windowTitleStyle = MakeStyle(GUI.skin.label, 19, "Bold", "MiddleLeft");
				headerStyle = MakeStyle(GUI.skin.button, 16, "Bold", "MiddleLeft", new RectOffset(10, 8, 0, 0));
				cellStyle = MakeStyle(GUI.skin.label, 16, null, "MiddleLeft", new RectOffset(10, 8, 0, 0));
				cellStyle.clipping = (TextClipping)1;
				cellStyle.wordWrap = false;
				rowAltStyle = new GUIStyle(cellStyle);
				smallStyle = MakeStyle(GUI.skin.label, 15, null, "MiddleLeft");
				sidebarSectionTitleStyle = MakeStyle(GUI.skin.label, 17, "Bold", "MiddleLeft");
				sectionStyle = new GUIStyle(GUI.skin.box)
				{
					padding = new RectOffset(8, 8, 6, 6)
				};
				toolbarButtonStyle = new GUIStyle(GUI.skin.button)
				{
					fontSize = 18,
					padding = new RectOffset(9, 9, 5, 5)
				};
				searchStyle = new GUIStyle(GUI.skin.textField)
				{
					fontSize = 17,
					padding = new RectOffset(12, 12, 7, 7)
				};
				navStyle = MakeStyle(GUI.skin.label, 16, null, "MiddleLeft", new RectOffset(12, 8, 0, 0));
				navSelectedStyle = new GUIStyle(navStyle);
				SetStyleEnum(navSelectedStyle, "fontStyle", "Bold");
				statusStyle = MakeStyle(GUI.skin.label, 15, null, "MiddleLeft", new RectOffset(12, 8, 0, 0));
				locateStyle = new GUIStyle(GUI.skin.button)
				{
					fontSize = 15,
					padding = new RectOffset(8, 8, 3, 3)
				};
				filterButtonStyle = new GUIStyle(GUI.skin.button)
				{
					fontSize = 14,
					alignment = (TextAnchor)3,
					padding = new RectOffset(8, 30, 3, 3)
				};
				filterButtonStyle.clipping = (TextClipping)1;
				filterDropdownItemStyle = MakeStyle(GUI.skin.label, 14, null, "MiddleLeft", new RectOffset(8, 8, 0, 0));
				filterDropdownArrowStyle = MakeStyle(GUI.skin.label, 14, "Bold", "MiddleCenter");
				closeButtonStyle = MakeStyle(GUI.skin.label, 22, null, "MiddleCenter");
				windowTitleStyle.wordWrap = false;
				windowTitleStyle.clipping = (TextClipping)1;
				searchIconTexture = MakeSearchIconTexture();
			}
		}

		private GUIStyle MakeStyle(GUIStyle source, int fontSize, string fontStyleName, string alignmentName, RectOffset padding = null)
		{
			//IL_000b: 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_0011: Expected O, but got Unknown
			GUIStyle val = ((source != null) ? new GUIStyle(source) : new GUIStyle());
			val.fontSize = fontSize;
			if (padding != null)
			{
				val.padding = padding;
			}
			if (!string.IsNullOrEmpty(fontStyleName))
			{
				SetStyleEnum(val, "fontStyle", fontStyleName);
			}
			if (!string.IsNullOrEmpty(alignmentName))
			{
				SetStyleEnum(val, "alignment", alignmentName);
			}
			return val;
		}

		private static void SetStyleEnum(GUIStyle style, string propertyName, string enumName)
		{
			if (style == null || string.IsNullOrEmpty(propertyName) || string.IsNullOrEmpty(enumName))
			{
				return;
			}
			try
			{
				PropertyInfo property = typeof(GUIStyle).GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public);
				if (!(property == null) && property.CanWrite && property.PropertyType.IsEnum)
				{
					object value = Enum.Parse(property.PropertyType, enumName, ignoreCase: true);
					property.SetValue(style, value, null);
				}
			}
			catch
			{
			}
		}

		private Texture2D MakeTexture(Color color)
		{
			//IL_0004: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false)
			{
				hideFlags = (HideFlags)61
			};
			val.SetPixel(0, 0, color);
			val.Apply();
			return val;
		}

		private Texture2D MakeSearchIconTexture()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_005d: 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_0199: 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_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 46, (TextureFormat)4, false);
			((Object)val).hideFlags = (HideFlags)61;
			Color[] array = (Color[])(object)new Color[2944];
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.05f, 0.68f, 1f, 1f);
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = val2;
			}
			for (int j = 0; j < 46; j++)
			{
				for (int k = 0; k < 64; k++)
				{
					float num = (float)k + 0.5f - 19f;
					float num2 = (float)j + 0.5f - 31f;
					float num3 = Mathf.Sqrt(num * num + num2 * num2);
					float num4 = Mathf.Clamp01((2.85f - Mathf.Abs(num3 - 10.5f)) / 1.1f);
					float num5 = 14f;
					float num6 = -14f;
					float num7 = num5 * num5 + num6 * num6;
					float num8 = (((float)k + 0.5f - 26.5f) * num5 + ((float)j + 0.5f - 23.5f) * num6) / num7;
					num8 = Mathf.Clamp01(num8);
					float num9 = 26.5f + num8 * num5;
					float num10 = 23.5f + num8 * num6;
					float num11 = Mathf.Sqrt(Mathf.Pow((float)k + 0.5f - num9, 2f) + Mathf.Pow((float)j + 0.5f - num10, 2f));
					float num12 = Mathf.Clamp01((2.8999999f - num11) / 1.1f);
					float num13 = Mathf.Max(num4, num12);
					if (num13 > 0f)
					{
						array[j * 64 + k] = new Color(val3.r, val3.g, val3.b, num13);
					}
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private void DrawWindow(int id)
		{
			//IL_0027: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			EnsureCache();
			GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, ((Rect)(ref windowRect)).height), (Texture)(object)panelTexture);
			DrawTopBar();
			DrawSidebar();
			DrawMainContent();
			DrawStatusBar();
			GUI.color = new Color(0.3f, 0.34f, 0.42f, 1f);
			GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, 1f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(0f, ((Rect)(ref windowRect)).height - 1f, ((Rect)(ref windowRect)).width, 1f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(0f, 0f, 1f, ((Rect)(ref windowRect)).height), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref windowRect)).width - 1f, 0f, 1f, ((Rect)(ref windowRect)).height), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = Color.white;
			DrawResizeGrips();
			HandleWindowResize(Event.current);
			GUI.DragWindow(new Rect(12f, 12f, Mathf.Max(1f, ((Rect)(ref windowRect)).width - 24f - 52f), 28f));
		}

		private void DrawTopBar()
		{
			//IL_001a: 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_005a: 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_006b: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, 40f), (Texture)(object)panelAltTexture);
			GUI.Label(new Rect(18f, 0f, ((Rect)(ref windowRect)).width - 36f, 40f), "Star System Explorer", new GUIStyle(windowTitleStyle)
			{
				alignment = (TextAnchor)4
			});
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref windowRect)).width - 62f, 1f, 46f, 38f);
			Event current = Event.current;
			if (current != null && ((Rect)(ref val)).Contains(current.mousePosition))
			{
				GUI.color = new Color(0.91f, 0.16f, 0.18f, 1f);
				GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture);
				GUI.color = Color.white;
			}
			if (GUI.Button(val, GUIContent.none, GUIStyle.none))
			{
				visible = false;
			}
			GUI.Label(val, "X", closeButtonStyle);
			GUI.DrawTexture(new Rect(0f, 40f, ((Rect)(ref windowRect)).width, 50f), (Texture)(object)panelTexture);
			Rect val2 = new Rect(64f, 46f, Mathf.Max(150f, ((Rect)(ref windowRect)).width - 64f - 12f), 38f);
			if ((Object)(object)searchIconTexture != (Object)null)
			{
				GUI.DrawTexture(new Rect(12f, 43f, 44f, 44f), (Texture)(object)searchIconTexture, (ScaleMode)2, true);
			}
			GUI.SetNextControlName("PlanetExplorerSearch");
			string a = GUI.TextField(val2, search ?? string.Empty, searchStyle);
			if (!string.Equals(a, search, StringComparison.Ordinal))
			{
				search = a;
				sortingDirty = true;
				scroll.y = 0f;
			}
			GUI.color = new Color(0.2f, 0.22f, 0.27f, 1f);
			GUI.DrawTexture(new Rect(0f, 39f, ((Rect)(ref windowRect)).width, 1f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(0f, 89f, ((Rect)(ref windowRect)).width, 1f), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = Color.white;
		}

		private void DrawSidebar()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(new Rect(0f, 90f, 220f, ((Rect)(ref windowRect)).height - 120f), (Texture)(object)panelAltTexture);
			DrawSidebarSectionTitle("EXPLORE", 104f);
			DrawNavItem(0, "All Star Systems", 134f);
			DrawNavItem(1, "Stars", 176f);
			DrawNavItem(2, "Planets", 218f);
			DrawSidebarSectionTitle("FILTERS", 292f);
			string a = filterPlanetType;
			string a2 = filterStarSystem;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(14f, 356f, 192f, 30f);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(14f, 444f, 192f, 30f);
			HandleSidebarDropdownOutsideClick(val, val2);
			Event current = Event.current;
			bool flag = false;
			if (openSidebarDropdown >= 0 && current != null)
			{
				Rect sidebarDropdownAnchor = GetSidebarDropdownAnchor(openSidebarDropdown, val, val2);
				string[] sidebarDropdownOptions = GetSidebarDropdownOptions(openSidebarDropdown);
				Rect sidebarDropdownPopupRect = GetSidebarDropdownPopupRect(sidebarDropdownAnchor, (sidebarDropdownOptions != null) ? sidebarDropdownOptions.Length : 0);
				flag = ((Rect)(ref sidebarDropdownPopupRect)).Contains(current.mousePosition);
			}
			bool enabled = GUI.enabled;
			if (flag)
			{
				GUI.enabled = false;
			}
			string text = ((navMode == 1) ? "Star type" : "Planet type");
			GUI.Label(new Rect(16f, 326f, 190f, 20f), text, smallStyle);
			filterPlanetType = DrawDropdown(val, filterPlanetType, GetPlanetTypeOptions(), 0);
			GUI.Label(new Rect(16f, 414f, 190f, 20f), "Star system", smallStyle);
			filterStarSystem = DrawDropdown(val2, filterStarSystem, GetStarSystemOptions(), 1);
			if (GUI.Button(new Rect(14f, 502f, 192f, 30f), "Reset filters", filterButtonStyle))
			{
				filterPlanetType = "All";
				filterStarSystem = "All";
				openSidebarDropdown = -1;
			}
			GUI.enabled = enabled;
			DrawSidebarDropdownPopup(val, val2);
			if (!string.Equals(a, filterPlanetType, StringComparison.Ordinal) || !string.Equals(a2, filterStarSystem, StringComparison.Ordinal))
			{
				sortingDirty = true;
				scroll.y = 0f;
				RebuildVisibleRows();
			}
		}

		private void DrawSidebarSectionTitle(string text, float y)
		{
			//IL_0010: 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_0032: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			GUI.Label(new Rect(16f, y, 190f, 28f), text, sidebarSectionTitleStyle);
			float num = Mathf.Ceil(sidebarSectionTitleStyle.CalcSize(new GUIContent(text)).x);
			GUI.color = new Color(0.72f, 0.75f, 0.8f, 0.95f);
			GUI.DrawTexture(new Rect(16f, y + 25f, Mathf.Max(24f, num), 1.5f), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = Color.white;
		}

		private void DrawNavItem(int mode, string text, float y)
		{
			//IL_002c: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(8f, y, 204f, 36f);
			if (navMode == mode)
			{
				GUI.DrawTexture(val, (Texture)(object)selectedTexture);
			}
			if (GUI.Button(val, text, (navMode == mode) ? navSelectedStyle : navStyle))
			{
				if (manualColumnWidths != null && manualColumnWidths.Length == 9 && navMode == 2 != (mode == 2))
				{
					float num = manualColumnWidths[0];
					manualColumnWidths[0] = manualColumnWidths[1];
					manualColumnWidths[1] = num;
				}
				navMode = mode;
				cachedColumnWidths = null;
				cachedColumnRowCount = -1;
				cachedColumnAreaWidth = -1;
				tableLayoutDirty = true;
				sortingDirty = true;
				scroll = Vector2.zero;
			}
		}

		private void DrawMainContent()
		{
			//IL_0037: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			float num = 220f;
			float num2 = 90f;
			float num3 = ((Rect)(ref windowRect)).height - 34f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(num, num2, ((Rect)(ref windowRect)).width - num, num3 - num2);
			GUI.DrawTexture(val, (Texture)(object)panelTexture);
			GUI.Label(new Rect(num + 18f, 102f, 500f, 34f), GetMainTitle(), titleStyle);
			GUI.Label(new Rect(num + 18f, 138f, 620f, 24f), GetMainSubtitle(), smallStyle);
			DrawTable(new Rect(num + 14f, 168f, ((Rect)(ref val)).width - 28f, ((Rect)(ref val)).height - 180f));
		}

		private string GetMainTitle()
		{
			if (navMode == 1)
			{
				return "Stars";
			}
			if (navMode == 2)
			{
				return "Planets";
			}
			return "All Star Systems";
		}

		private string GetMainSubtitle()
		{
			return visibleRows.Count + " items" + (string.IsNullOrEmpty(search) ? "" : " matching search");
		}

		private void DrawStatusBar()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(0f, ((Rect)(ref windowRect)).height - 34f, ((Rect)(ref windowRect)).width, 34f);
			GUI.DrawTexture(val, (Texture)(object)panelAltTexture);
			string text = lastRowCount + " cached rows  |  " + cachedStarSystemCount + " star systems";
			string text2 = ((currentContext == ExplorerContext.Preview) ? previewContextText : string.Empty);
			if (!string.IsNullOrEmpty(status))
			{
				text2 = (string.IsNullOrEmpty(text2) ? status : (text2 + "  |  " + status));
			}
			GUI.Label(new Rect(12f, ((Rect)(ref val)).y + 4f, 86f, 26f), "STATUS", statusStyle);
			GUI.Label(new Rect(98f, ((Rect)(ref val)).y + 4f, 510f, 26f), text, statusStyle);
			if (!string.IsNullOrEmpty(text2))
			{
				GUI.Label(new Rect(620f, ((Rect)(ref val)).y + 4f, Mathf.Max(0f, ((Rect)(ref windowRect)).width - 632f), 26f), text2, statusStyle);
			}
		}

		private void DrawTable(Rect area)
		{
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: 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)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			if (sortingDirty)
			{
				RebuildVisibleRows();
			}
			float[] columnWidths = GetColumnWidths(((Rect)(ref area)).width - 18f);
			bool flag = navMode == 2;
			string[] array = ((!flag) ? new string[9] { "Star system", "Planet", "Type", "Ocean", "Solar", "Wind", "Distance", "Resources", "" } : new string[9] { "Planet", "Star system", "Type", "Ocean", "Solar", "Wind", "Distance", "Resources", "" });
			string[] array2 = ((!flag) ? new string[9] { "StarSystem", "Planet", "Type", "Ocean", "Solar", "Wind", "Distance", "Resources", "" } : new string[9] { "Planet", "StarSystem", "Type", "Ocean", "Solar", "Wind", "Distance", "Resources", "" });
			float num = 38f;
			float num2 = Mathf.Max(1f, ((Rect)(ref area)).width - 18f);
			float num3 = Mathf.Max(num2, GetTotalColumnWidth(columnWidths));
			GUI.DrawTexture(new Rect(((Rect)(ref area)).x, ((Rect)(ref area)).y, ((Rect)(ref area)).width, num), (Texture)(object)panelAltTexture);
			GUI.BeginGroup(new Rect(((Rect)(ref area)).x, ((Rect)(ref area)).y, num2, num));
			Rect area2 = default(Rect);
			((Rect)(ref area2))..ctor(0f - scroll.x, 0f, num3, num);
			HandleColumnResizing(area2, num, columnWidths);
			float num4 = 0f - scroll.x;
			for (int i = 0; i < array.Length; i++)
			{
				if (i == 8)
				{
					GUI.Label(new Rect(num4, 0f, columnWidths[i], num), "", headerStyle);
					num4 += columnWidths[i];
				}
				else
				{
					DrawModernHeader(new Rect(num4, 0f, columnWidths[i], num), array[i], array2[i]);
					num4 += columnWidths[i];
				}
			}
			DrawColumnResizeHandleHints(area2, num, columnWidths);
			GUI.EndGroup();
			num3 = Mathf.Max(num2, GetTotalColumnWidth(columnWidths));
			EnsureTableLayout(columnWidths[7]);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref area)).x, ((Rect)(ref area)).y + num, ((Rect)(ref area)).width, ((Rect)(ref area)).height - num);
			scroll = GUI.BeginScrollView(val, scroll, new Rect(0f, 0f, num3, cachedTableContentHeight));
			int num5 = 48;
			int num6 = 0;
			float visibleTop = Mathf.Max(0f, scroll.y - 74f);
			float num7 = scroll.y + ((Rect)(ref val)).height + 74f;
			for (int j = FindFirstVisibleTableLayoutItem(visibleTop); j < tableLayout.Count; j++)
			{
				TableLayoutItem tableLayoutItem = tableLayout[j];
				if (tableLayoutItem.Y > num7)
				{
					break;
				}
				if (tableLayoutItem.IsGroupHeader)
				{
					bool collapsed = tableLayoutItem.Collapsed;
					float y = tableLayoutItem.Y;
					DrawStarGroupHeader(tableLayoutItem.StarName, ref y, num3, tableLayoutItem.Collapsed, tableLayoutItem.GroupCount);
					if (collapsedStarSystems.Contains(tableLayoutItem.StarName) != collapsed)
					{
						tableLayoutDirty = true;
						break;
					}
				}
				else
				{
					if (num6 >= num5)
					{
						break;
					}
					float y2 = tableLayoutItem.Y;
					DrawModernRowAtY(tableLayoutItem.Row, tableLayoutItem.ResourceLines, ref y2, tableLayoutItem.Height, tableLayoutItem.RowStripeIndex, columnWidths, num3);
					num6++;
				}
			}
			GUI.EndScrollView();
		}

		private void EnsureTableLayout(float resourceColumnWidth)
		{
			if (!tableLayoutDirty && Mathf.Abs(cachedLayoutResourceWidth - resourceColumnWidth) <= 0.5f)
			{
				return;
			}
			tableLayout.Clear();
			float num = 0f;
			int num2 = 0;
			if (navMode == 0)
			{
				string text = null;
				bool flag = false;
				for (int i = 0; i < visibleRows.Count; i++)
				{
					Row row = visibleRows[i];
					if (!string.Equals(text, row.StarSystem, StringComparison.OrdinalIgnoreCase))
					{
						text = row.StarSystem;
						flag = collapsedStarSystems.Contains(text);
						visibleStarGroupCounts.TryGetValue(text ?? string.Empty, out var value);
						tableLayout.Add(TableLayoutItem.ForGroup(num, 30f, text, flag, value));
						num += 30f;
					}
					if (!flag)
					{
						string[] resourceLines;
						float rowHeight = GetRowHeight(row, resourceColumnWidth, out resourceLines);
						tableLayout.Add(TableLayoutItem.ForRow(num, rowHeight, row, num2++, resourceLines));
						num += rowHeight;
					}
				}
			}
			else
			{
				for (int j = 0; j < visibleRows.Count; j++)
				{
					string[] resourceLines2;
					float rowHeight2 = GetRowHeight(visibleRows[j], resourceColumnWidth, out resourceLines2);
					tableLayout.Add(TableLayoutItem.ForRow(num, rowHeight2, visibleRows[j], num2++, resourceLines2));
					num += rowHeight2;
				}
			}
			cachedTableContentHeight = Mathf.Max(num + 4f, 1f);
			cachedLayoutResourceWidth = resourceColumnWidth;
			tableLayoutDirty = false;
		}

		private float GetRowHeight(Row row, float resourceColumnWidth, out string[] resourceLines)
		{
			resourceLines = WrapResourceLines((row == null) ? string.Empty : row.Resources, Mathf.Max(40f, resourceColumnWidth - 18f));
			int num = ((resourceLines == null || resourceLines.Length == 0) ? 1 : resourceLines.Length);
			return Mathf.Max(37f, 8f + (float)num * 22f);
		}

		private int FindFirstVisibleTableLayoutItem(float visibleTop)
		{
			int num = 0;
			int num2 = tableLayout.Count;
			while (num < num2)
			{
				int num3 = num + (num2 - num >> 1);
				TableLayoutItem tableLayoutItem = tableLayout[num3];
				if (tableLayoutItem.Y + tableLayoutItem.Height < visibleTop)
				{
					num = num3 + 1;
				}
				else
				{
					num2 = num3;
				}
			}
			return num;
		}

		private float[] GetColumnWidths(float availableWidth)
		{
			int num = Mathf.RoundToInt(availableWidth);
			if (cachedColumnWidths != null && cachedColumnRowCount == visibleRows.Count && cachedColumnAreaWidth == num)
			{
				return cachedColumnWidths;
			}
			float num2 = ((currentContext == ExplorerContext.InGame) ? 178f : 88f);
			bool flag = navMode == 2;
			if (manualColumnWidths != null && manualColumnWidths.Length == 9)
			{
				float[] manualColumnMinimumWidths = GetManualColumnMinimumWidths(num2);
				float[] manualColumnMaximumWidths = GetManualColumnMaximumWidths(num2);
				if (flag)
				{
					SwapFirstTwo(manualColumnMinimumWidths);
					SwapFirstTwo(manualColumnMaximumWidths);
				}
				float[] array = (float[])manualColumnWidths.Clone();
				for (int i = 0; i < 8; i++)
				{
					array[i] = Mathf.Clamp(array[i], manualColumnMinimumWidths[i], manualColumnMaximumWidths[i]);
				}
				array[8] = num2;
				manualColumnWidths = (float[])array.Clone();
				cachedColumnWidths = array;
				cachedColumnRowCount = visibleRows.Count;
				cachedColumnAreaWidth = num;
				return cachedColumnWidths;
			}
			float[] columnMinimumWidths = GetColumnMinimumWidths(num2);
			float[] columnMaximumWidths = GetColumnMaximumWidths(num2);
			if (flag)
			{
				SwapFirstTwo(columnMinimumWidths);
				SwapFirstTwo(columnMaximumWidths);
			}
			string[] array2 = ((!flag) ? new string[9] { "Star system", "Planet", "Type", "Ocean", "Solar", "Wind", "Distance", "Resources", "" } : new string[9] { "Planet", "Star system", "Type", "Ocean", "Solar", "Wind", "Distance", "Resources", "" });
			float[] array3 = new float[9];
			for (int j = 0; j < array3.Length; j++)
			{
				array3[j] = Mathf.Clamp((j == 8) ? columnMinimumWidths[j] : GetMeasuredColumnWidth(j, array2[j]), columnMinimumWidths[j], columnMaximumWidths[j]);
			}
			float totalColumnWidth = GetTotalColumnWidth(array3);
			if (totalColumnWidth < availableWidth)
			{
				float num3 = availableWidth - totalColumnWidth;
				int[] array4 = new int[4] { 7, 0, 1, 6 };
				for (int k = 0; k < array4.Length; k++)
				{
					if (!(num3 > 0.5f))
					{
						break;
					}
					int num4 = array4[k];
					float num5 = columnMaximumWidths[num4] - array3[num4];
					if (!(num5 <= 0.5f))
					{
						float num6 = Mathf.Min(num5, num3);
						array3[num4] += num6;
						num3 -= num6;
					}
				}
				if (num3 > 0.5f)
				{
					float num7 = num3 / 7f;
					for (int l = 0; l < 8; l++)
					{
						array3[l] = Mathf.Min(columnMaximumWidths[l], array3[l] + num7);
					}
				}
			}
			else if (totalColumnWidth > availableWidth)
			{
				float num8 = totalColumnWidth - availableWidth;
				int[] array5 = new int[8] { 7, 1, 0, 6, 3, 2, 4, 5 };
				for (int m = 0; m < array5.Length; m++)
				{
					if (!(num8 > 0.5f))
					{
						break;
					}
					int num9 = array5[m];
					float num10 = array3[num9] - columnMinimumWidths[num9];
					if (!(num10 <= 0.5f))
					{
						float num11 = Mathf.Min(num10, num8);
						array3[num9] -= num11;
						num8 -= num11;
					}
				}
			}
			cachedColumnWidths = array3;
			cachedColumnRowCount = visibleRows.Count;
			cachedColumnAreaWidth = num;
			return array3;
		}

		private static void SwapFirstTwo(float[] values)
		{
			if (values != null && values.Length >= 2)
			{
				float num = values[0];
				values[0] = values[1];
				values[1] = num;
			}
		}

		private static float[] GetColumnMinimumWidths(float actionWidth)
		{
			float[] obj = new float[9] { 150f, 145f, 90f, 92f, 76f, 76f, 92f, 320f, 0f };
			obj[8] = actionWidth;
			return obj;
		}

		private static float[] GetColumnMaximumWidths(float actionWidth)
		{
			float[] obj = new float[9] { 260f, 270f, 155f, 150f, 105f, 105f, 125f, 680f, 0f };
			obj[8] = actionWidth;
			return obj;
		}

		private static float[] GetManualColumnMinimumWidths(float actionWidth)
		{
			float[] obj = new float[9] { 150f, 145f, 90f, 92f, 76f, 76f, 92f, 180f, 0f };
			obj[8] = actionWidth;
			return obj;
		}

		private static float[] GetManualColumnMaximumWidths(float actionWidth)
		{
			float[] obj = new float[9] { 420f, 440f, 260f, 260f, 190f, 190f, 260f, 1600f, 0f };
			obj[8] = actionWidth;
			return obj;
		}

		private static float GetTotalColumnWidth(float[] widths)
		{
			float num = 0f;
			if (widths != null)
			{
				for (int i = 0; i < widths.Length; i++)
				{
					num += widths[i];
				}
			}
			return num;
		}

		private void HandleColumnResizing(Rect area, float headerHeight, float[] widths)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Invalid comparison between Unknown and I4
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Invalid comparison between Unknown and I4
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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)
			Event current = Event.current;
			if (current == null || widths == null || widths.Length < 9)
			{
				return;
			}
			int controlID = GUIUtility.GetControlID(3812701, (FocusType)2);
			float num = ((Rect)(ref area)).x;
			if ((int)current.type == 0 && current.button == 0)
			{
				Rect val = default(Rect);
				for (int i = 0; i <= 7; i++)
				{
					num += widths[i];
					((Rect)(ref val))..ctor(num - 6f, ((Rect)(ref area)).y, 12f, headerHeight);
					if (((Rect)(ref val)).Contains(current.mousePosition))
					{
						if (manualColumnWidths == null || manualColumnWidths.Length != widths.Length)
						{
							manualColumnWidths = (float[])widths.Clone();
						}
						activeColumnDivider = i;
						columnResizeStartMouseX = current.mousePosition.x;
						columnResizeStartLeftWidth = widths[i];
						GUIUtility.hotControl = controlID;
						current.Use();
						return;
					}
				}
			}
			if (activeColumnDivider < 0 || GUIUtility.hotControl != controlID)
			{
				return;
			}
			if ((int)current.type == 3)
			{
				int num2 = activeColumnDivider;
				float actionWidth = ((currentContext == ExplorerContext.InGame) ? 178f : 88f);
				float[] manualColumnMinimumWidths = GetManualColumnMinimumWidths(actionWidth);
				float[] manualColumnMaximumWidths = GetManualColumnMaximumWidths(actionWidth);
				float num3 = current.mousePosition.x - columnResizeStartMouseX;
				float num4 = Mathf.Clamp(columnResizeStartLeftWidth + num3, manualColumnMinimumWidths[num2], manualColumnMaximumWidths[num2]);
				manualColumnWidths[num2] = num4;
				widths[num2] = num4;
				cachedColumnWidths = (float[])widths.Clone();
				cachedColumnRowCount = visibleRows.Count;
				cachedColumnAreaWidth = -1;
				if (num2 == 7)
				{
					cachedLayoutResourceWidth = -1f;
					tableLayoutDirty = true;
				}
				current.Use();
			}
			else if ((int)current.type == 1 && current.button == 0)
			{
				activeColumnDivider = -1;
				GUIUtility.hotControl = 0;
				current.Use();
			}
		}

		private void DrawColumnResizeHandleHints(Rect area, float headerHeight, float[] widths)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if (current != null && widths != null)
			{
				float num = ((Rect)(ref area)).x;
				Rect val = default(Rect);
				for (int i = 0; i <= 7; i++)
				{
					num += widths[i];
					((Rect)(ref val))..ctor(num - 6f, ((Rect)(ref area)).y, 12f, headerHeight);
					bool num2 = activeColumnDivider == i || ((Rect)(ref val)).Contains(current.mousePosition);
					Color color = GUI.color;
					GUI.color = (num2 ? new Color(0.86f, 0.92f, 1f, 1f) : new Color(0.43f, 0.49f, 0.58f, 0.95f));
					GUI.DrawTexture(new Rect(num - 1f, ((Rect)(ref area)).y + 4f, 2f, headerHeight - 8f), (Texture)(object)Texture2D.whiteTexture);
					float num3 = 18f;
					float num4 = ((Rect)(ref area)).y + (headerHeight - num3) * 0.5f;
					GUI.color = (num2 ? new Color(0.66f, 0.76f, 0.91f, 1f) : new Color(0.28f, 0.33f, 0.4f, 1f));
					GUI.DrawTexture(new Rect(num - 4f, num4, 8f, num3), (Texture)(object)Texture2D.whiteTexture);
					GUI.color = (Color)(num2 ? Color.white : new Color(0.7f, 0.76f, 0.84f, 0.95f));
					GUI.DrawTexture(new Rect(num - 1f, num4 + 3f, 2f, num3 - 6f), (Texture)(object)Texture2D.whiteTexture);
					GUI.color = color;
				}
			}
		}

		private float GetMeasuredColumnWidth(int column, string header)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			float num = ((headerStyle != null) ? headerStyle.CalcSize(new GUIContent(header)).x : 0f);
			if (cellStyle != null)
			{
				for (int i = 0; i < visibleRows.Count; i++)
				{
					int column2 = ((navMode != 2) ? column : (column switch
					{
						1 => 0, 
						0 => 1, 
						_ => column, 
					}));
					string columnValue = GetColumnValue(visibleRows[i], column2);
					float x = cellStyle.CalcSize(new GUIContent(columnValue ?? string.Empty)).x;
					if (x > num)
					{
						num = x;
					}
				}
			}
			return num + 18f;
		}

		private static string GetColumnValue(Row row, int column)
		{
			return column switch
			{
				0 => row.StarSystem, 
				1 => row.Planet, 
				2 => row.Type, 
				3 => row.Ocean, 
				4 => row.Solar, 
				5 => row.Wind, 
				6 => row.Distance, 
				7 => row.Resources, 
				_ => string.Empty, 
			};
		}

		private void DrawStarGroupHeader(string starName, ref float y, float totalWidth, bool collapsed, int count)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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)
			GUI.DrawTexture(new Rect(0f, y, totalWidth, 30f), (Texture)(object)selectedTexture);
			string text = (collapsed ? ">" : "v");
			starObjectsByName.TryGetValue(starName ?? string.Empty, out var value);
			float num = ((currentContext == ExplorerContext.None) ? 0f : ((currentContext == ExplorerContext.InGame) ? 168f : 82f));
			if (GUI.Button(new Rect(0f, y, Mathf.Max(1f, totalWidth - num), 30f), text + "  " + starName + "   (" + count + ")", navSelectedStyle))
			{
				if (collapsed)
				{
					collapsedStarSystems.Remove(starName);
				}
				else
				{
					collapsedStarSystems.Add(starName);
				}
			}
			if (currentContext == ExplorerContext.Preview && value != null)
			{
				DrawPreviewScanButton(new Rect(totalWidth - num + 3f, y + 3f, num - 6f, 24f), value, starName, isStar: true);
			}
			else if (currentContext == ExplorerContext.InGame && value != null)
			{
				float num2 = Mathf.Max(1f, (num - 6f - 4f) * 0.5f);
				float num3 = totalWidth - num + 3f;
				if (GUI.Button(new Rect(num3, y + 3f, num2, 24f), "Rescan", locateStyle))
				{
					RescanSystem(starName);
				}
				if (GUI.Button(new Rect(num3 + num2 + 4f, y + 3f, num2, 24f), "Locate", locateStyle))
				{
					LocateStar(starName, value);
				}
			}
			y += 30f;
		}

		private void DrawModernHeader(Rect r, string text, string key)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			string text2 = ((!string.Equals(sortKey, key, StringComparison.Ordinal)) ? string.Empty : (sortAscending ? "  ^" : "  v"));
			if (GUI.Button(r, text + text2, headerStyle))
			{
				if (string.Equals(sortKey, key, StringComparison.Ordinal))
				{
					sortAscending = !sortAscending;
				}
				else
				{
					sortKey = key;
					sortAscending = true;
				}
				scroll.y = 0f;
				sortingDirty = true;
			}
		}

		private void DrawModernRowAtY(Row row, string[] resourceLines, ref float y, float rowHeight, int index, float[] widths, float totalWidth)
		{
			//IL_0024: 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_00ad: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(1f, rowHeight - 4f);
			if ((index & 1) == 1)
			{
				GUI.DrawTexture(new Rect(0f, y, totalWidth, num), (Texture)(object)panelAltTexture);
			}
			float num2 = y;
			float num3 = 0f;
			if (navMode == 2)
			{
				DrawCell(new Rect(num3, num2, widths[0], num), row.Planet);
				num3 += widths[0];
				DrawCell(new Rect(num3, num2, widths[1], num), row.StarSystem);
				num3 += widths[1];
			}
			else
			{
				DrawCell(new Rect(num3, num2, widths[0], num), row.StarSystem);
				num3 += widths[0];
				DrawCell(new Rect(num3, num2, widths[1], num), row.Planet);
				num3 += widths[1];
			}
			DrawCell(new Rect(num3, num2, widths[2], num), row.Type);
			num3 += widths[2];
			DrawCell(new Rect(num3, num2, widths[3], num), row.Ocean);
			num3 += widths[3];
			DrawCell(new Rect(num3, num2, widths[4], num), row.Solar);
			num3 += widths[4];
			DrawCell(new Rect(num3, num2, widths[5], num), row.Wind);
			num3 += widths[5];
			DrawCell(new Rect(num3, num2, widths[6], num), row.Distance);
			num3 += widths[6];
			DrawResourceCell(new Rect(num3, num2, widths[7], num), resourceLines);
			num3 += widths[7];
			float num4 = num2 + Mathf.Max(3f, (num - 23f) * 0.5f);
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(num3 + 5f, num4, widths[8] - 10f, 23f);
			if (currentContext == ExplorerContext.Preview)
			{
				object obj = row.PlanetObject ?? row.StarObject;
				if (obj != null)
				{
					DrawPreviewScanButton(rect, obj, string.IsNullOrEmpty(row.Planet) ? row.StarSystem : row.Planet, row.PlanetObject == null);
				}
			}
			else if (currentContext == ExplorerContext.InGame)
			{
				float num5 = Mathf.Max(1f, (((Rect)(ref rect)).width - 4f) * 0.5f);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, num5, ((Rect)(ref rect)).height);
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(((Rect)(ref rect)).x + num5 + 4f, ((Rect)(ref rect)).y, num5, ((Rect)(ref rect)).height);
				if (row.PlanetObject != null)
				{
					if (GUI.Button(val, "Rescan", locateStyle))
					{
						RescanPlanet(row);
					}
					if (GUI.Button(val2, "Locate", locateStyle))
					{
						Locate(row);
					}
				}
				else if (row.StarObject != null)
				{
					if (GUI.Button(val, "Rescan", locateStyle))
					{
						RescanSystem(row.StarSystem);
					}
					if (GUI.Button(val2, "Locate", locateStyle))
					{
						LocateStar(row.StarSystem, row.StarObject);
					}
				}
			}
			y += rowHeight;
		}

		private void DrawCell(Rect r, string text)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			GUI.Label(r, text ?? "", cellStyle);
		}

		private void DrawResourceCell(Rect r, string[] lines)
		{
			//IL_0019: 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)
			string[] array = ((lines != null && lines.Length != 0) ? lines : new string[1] { string.Empty });
			GUI.BeginGroup(r);
			try
			{
				float num = Mathf.Max(0f, (((Rect)(ref r)).height - (float)array.Length * 22f) * 0.5f);
				for (int i = 0; i < array.Length; i++)
				{
					GUI.Label(new Rect(0f, num + (float)i * 22f, ((Rect)(ref r)).width, 22f), array[i] ?? string.Empty, cellStyle);
				}
			}
			finally
			{
				GUI.EndGroup();
			}
		}

		private string[] WrapResourceLines(string value, float maxTextWidth)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			string text = value ?? string.Empty;
			if (string.IsNullOrEmpty(text) || cellStyle == null)
			{
				return new string[1] { text };
			}
			string[] array = text.Split(new string[1] { "  |  " }, StringSplitOptions.None);
			if (array.Length <= 1)
			{
				return new string[1] { text };
			}
			List<string> list = new List<string>(Mathf.Max(1, array.Length / 2));
			string text2 = string.Empty;
			for (int i = 0; i < array.Length; i++)
			{
				string text3 = array[i] ?? string.Empty;
				string text4 = (string.IsNullOrEmpty(text2) ? text3 : (text2 + "  |  " + text3));
				if (!string.IsNullOrEmpty(text2) && cellStyle.CalcSize(new GUIContent(text4)).x > maxTextWidth)
				{
					list.Add(text2);
					text2 = text3;
				}
				else
				{
					text2 = text4;
				}
			}
			if (!string.IsNullOrEmpty(text2) || list.Count == 0)
			{
				list.Add(text2);
			}
			return list.ToArray();
		}

		private string DrawDropdown(Rect rect, string current, string[] options, int dropdownId)
		{
			//IL_0018: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (options == null || options.Length == 0)
			{
				return current;
			}
			if (Array.IndexOf(options, current) < 0)
			{
				current = options[0];
			}
			if (GUI.Button(rect, current, filterButtonStyle))
			{
				openSidebarDropdown = ((openSidebarDropdown == dropdownId) ? (-1) : dropdownId);
				sidebarDropdownScroll = Vector2.zero;
			}
			GUI.Label(new Rect(((Rect)(ref rect)).xMax - 27f, ((Rect)(ref rect)).y, 24f, ((Rect)(ref rect)).height), "v", filterDropdownArrowStyle);
			return current;
		}

		private void HandleSidebarDropdownOutsideClick(Rect typeRect, Rect starRect)
		{
			//IL_0014: 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_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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			if (openSidebarDropdown < 0)
			{
				return;
			}
			Event current = Event.current;
			if (current != null && (int)current.type == 0 && current.button == 0)
			{
				Rect sidebarDropdownAnchor = GetSidebarDropdownAnchor(openSidebarDropdown, typeRect, starRect);
				string[] sidebarDropdownOptions = GetSidebarDropdownOptions(openSidebarDropdown);
				Rect sidebarDropdownPopupRect = GetSidebarDropdownPopupRect(sidebarDropdownAnchor, (sidebarDropdownOptions != null) ? sidebarDropdownOptions.Length : 0);
				if (!((Rect)(ref sidebarDropdownAnchor)).Contains(current.mousePosition) && !((Rect)(ref sidebarDropdownPopupRect)).Contains(current.mousePosition))
				{
					openSidebarDropdown = -1;
				}
			}
		}

		private void DrawSidebarDropdownPopup(Rect typeRect, Rect starRect)
		{
			//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_0036: 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_003f: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: 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_0291: Unknown result type (might be due to invalid IL or missing references)
			if (openSidebarDropdown < 0)
			{
				return;
			}
			string[] sidebarDropdownOptions = GetSidebarDropdownOptions(openSidebarDropdown);
			if (sidebarDropdownOptions == null || sidebarDropdownOptions.Length == 0)
			{
				openSidebarDropdown = -1;
				return;
			}
			Rect sidebarDropdownAnchor = GetSidebarDropdownAnchor(openSidebarDropdown, typeRect, starRect);
			Rect sidebarDropdownPopupRect = GetSidebarDropdownPopupRect(sidebarDropdownAnchor, sidebarDropdownOptions.Length);
			GUI.DrawTexture(sidebarDropdownPopupRect, (Texture)(object)panelTexture);
			GUI.color = new Color(0.34f, 0.38f, 0.46f, 1f);
			GUI.DrawTexture(new Rect(((Rect)(ref sidebarDropdownPopupRect)).x, ((Rect)(ref sidebarDropdownPopupRect)).y, ((Rect)(ref sidebarDropdownPopupRect)).width, 1f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref sidebarDropdownPopupRect)).x, ((Rect)(ref sidebarDropdownPopupRect)).yMax - 1f, ((Rect)(ref sidebarDropdownPopupRect)).width, 1f), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref sidebarDropdownPopupRect)).x, ((Rect)(ref sidebarDropdownPopupRect)).y, 1f, ((Rect)(ref sidebarDropdownPopupRect)).height), (Texture)(object)Texture2D.whiteTexture);
			GUI.DrawTexture(new Rect(((Rect)(ref sidebarDropdownPopupRect)).xMax - 1f, ((Rect)(ref sidebarDropdownPopupRect)).y, 1f, ((Rect)(ref sidebarDropdownPopupRect)).height), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = Color.white;
			GUI.BeginGroup(sidebarDropdownPopupRect);
			float num = Mathf.Max(28f, (float)sidebarDropdownOptions.Length * 28f);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(2f, 2f, ((Rect)(ref sidebarDropdownPopupRect)).width - 4f, ((Rect)(ref sidebarDropdownPopupRect)).height - 4f);
			bool flag = num > ((Rect)(ref val)).height;
			float num2 = Mathf.Max(40f, ((Rect)(ref val)).width - (flag ? 18f : 2f));
			sidebarDropdownScroll = GUI.BeginScrollView(val, sidebarDropdownScroll, new Rect(0f, 0f, num2, num), false, flag);
			string sidebarDropdownCurrent = GetSidebarDropdownCurrent(openSidebarDropdown);
			Event current = Event.current;
			Rect val2 = default(Rect);
			for (int i = 0; i < sidebarDropdownOptions.Length; i++)
			{
				((Rect)(ref val2))..ctor(0f, (float)i * 28f, num2, 28f);
				bool num3 = string.Equals(sidebarDropdownOptions[i], sidebarDropdownCurrent, StringComparison.Ordinal);
				bool flag2 = current != null && ((Rect)(ref val2)).Contains(current.mousePosition);
				if (num3)
				{
					GUI.DrawTexture(val2, (Texture)(object)selectedTexture);
				}
				else if (flag2)
				{
					GUI.color = new Color(0.22f, 0.28f, 0.38f, 1f);
					GUI.DrawTexture(val2, (Texture)(object)Texture2D.whiteTexture);
					GUI.color = Color.white;
				}
				if (GUI.Button(val2, GUIContent.none, GUIStyle.none))
				{
					SetSidebarDropdownCurrent(openSidebarDropdown, sidebarDropdownOptions[i]);
					openSidebarDropdown = -1;
				}
				GUI.Label(val2, sidebarDropdownOptions[i], filterDropdownItemStyle);
			}
			GUI.EndScrollView();
			GUI.EndGroup();
		}

		private Rect GetSidebarDropdownAnchor(int dropdownId, Rect typeRect, Rect starRect)
		{
			//IL_0005: 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)
			if (dropdownId != 0)
			{
				return starRect;
			}
			return typeRect;
		}

		private string[] GetSidebarDropdownOptions(int dropdownId)
		{
			if (dropdownId != 0)
			{
				return GetStarSystemOptions();
			}
			return GetPlanetTypeOptions();
		}

		private string GetSidebarDropdownCurrent(int dropdownId)
		{
			if (dropdownId != 0)
			{
				return filterStarSystem;
			}
			return filterPlanetType;
		}

		private void SetSidebarDropdownCurrent(int dropdownId, string value)
		{
			if (dropdownId == 0)
			{
				filterPlanetType = value;
			}
			else
			{
				filterStarSystem = value;
			}
		}

		private Rect GetSidebarDropdownPopupRect(Rect anchor, int optionCount)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(28f, (float)optionCount * 28f);
			float num2 = Mathf.Min(228f, num + 4f);
			float num3 = Mathf.Max(92f, ((Rect)(ref windowRect)).height - 38f - num2);
			float num4 = ((Rect)(ref anchor)).yMax + 2f;
			float num5 = ((Rect)(ref anchor)).y - num2 - 2f;
			float num6 = ((num4 + num2 <= ((Rect)(ref windowRect)).height - 38f) ? num4 : ((!(num5 >= 92f)) ? num3 : num5));
			return new Rect(((Rect)(ref anchor)).x, num6, ((Rect)(ref anchor)).width, num2);
		}

		private string[] GetPlanetTypeOptions()
		{
			SortedSet<string> sortedSet = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);
			List<Row> list = ((navMode == 1) ? allStarRows : allRows);
			for (int i = 0; i < list.Count; i++)
			{
				string type = list[i].Type;
				if (!string.IsNullOrEmpty(type))
				{
					sortedSet.Add(type);
				}
			}
			List<string> list2 = new List<string>();
			list2.Add("All");
			list2.AddRange(sortedSet);
			return list2.ToArray();
		}

		private string[] GetStarSystemOptions()
		{
			SortedSet<string> sortedSet = new SortedSet<string>(StringComparer.OrdinalIgnoreCase);
			for (int i = 0; i < allRows.Count; i++)
			{
				string starSystem = allRows[i].StarSystem;
				if (!string.IsNullOrEmpty(starSystem))
				{
					sortedSet.Add(starSystem);
				}
			}
			List<string> list = new List<string>();
			list.Add("All");
			list.AddRange(sortedSet);
			return list.ToArray();
		}

		private void EnsureCache(bool force = false)
		{
			if (building)
			{
				return;
			}
			if (!TryGetActiveGalaxy(out var galaxy, out var context))
			{
				status = "Waiting for game or Galaxy Select data...";
				return;
			}
			bool flag = context != currentContext || galaxy != cachedGalaxySource;
			if (!force && cacheBuilt && !cacheDirty && !flag)
			{
				return;
			}
			building = true;
			try
			{
				currentContext = context;
				BuildCache(galaxy, context);
				cachedGalaxySource = galaxy;
				cacheBuilt = true;
				cacheDirty = false;
				sortingDirty = true;
				status = string.Empty;
				if (context == ExplorerContext.Preview)
				{
					UpdatePreviewContextText(galaxy);
				}
				else
				{
					previewContextText = string.Empty;
				}
			}
			catch (Exception ex)
			{
				status = "Error: " + ex.Message;
				((BaseUnityPlugin)this).Logger.LogError((object)("Star System Explorer cache build failed: " + ex));
			}
			finally
			{
				building = false;
			}
		}

		private void BuildCache(object galaxy, ExplorerContext context)
		{
			allRows.Clear();
			allStarRows.Clear();
			starObjectsByName.Clear();
			if (!(GetMember(galaxy, "stars") is IEnumerable enumerable))
			{
				throw new InvalidOperationException("Active galaxy stars were not available.");
			}
			int num = GetInt(galaxy, "birthStarId");
			object birthStar = null;
			foreach (object item2 in enumerable)
			{
				if (item2 != null && GetInt(item2, "id") == num)
				{
					birthStar = item2;
					break;
				}
			}
			foreach (object item3 in enumerable)
			{
				if (item3 == null)
				{
					continue;
				}
				string text = GetString(item3, "displayName", "name") ?? "Star";
				float distanceToBirth = CalculateStarDistance(item3, birthStar);
				Row item = BuildStarRow(item3, text, distanceToBirth);
				allStarRows.Add(item);
				starObjectsByName[text] = item3;
				if (!(GetMember(item3, "planets") is IEnumerable enumerable2))
				{
					allRows.Add(item);
					continue;
				}
				bool flag = false;
				foreach (object item4 in enumerable2)
				{
					if (item4 != null)
					{
						flag = true;
						allRows.Add(BuildPlanetRow(item3, text, item4, context, distanceToBirth));
					}
				}
				if (!flag)
				{
					allRows.Add(item);
				}
			}
			lastRowCount = allRows.Count;
			cachedStarSystemCount = allStarRows.Count;
		}

		private Row BuildStarRow(object star, string starName, float distanceToBirth)
		{
			Row row = new Row();
			row.StarSystem = starName;
			row.Planet = "";
			row.Type = EnumOrString(star, "type", "starType") ?? "Star";
			row.Ocean = "";
			row.Solar = FormatPercent(GetFloat(star, "luminosity", "solarEnergyLossRate"));
			row.Wind = "";
			row.Distance = FormatDistance(distanceToBirth);
			row.Resources = "Star system";
			row.StarObject = star;
			row.HasResources = false;
			row.ResourcesKnown = true;
			return row;
		}

		private Row BuildPlanetRow(object star, string starName, object planet, ExplorerContext context, float distanceToBirth)
		{
			string planet2 = GetString(planet, "displayName", "name") ?? "Planet";
			bool flag = context != ExplorerContext.Preview || GetBool(planet, "scanned");
			string text = (flag ? BuildResourceSummary(planet) : "Not scanned");
			Row row = new Row();
			row.StarSystem = starName;
			row.Planet = planet2;
			row.Type = EnumOrString(planet, "type", "planetType") ?? "Planet";
			row.Ocean = GetOceanName(planet);
			row.Solar = FormatPercent(GetFloat(planet, "luminosity", "solarEnergyLossRate", "sunlight"));
			row.Wind = FormatPercent(GetFloat(planet, "windStrength", "wind", "windPower"));
			row.Distance = FormatDistance(distanceToBirth);
			row.Resources = text;
			row.StarObject = star;
			row.PlanetObject = planet;
			row.HasResources = flag && !string.Equals(text, "None", StringComparison.OrdinalIgnoreCase);
			row.ResourcesKnown = flag;
			Row row2 = row;
			if (string.IsNullOrEmpty(row2.Solar) || row2.Solar == "-")
			{
				row2.Solar = FormatPercent(GetFloat(star, "luminosity"));
			}
			return row2;
		}

		private static float CalculateStarDistance(object star, object birthStar)
		{
			if (star == null || birthStar == null)
			{
				return 0f;
			}
			try
			{
				object memberStatic = GetMemberStatic(star, "position");
				object memberStatic2 = GetMemberStatic(birthStar, "position");
				if (memberStatic != null && memberStatic2 != null)
				{
					double num = GetDouble(memberStatic, "x") - GetDouble(memberStatic2, "x");
					double num2 = GetDouble(memberStatic, "y") - GetDouble(memberStatic2, "y");
					double num3 = GetDouble(memberStatic, "z") - GetDouble(memberStatic2, "z");
					return (float)Math.Sqrt(num * num + num2 * num2 + num3 * num3);
				}
				memberStatic = GetMemberStatic(star, "uPosition");
				memberStatic2 = GetMemberStatic(birthStar, "uPosition");
				if (memberStatic != null && memberStatic2 != null)
				{
					double num4 = GetDouble(memberStatic, "x") - GetDouble(memberStatic2, "x");
					double num5 = GetDouble(memberStatic, "y") - GetDouble(memberStatic2, "y");
					double num6 = GetDouble(memberStatic, "z") - GetDouble(memberStatic2, "z");
					return (float)(Math.Sqrt(num4 * num4 + num5 * num5 + num6 * num6) / 2400000.0);
				}
			}
			catch
			{
			}
			return 0f;
		}

		private string GetOceanName(object planet)
		{
			string text = EnumOrString(planet, "oceanType", "Ocean");
			if (!string.IsNullOrEmpty(text))
			{
				return text;
			}
			int num = GetInt(planet, "waterItemId");
			if (num <= 0)
			{
				return "None";
			}
			return ResolveItemName(num);
		}

		private string ResolveItemName(int itemId)
		{
			if (itemId <= 0)
			{
				return "None";
			}
			if (itemNameCache.TryGetValue(itemId, out var value))
			{
				return value;
			}
			string text = GetKnownEnglishItemName(itemId);
			if (string.IsNullOrEmpty(text))
			{
				try
				{
					Type type = FindType("LDB");
					object staticMember = GetStaticMember(type, "items");
					if (staticMember != null)
					{
						MethodInfo methodInfo = FindMethod(staticMember.GetType(), "Select", 1);
						text = GetString((methodInfo == null) ? null : methodInfo.Invoke(staticMember, new object[1] { itemId }), "Name", "name", "displayName");
					}
				}
				catch
				{
				}
			}
			text = NormalizeEnglishItemName(itemId, text);
			if (string.IsNullOrEmpty(text))
			{
				text = "Item " + itemId.ToString(CultureInfo.InvariantCulture);
			}
			itemNameCache[itemId] = text;
			return text;
		}

		private static string GetKnownEnglishItemName(int itemId)
		{
			return itemId switch
			{
				1000 => "Water", 
				1011 => "Fire Ice", 
				1116 => "Sulfuric Acid", 
				1120 => "Hydrogen", 
				1121 => "Deuterium", 
				_ => null, 
			};
		}

		private static string NormalizeEnglishItemName(int itemId, string name)
		{
			string knownEnglishItemName = GetKnownEnglishItemName(itemId);
			if (!string.IsNullOrEmpty(knownEnglishItemName))
			{
				return knownEnglishItemName;
			}
			if (string.IsNullOrEmpty(name))
			{
				return name;
			}
			switch (name.Trim())
			{
			case "可燃冰":
				return "Fire Ice";
			case "氢":
			case "氢气":
				return "Hydrogen";
			case "重氢":
				return "Deuterium";
			case "水":
				return "Water";
			case "硫酸":
				return "Sulfuric Acid";
			default:
				return name;
			}
		}

		private string BuildResourceSummary(object planet)
		{
			Dictionary<int, double> dictionary = new Dictionary<int, double>();
			object member = GetMember(planet, "veinAmounts");
			object member2 = GetMember(planet, "runtimeVeinGroups", "veinGroups");
			AccumulateVeinArray(member, dictionary, preferCount: false);
			AccumulateVeinGroups(member2, dictionary);
			List<string> list = new List<string>(18);
			for (int i = 0; i < ResourceVeinTypes.Length; i++)
			{
				int key = ResourceVeinTypes[i];
				if (dictionary.TryGetValue(key, out var value) && !(value <= 0.0))
				{
					string text = ResourceNames[i];
					list.Add(showVeinAmount ? (text + ": " + FormatLarge(value)) : text);
				}
			}
			string gasSummary = GetGasSummary(planet);
			if (!string.IsNullOrEmpty(gasSummary))
			{
				list.Add(gasSummary);
			}
			if (list.Count != 0)
			{
				return string.Join("  |  ", list.ToArray());
			}
			return "None";
		}

		private void AccumulateVeinArray(object value, Dictionary<int, double> counts, bool preferCount)
		{
			if (!(value is Array array))
			{
				return;
			}
			for (int i = 0; i < array.Length; i++)
			{
				object value2 = array.GetValue(i);
				if (value2 == null)
				{
					continue;
				}
				int num = GetInt(value2, "type", "veinType", "id");
				double num2 = GetDouble(value2, "amount", "count", "miningCount", "totalAmount");
				if (num2 <= 0.0 && IsNumeric(value2))
				{
					try
					{
						num2 = Convert.ToDouble(value2, CultureInfo.InvariantCulture);
					}
					catch
					{
					}
				}
				if (num <= 0 && i < 32)
				{
					num = i;
				}
				if (!(num2 <= 0.0))
				{
					AddCount(counts, num, num2);
				}
			}
		}

		private void AccumulateVeinGroups(object value, Dictionary<int, double> counts)
		{
			if (!(value is IEnumerable enumerable))
			{
				return;
			}
			foreach (object item in enumerable)
			{
				if (item != null)
				{
					int num = GetInt(item, "type", "veinType", "id");
					double num2 = GetDouble(item, "amount", "count", "miningCount", "totalAmount");
					if (num > 0 && num2 > 0.0)
					{
						AddCount(counts, num, num2);
					}
				}
			}
		}

		private string GetGasSummary(object planet)
		{
			object member = GetMember(planet, "GasItems", "gasItems");
			object member2 = GetMember(planet, "GasSpeeds", "gasSpeeds");
			List<string> list = new List<string>(4);
			Array array = member as Array;
			Array array2 = member2 as Array;
			if (array != null && array2 != null)
			{
				int num = Math.Min(array.Length, array2.Length);
				for (int i = 0; i < num; i++)
				{
					int num2;
					try
					{
						num2 = Convert.ToInt32(array.GetValue(i), CultureInfo.InvariantCulture);
					}
					catch
					{
						continue;
					}
					double num3;
					try
					{
						num3 = Convert.ToDouble(array2.GetValue(i), CultureInfo.InvariantCulture);
					}
					catch
					{
						continue;
					}
					if (num2 > 0 && !(num3 <= 0.0))
					{
						string text = ResolveItemName(num2);
						list.Add(showVeinAmount ? (text + ": " + FormatLarge(num3) + "/s") : text);
					}
				}
				if (list.Count != 0)
				{
					return string.Join("  |  ", list.ToArray());
				}
				return string.Empty;
			}
			if (!(member is IEnumerable enumerable))
			{
				return string.Empty;
			}
			foreach (object item in enumerable)
			{
				if (item != null)
				{
					string text2 = GetString(item, "Name", "name", "displayName");
					if (string.IsNullOrEmpty(text2))
					{
						text2 = EnumOrString(item, "type", "id");
					}
					text2 = NormalizeEnglishItemName(0, text2);
					double num4 = GetDouble(item, "speed", "gasSpeed", "value", "amount");
					if (!string.IsNullOrEmpty(text2) && num4 > 0.0)
					{
						list.Add(showVeinAmount ? (text2 + ": " + FormatLarge(num4) + "/s") : text2);
					}
				}
			}
			if (list.Count != 0)
			{
				return string.Join("  |  ", list.ToArray());
			}
			return string.Empty;
		}

		private void RebuildVisibleRows()
		{
			visibleRows.Clear();
			visibleStarGroupCounts.Clear();
			string text = (search ?? string.Empty).Trim();
			bool flag = text.Length > 0;
			StringComparison comparisonType = StringComparison.OrdinalIgnoreCase;
			foreach (Row item in (navMode == 1) ? allStarRows : allRows)
			{
				if ((navMode != 1 || item.PlanetObject == null) && (navMode != 2 || item.PlanetObject != null) && (string.Equals(filterPlanetType, "All", StringComparison.OrdinalIgnoreCase) || string.Equals(item.Type, filterPlanetType, StringComparison.OrdinalIgnoreCase)) && (string.Equals(filterStarSystem, "All", StringComparison.OrdinalIgnoreCase) || string.Equals(item.StarSystem, filterStarSystem, StringComparison.OrdinalIgnoreCase)) && (!flag || item.StarSystem.IndexOf(text, comparisonType) >= 0 || item.Planet.IndexOf(text, comparisonType) >= 0 || item.Type.IndexOf(text, comparisonType) >= 0 || item.Ocean.IndexOf(text, comparisonType) >= 0 || item.Resources.IndexOf(text, comparisonType) >= 0))
				{
					visibleRows.Add(item);
					if (visibleStarGroupCounts.TryGetValue(item.StarSystem ?? string.Empty, out var value))
					{
						visibleStarGroupCounts[item.StarSystem ?? string.Empty] = value + 1;
					}
					else
					{
						visibleStarGroupCounts[item.StarSystem ?? string.Empty] = 1;
					}
				}
			}
			visibleRows.Sort(CompareRows);
			cachedColumnWidths = null;
			cachedColumnRowCount = -1;
			cachedColumnAreaWidth = -1;
			tableLayoutDirty = true;
			sortingDirty = false;
		}

		private int CompareRows(Row a, Row b)
		{
			if (navMode == 0)
			{
				int num = ((!string.Equals(sortKey, "StarSystem", StringComparison.Ordinal)) ? 1 : (sortAscending ? 1 : (-1)));
				int num2 = string.Compare(a.StarSystem, b.StarSystem, StringComparison.OrdinalIgnoreCase);
				if (num2 != 0)
				{
					return num2 * num;
				}
				if (string.Equals(sortKey, "StarSystem", StringComparison.Ordinal))
				{
					return string.Compare(a.Planet, b.Planet, StringComparison.OrdinalIgnoreCase);
				}
			}
			int num3 = CompareRowsKey(a, b, sortKey, sortAscending);
			if (num3 != 0)
			{
				return num3;
			}
			int num4 = string.Compare(a.StarSystem, b.StarSystem, StringComparison.OrdinalIgnoreCase);
			if (num4 != 0)
			{
				return num4;
			}
			return string.Compare(a.Planet, b.Planet, StringComparison.OrdinalIgnoreCase);
		}

		private int CompareRowsKey(Row a, Row b, string key, bool ascending)
		{
			int num = key switch
			{
				"Planet" => string.Compare(a.Planet, b.Planet, StringComparison.OrdinalIgnoreCase), 
				"Type" => string.Compare(a.Type, b.Type, StringComparison.OrdinalIgnoreCase), 
				"Ocean" => string.Compare(a.Ocean, b.Ocean, StringComparison.OrdinalIgnoreCase), 
				"Solar" => CompareNumeric(a.Solar, b.Solar), 
				"Wind" => CompareNumeric(a.Wind, b.Wind), 
				"Distance" => CompareNumeric(a.Distance, b.Distance), 
				"Resources" => string.Compare(a.Resources, b.Resources, StringComparison.OrdinalIgnoreCase), 
				_ => string.Compare(a.StarSystem, b.StarSystem, StringComparison.OrdinalIgnoreCase), 
			};
			if (!ascending)
			{
				return -num;
			}
			return num;
		}

		p