Decompiled source of DSPPlanetExplorer v3.2.4

BepInEx/plugins/DSPPlanetExplorer/DSPPlanetExplorer.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("DSPPlanetExplorer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("戴森球计划行星数据探索器 - 查看全星区行星矿物、光能、风能等数据")]
[assembly: AssemblyFileVersion("3.2.4.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DSP Planet Explorer")]
[assembly: AssemblyTitle("DSPPlanetExplorer")]
[assembly: AssemblyVersion("3.2.4.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 DSPPlanetExplorer
{
	[BepInPlugin("dongm.dsp.planetexplorer", "DSP Planet Explorer", "3.2.4")]
	[BepInProcess("DSPGAME.exe")]
	public class PlanetExplorerPlugin : BaseUnityPlugin
	{
		public const string pluginGuid = "dongm.dsp.planetexplorer";

		public const string pluginName = "DSP Planet Explorer";

		public const string pluginVersion = "3.2.4";

		public static ConfigEntry<KeyCode> toggleKey;

		public static PlanetExplorerPlugin instance;

		private Harmony harmony;

		private PlanetExplorerUI ui;

		public static ManualLogSource Log => ((BaseUnityPlugin)instance).Logger;

		private void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			instance = this;
			toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)287, "打开/关闭行星探索器窗口的快捷键");
			harmony = new Harmony("dongm.dsp.planetexplorer");
			harmony.PatchAll(typeof(PlanetExplorerPlugin));
			((BaseUnityPlugin)this).Logger.LogInfo((object)("DSP Planet Explorer v3.2.4 加载完成,按 " + ((object)toggleKey.Value/*cast due to .constrained prefix*/).ToString() + " 打开窗口"));
		}

		private void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(toggleKey.Value))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[DEBUG] F6 pressed, ui=" + ((Object)(object)ui != (Object)null)));
				if ((Object)(object)ui == (Object)null)
				{
					ui = ((Component)this).gameObject.AddComponent<PlanetExplorerUI>();
					((BaseUnityPlugin)this).Logger.LogInfo((object)"[DEBUG] UI component created");
				}
				ui.Toggle();
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[DEBUG] Toggle called, visible=" + ui.IsVisible()));
			}
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameMain), "Begin")]
		public static void OnGameBegin()
		{
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.ui != (Object)null)
			{
				instance.ui.OnGameBegin();
			}
		}

		public static int GetStarNeedLevel(StarData star, StarData birthStar)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_002e: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			if (birthStar == null || star == birthStar)
			{
				return 2;
			}
			VectorLF3 val = star.uPosition - birthStar.uPosition;
			if (!(Math.Sqrt(val.x * val.x + val.y * val.y + val.z * val.z) < 14400000.0))
			{
				return 4;
			}
			return 3;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameHistoryData), "UnlockTechFunction")]
		public static void UnlockTechFunctionPostfix()
		{
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.ui != (Object)null)
			{
				instance.ui.MarkDataDirty();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlanetData), "NotifyScanEnded")]
		public static void NotifyScanEndedPostfix()
		{
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.ui != (Object)null)
			{
				instance.ui.MarkDataDirty();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameMain), "Pause")]
		public static bool PausePrefix()
		{
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.ui != (Object)null && instance.ui.IsVisible())
			{
				instance.ui.Hide();
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(VFInput), "UpdateGameStates")]
		public static void VFInputUpdateGameStatesPostfix()
		{
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.ui != (Object)null && instance.ui.IsMouseOverPanel())
			{
				VFInput.onGUI = true;
				VFInput.onGUIOperate = true;
			}
		}
	}
	public class PlanetInfo
	{
		public int planetId;

		public string starName;

		public string starType;

		public float starLuminosity;

		public string planetName;

		public string planetType;

		public float windStrength;

		public float luminosity;

		public float landPercent;

		public float realRadius;

		public bool isGas;

		public bool isSatellite;

		public string orbitAround;

		public string oceanType;

		public double distanceToBirth;

		public bool isObserved;

		public Dictionary<int, long> veinAmounts = new Dictionary<int, long>();

		public Dictionary<int, int> veinCounts = new Dictionary<int, int>();

		public Dictionary<int, float> gasSpeeds = new Dictionary<int, float>();

		public double oilRate;

		public string[] cachedVeinTexts;

		public string[] cachedGasTexts;

		public string cachedLuminosity;

		public string cachedWind;

		public string cachedDistance;
	}
	public class StarGroup
	{
		public string starName;

		public string starType;

		public float starLuminosity;

		public List<PlanetInfo> planets = new List<PlanetInfo>();

		public bool expanded = true;

		public bool isObserved;

		public long[] veinSummary;

		public float[] gasSummary;

		public string[] veinSummaryText;

		public string[] gasSummaryText;

		public long[] veinSummarySort;

		public double oilRateSummary;

		public double oilRateSummarySort;
	}
	public class SortCondition
	{
		public int columnIndex;

		public bool ascending;

		public string columnName;
	}
	public class TableRow
	{
		public bool isStar;

		public StarGroup starGroup;

		public PlanetInfo planet;

		public int starGroupIdx;
	}
	public class DataCollector
	{
		public static List<PlanetInfo> CollectAllPlanets()
		{
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Invalid comparison between Unknown and I4
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			List<PlanetInfo> list = new List<PlanetInfo>();
			if ((Object)(object)GameMain.universeSimulator == (Object)null || GameMain.universeSimulator.galaxyData == null)
			{
				return list;
			}
			int num = -1;
			StarData birthStar = null;
			try
			{
				if ((Object)(object)GameMain.instance != (Object)null && GameMain.history != null)
				{
					num = GameMain.history.universeObserveLevel;
				}
				if (GameMain.galaxy != null && GameMain.galaxy.birthStarId >= 0)
				{
					birthStar = GameMain.galaxy.StarById(GameMain.galaxy.birthStarId);
				}
			}
			catch
			{
			}
			StarData[] stars = GameMain.universeSimulator.galaxyData.stars;
			foreach (StarData val in stars)
			{
				bool flag = num >= 0 && num >= PlanetExplorerPlugin.GetStarNeedLevel(val, birthStar);
				if (flag)
				{
					PlanetData[] planets = val.planets;
					foreach (PlanetData val2 in planets)
					{
						PlanetInfo planetInfo = new PlanetInfo
						{
							planetId = val2.id,
							starName = val.displayName,
							starType = val.typeString,
							starLuminosity = val.dysonLumino,
							planetName = val2.displayName,
							planetType = val2.typeString,
							windStrength = val2.windStrength,
							luminosity = val2.luminosity,
							landPercent = val2.landPercent,
							realRadius = val2.realRadius,
							isGas = ((int)val2.type == 5),
							isSatellite = (val2.orbitAroundPlanet != null),
							orbitAround = ((val2.orbitAroundPlanet != null) ? val2.orbitAroundPlanet.displayName : ""),
							oceanType = GetOceanName(val2),
							isObserved = flag
						};
						CollectVeinData(val2, planetInfo);
						list.Add(planetInfo);
					}
				}
			}
			try
			{
				PlanetData val3 = GameMain.galaxy.PlanetById(GameMain.galaxy.birthPlanetId);
				if (val3 != null)
				{
					double num2 = 2400000.0;
					VectorLF3 uPosition = val3.uPosition;
					foreach (PlanetInfo item in list)
					{
						PlanetData val4 = GameMain.galaxy.PlanetById(item.planetId);
						if (val4 != null)
						{
							double num3 = val4.uPosition.x - uPosition.x;
							double num4 = val4.uPosition.y - uPosition.y;
							double num5 = val4.uPosition.z - uPosition.z;
							double num6 = Math.Sqrt(num3 * num3 + num4 * num4 + num5 * num5);
							item.distanceToBirth = num6 / num2;
						}
					}
				}
			}
			catch
			{
			}
			return list;
		}

		private static string GetOceanName(PlanetData planet)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)planet.type == 5)
			{
				return "气态";
			}
			if (planet.waterItemId == 0)
			{
				return "无";
			}
			if (planet.waterItemId == -1)
			{
				return "熔岩";
			}
			if (planet.waterItemId == -2)
			{
				return "冰原";
			}
			try
			{
				ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(planet.waterItemId);
				return (val != null) ? ((Proto)val).name : "未知";
			}
			catch
			{
				return "未知";
			}
		}

		private static void CollectVeinData(PlanetData planet, PlanetInfo info)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00d2: Invalid comparison between Unknown and I4
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			if ((int)planet.type == 5)
			{
				int[] array = new int[3] { 1120, 1121, 1011 };
				foreach (int num in array)
				{
					int num2 = Array.IndexOf(planet.gasItems, num);
					info.gasSpeeds[num] = ((num2 >= 0) ? planet.gasSpeeds[num2] : 0f);
				}
			}
			else
			{
				if (planet.runtimeVeinGroups == null)
				{
					return;
				}
				long[] array2 = new long[64];
				HashSet<int> hashSet = new HashSet<int>();
				planet.SummarizeVeinAmountsByFilter(ref array2, hashSet, 0);
				VeinProto[] dataArray = ((ProtoSet<VeinProto>)(object)LDB.veins).dataArray;
				for (int i = 0; i < dataArray.Length; i++)
				{
					int iD = ((Proto)dataArray[i]).ID;
					info.veinAmounts[iD] = array2[iD];
					int num3 = 0;
					VeinGroup[] runtimeVeinGroups = planet.runtimeVeinGroups;
					foreach (VeinGroup val in runtimeVeinGroups)
					{
						if ((int)val.type == iD)
						{
							num3 += val.count;
						}
					}
					info.veinCounts[iD] = num3;
				}
			}
		}
	}
	public static class PlanetNavigator
	{
		private static bool initialized = false;

		private static MethodInfo navigateMethod = null;

		private static FieldInfo navigateField = null;

		private static PropertyInfo navigateProperty = null;

		private static object navigateTarget = null;

		private static Type spaceGuideType = null;

		private static object spaceGuideInstance = null;

		private static MethodInfo setEntryMethod = null;

		private static object planetGuideTypeValue = null;

		private static int spaceGuideCount = 0;

		private static Type playerNavType = null;

		private static object playerNavInstance = null;

		private static MethodInfo playerNavNavigateMethod = null;

		private static Type vectorLF3Type = null;

		private static MethodInfo playerNavSetMethod = null;

		private static FieldInfo playerNavTargetField = null;

		private static PropertyInfo playerNavTargetProperty = null;

		private static readonly string[] SearchKeywords = new string[11]
		{
			"navigate", "indicator", "direction", "locate", "mark", "ping", "arrow", "pointer", "guide", "waypoint",
			"target"
		};

		private static readonly string[] ExcludeKeywords = new string[3] { "fasttravel", "fast_travel", "fastTravel" };

		private static object GetPlayerNavigation()
		{
			if (playerNavInstance != null && !playerNavInstance.Equals(null))
			{
				return playerNavInstance;
			}
			try
			{
				Player mainPlayer = GameMain.mainPlayer;
				if (mainPlayer == null)
				{
					return null;
				}
				FieldInfo[] fields = ((object)mainPlayer).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					if (fieldInfo.FieldType.Name == "PlayerNavigation")
					{
						playerNavInstance = fieldInfo.GetValue(mainPlayer);
						playerNavType = fieldInfo.FieldType;
						PlanetExplorerPlugin.Log.LogInfo((object)("Found PlayerNavigation via Player." + fieldInfo.Name));
						return playerNavInstance;
					}
					if (!(fieldInfo.FieldType.Name == "PlayerAction_Navigate"))
					{
						continue;
					}
					object value = fieldInfo.GetValue(mainPlayer);
					if (value != null)
					{
						FieldInfo field = fieldInfo.FieldType.GetField("navigation", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field != null)
						{
							playerNavInstance = field.GetValue(value);
							playerNavType = field.FieldType;
							PlanetExplorerPlugin.Log.LogInfo((object)("Found PlayerNavigation via Player." + fieldInfo.Name + ".navigation"));
							return playerNavInstance;
						}
					}
				}
			}
			catch (Exception ex)
			{
				PlanetExplorerPlugin.Log.LogWarning((object)("GetPlayerNavigation failed: " + ex.Message));
			}
			return null;
		}

		public static void Init()
		{
			if (initialized)
			{
				return;
			}
			initialized = true;
			try
			{
				List<(Type, object, string)> list = new List<(Type, object, string)>();
				Type type = typeof(GameMain).GetProperty("data")?.PropertyType;
				if (type != null && GameMain.data != null)
				{
					list.Add((type, GameMain.data, "GameMain.data"));
				}
				try
				{
					UIStarmap val = UIRoot.instance?.uiGame?.starmap;
					if ((Object)(object)val != (Object)null)
					{
						list.Add((((object)val).GetType(), val, "UIStarmap"));
					}
				}
				catch
				{
				}
				try
				{
					Player mainPlayer = GameMain.mainPlayer;
					if (mainPlayer != null)
					{
						list.Add((((object)mainPlayer).GetType(), mainPlayer, "Player"));
					}
				}
				catch
				{
				}
				ScanAllAssemblies(list);
				List<string> list2 = new List<string>();
				foreach (var (type2, obj3, text) in list)
				{
					foreach (MemberInfo item in (from m in type2.GetMembers(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
						where SearchKeywords.Any((string k) => m.Name.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0)
						where !ExcludeKeywords.Any((string k) => m.Name.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0)
						select m).ToList())
					{
						if (item is MethodInfo methodInfo && methodInfo.GetParameters().Length <= 2)
						{
							list2.Add(text + "." + methodInfo.Name + "(" + string.Join(",", from p in methodInfo.GetParameters()
								select p.ParameterType.Name) + ")");
							if (navigateMethod == null && methodInfo.GetParameters().Length == 1)
							{
								Type parameterType = methodInfo.GetParameters()[0].ParameterType;
								if (parameterType == typeof(int) || parameterType == typeof(PlanetData) || parameterType == typeof(StarData))
								{
									navigateMethod = methodInfo;
									navigateTarget = obj3;
								}
							}
						}
						else if (item is FieldInfo fieldInfo)
						{
							list2.Add(text + "." + fieldInfo.Name + " [Field:" + fieldInfo.FieldType.Name + "]");
							if (navigateField == null && (fieldInfo.FieldType == typeof(int) || fieldInfo.FieldType == typeof(PlanetData) || fieldInfo.FieldType == typeof(int?)))
							{
								navigateField = fieldInfo;
								navigateTarget = obj3;
							}
						}
						else if (item is PropertyInfo propertyInfo)
						{
							list2.Add(text + "." + propertyInfo.Name + " [Property:" + propertyInfo.PropertyType.Name + "]");
							if (navigateProperty == null && propertyInfo.CanWrite && (propertyInfo.PropertyType == typeof(int) || propertyInfo.PropertyType == typeof(PlanetData) || propertyInfo.PropertyType == typeof(int?)))
							{
								navigateProperty = propertyInfo;
								navigateTarget = obj3;
							}
						}
					}
				}
				PlanetExplorerPlugin.Log.LogInfo((object)"=== Navigation-related members (excluding fastTravel) ===");
				foreach (string item2 in list2)
				{
					PlanetExplorerPlugin.Log.LogInfo((object)item2);
				}
				try
				{
					List<Type> source = (from a in AppDomain.CurrentDomain.GetAssemblies()
						where a.GetName().Name.Contains("Assembly-CSharp")
						select a).SelectMany(delegate(Assembly a)
					{
						try
						{
							return a.GetTypes();
						}
						catch
						{
							return new Type[0];
						}
					}).ToList();
					spaceGuideType = source.FirstOrDefault((Type t) => t.Name == "UISpaceGuide");
					if (spaceGuideType != null)
					{
						MethodInfo method = typeof(Object).GetMethod("FindObjectOfType", new Type[0]);
						if (method != null)
						{
							spaceGuideInstance = method.MakeGenericMethod(spaceGuideType).Invoke(null, null);
						}
						if (spaceGuideInstance != null)
						{
							PlanetExplorerPlugin.Log.LogInfo((object)$"Found UISpaceGuide instance: {spaceGuideInstance}");
							setEntryMethod = spaceGuideType.GetMethod("SetEntry", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							if (setEntryMethod != null)
							{
								PlanetExplorerPlugin.Log.LogInfo((object)$"Found SetEntry method: {setEntryMethod}");
							}
						}
						else
						{
							PlanetExplorerPlugin.Log.LogInfo((object)"UISpaceGuide instance not found (maybe not opened yet)");
						}
					}
					Type type3 = source.FirstOrDefault((Type t) => t.Name == "ESpaceGuideType" && t.IsEnum);
					if (type3 != null)
					{
						planetGuideTypeValue = Enum.Parse(type3, "Planet");
						PlanetExplorerPlugin.Log.LogInfo((object)$"ESpaceGuideType.Planet = {Convert.ToInt32(planetGuideTypeValue)}");
					}
				}
				catch (Exception ex)
				{
					PlanetExplorerPlugin.Log.LogWarning((object)("Find UISpaceGuide failed: " + ex.Message));
				}
				AnalyzeKeyType("PlayerAction_Navigate", list);
				AnalyzeKeyType("UISpaceGuide", list);
				AnalyzeKeyType("UISpaceGuideEntry", list);
				AnalyzeEnum("ESpaceGuideType");
				try
				{
					Type type4 = (from a in AppDomain.CurrentDomain.GetAssemblies()
						where a.GetName().Name.Contains("Assembly-CSharp")
						select a).SelectMany(delegate(Assembly a)
					{
						try
						{
							return a.GetTypes();
						}
						catch
						{
							return new Type[0];
						}
					}).ToList().FirstOrDefault((Type t) => t.Name == "PlayerAction_Navigate");
					if (type4 != null)
					{
						Object val2 = Object.FindObjectOfType(type4);
						if (val2 != (Object)null)
						{
							PlanetExplorerPlugin.Log.LogInfo((object)$"Found PlayerAction_Navigate via FindObjectOfType: {val2}");
							FieldInfo field = type4.GetField("navigation", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							if (field != null)
							{
								playerNavInstance = field.GetValue(val2);
								if (playerNavInstance != null)
								{
									playerNavType = playerNavInstance.GetType();
									PlanetExplorerPlugin.Log.LogInfo((object)("Found PlayerNavigation instance: " + playerNavType.Name));
									PlanetExplorerPlugin.Log.LogInfo((object)"=== ALL PlayerNavigation methods ===");
									foreach (MethodInfo item3 in from m in playerNavType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
										where !m.Name.StartsWith("get_") && !m.Name.StartsWith("set_")
										orderby m.Name
										select m)
									{
										PlanetExplorerPlugin.Log.LogInfo((object)("  " + item3.Name + "(" + string.Join(",", from p in item3.GetParameters()
											select p.ParameterType.Name + " " + p.Name) + ")"));
									}
									PlanetExplorerPlugin.Log.LogInfo((object)"=== ALL PlayerNavigation fields ===");
									FieldInfo[] fields = playerNavType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
									foreach (FieldInfo fieldInfo2 in fields)
									{
										PlanetExplorerPlugin.Log.LogInfo((object)("  " + fieldInfo2.Name + " [Field:" + fieldInfo2.FieldType.Name + "]"));
									}
									PlanetExplorerPlugin.Log.LogInfo((object)"=== ALL PlayerNavigation properties ===");
									PropertyInfo[] properties = playerNavType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
									foreach (PropertyInfo propertyInfo2 in properties)
									{
										PlanetExplorerPlugin.Log.LogInfo((object)$"  {propertyInfo2.Name} [Property:{propertyInfo2.PropertyType.Name}] CanWrite={propertyInfo2.CanWrite}");
									}
									playerNavSetMethod = playerNavType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => (m.Name.IndexOf("set", StringComparison.OrdinalIgnoreCase) >= 0 || m.Name.IndexOf("navigate", StringComparison.OrdinalIgnoreCase) >= 0 || m.Name.IndexOf("target", StringComparison.OrdinalIgnoreCase) >= 0 || m.Name.IndexOf("planet", StringComparison.OrdinalIgnoreCase) >= 0) && m.GetParameters().Length <= 2);
									playerNavTargetField = playerNavType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((FieldInfo fi) => (fi.Name.IndexOf("target", StringComparison.OrdinalIgnoreCase) >= 0 || fi.Name.IndexOf("planet", StringComparison.OrdinalIgnoreCase) >= 0 || fi.Name.IndexOf("navigate", StringComparison.OrdinalIgnoreCase) >= 0) && (fi.FieldType == typeof(int) || fi.FieldType == typeof(PlanetData) || fi.FieldType == typeof(int?)));
									playerNavTargetProperty = playerNavType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((PropertyInfo pi) => pi.CanWrite && (pi.Name.IndexOf("target", StringComparison.OrdinalIgnoreCase) >= 0 || pi.Name.IndexOf("planet", StringComparison.OrdinalIgnoreCase) >= 0 || pi.Name.IndexOf("navigate", StringComparison.OrdinalIgnoreCase) >= 0) && (pi.PropertyType == typeof(int) || pi.PropertyType == typeof(PlanetData) || pi.PropertyType == typeof(int?)));
									if (playerNavSetMethod != null)
									{
										PlanetExplorerPlugin.Log.LogInfo((object)("Selected PlayerNavigation method: " + playerNavSetMethod.Name));
									}
									if (playerNavTargetField != null)
									{
										PlanetExplorerPlugin.Log.LogInfo((object)("Selected PlayerNavigation field: " + playerNavTargetField.Name));
									}
									if (playerNavTargetProperty != null)
									{
										PlanetExplorerPlugin.Log.LogInfo((object)("Selected PlayerNavigation property: " + playerNavTargetProperty.Name));
									}
								}
							}
						}
					}
				}
				catch (Exception ex2)
				{
					PlanetExplorerPlugin.Log.LogWarning((object)("Find PlayerAction_Navigate via FindObjectOfType failed: " + ex2.Message));
				}
				try
				{
					Player mainPlayer2 = GameMain.mainPlayer;
					if (mainPlayer2 != null)
					{
						foreach (FieldInfo item4 in (from f in ((object)mainPlayer2).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
							where f.FieldType.Name == "PlayerAction_Navigate"
							select f).ToList())
						{
							object value = item4.GetValue(mainPlayer2);
							if (value == null)
							{
								continue;
							}
							PlanetExplorerPlugin.Log.LogInfo((object)("Found PlayerAction_Navigate instance via Player." + item4.Name));
							list.Add((item4.FieldType, value, "Player." + item4.Name));
							foreach (MemberInfo item5 in (from m in item4.FieldType.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
								where SearchKeywords.Any((string k) => m.Name.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0)
								where !ExcludeKeywords.Any((string k) => m.Name.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0)
								select m).ToList())
							{
								if (item5 is MethodInfo methodInfo2 && methodInfo2.GetParameters().Length <= 2)
								{
									PlanetExplorerPlugin.Log.LogInfo((object)("  PlayerAction_Navigate." + methodInfo2.Name + "(" + string.Join(",", from p in methodInfo2.GetParameters()
										select p.ParameterType.Name) + ")"));
									if (navigateMethod == null && methodInfo2.GetParameters().Length == 1)
									{
										Type parameterType2 = methodInfo2.GetParameters()[0].ParameterType;
										if (parameterType2 == typeof(int) || parameterType2 == typeof(PlanetData) || parameterType2 == typeof(StarData))
										{
											navigateMethod = methodInfo2;
											navigateTarget = value;
										}
									}
								}
								else if (item5 is FieldInfo fieldInfo3)
								{
									PlanetExplorerPlugin.Log.LogInfo((object)("  PlayerAction_Navigate." + fieldInfo3.Name + " [Field:" + fieldInfo3.FieldType.Name + "]"));
									if (navigateField == null && (fieldInfo3.FieldType == typeof(int) || fieldInfo3.FieldType == typeof(PlanetData) || fieldInfo3.FieldType == typeof(int?)))
									{
										navigateField = fieldInfo3;
										navigateTarget = value;
									}
								}
								else if (item5 is PropertyInfo propertyInfo3)
								{
									PlanetExplorerPlugin.Log.LogInfo((object)("  PlayerAction_Navigate." + propertyInfo3.Name + " [Property:" + propertyInfo3.PropertyType.Name + "]"));
									if (navigateProperty == null && propertyInfo3.CanWrite && (propertyInfo3.PropertyType == typeof(int) || propertyInfo3.PropertyType == typeof(PlanetData) || propertyInfo3.PropertyType == typeof(int?)))
									{
										navigateProperty = propertyInfo3;
										navigateTarget = value;
									}
								}
							}
							PlanetExplorerPlugin.Log.LogInfo((object)"  === ALL PlayerAction_Navigate methods ===");
							foreach (MethodInfo item6 in from m in item4.FieldType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
								where !m.Name.StartsWith("get_") && !m.Name.StartsWith("set_")
								orderby m.Name
								select m)
							{
								PlanetExplorerPlugin.Log.LogInfo((object)("    " + item6.Name + "(" + string.Join(",", from p in item6.GetParameters()
									select p.ParameterType.Name + " " + p.Name) + ")"));
							}
							PlanetExplorerPlugin.Log.LogInfo((object)"  === ALL PlayerAction_Navigate fields ===");
							FieldInfo[] fields = item4.FieldType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							foreach (FieldInfo fieldInfo4 in fields)
							{
								PlanetExplorerPlugin.Log.LogInfo((object)("    " + fieldInfo4.Name + " [Field:" + fieldInfo4.FieldType.Name + "]"));
							}
							try
							{
								FieldInfo field2 = item4.FieldType.GetField("navigation", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
								if (!(field2 != null))
								{
									continue;
								}
								playerNavInstance = field2.GetValue(value);
								if (playerNavInstance == null)
								{
									continue;
								}
								playerNavType = playerNavInstance.GetType();
								PlanetExplorerPlugin.Log.LogInfo((object)("  Found PlayerNavigation instance: " + playerNavType.Name));
								PlanetExplorerPlugin.Log.LogInfo((object)"  === ALL PlayerNavigation methods ===");
								foreach (MethodInfo item7 in from m in playerNavType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
									where !m.Name.StartsWith("get_") && !m.Name.StartsWith("set_")
									orderby m.Name
									select m)
								{
									PlanetExplorerPlugin.Log.LogInfo((object)("    " + item7.Name + "(" + string.Join(",", from p in item7.GetParameters()
										select p.ParameterType.Name + " " + p.Name) + ")"));
								}
								PlanetExplorerPlugin.Log.LogInfo((object)"  === ALL PlayerNavigation fields ===");
								fields = playerNavType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
								foreach (FieldInfo fieldInfo5 in fields)
								{
									PlanetExplorerPlugin.Log.LogInfo((object)("    " + fieldInfo5.Name + " [Field:" + fieldInfo5.FieldType.Name + "]"));
								}
								PlanetExplorerPlugin.Log.LogInfo((object)"  === ALL PlayerNavigation properties ===");
								PropertyInfo[] properties = playerNavType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
								foreach (PropertyInfo propertyInfo4 in properties)
								{
									PlanetExplorerPlugin.Log.LogInfo((object)$"    {propertyInfo4.Name} [Property:{propertyInfo4.PropertyType.Name}] CanWrite={propertyInfo4.CanWrite}");
								}
								playerNavSetMethod = playerNavType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => (m.Name.IndexOf("set", StringComparison.OrdinalIgnoreCase) >= 0 || m.Name.IndexOf("navigate", StringComparison.OrdinalIgnoreCase) >= 0 || m.Name.IndexOf("target", StringComparison.OrdinalIgnoreCase) >= 0 || m.Name.IndexOf("planet", StringComparison.OrdinalIgnoreCase) >= 0) && m.GetParameters().Length <= 2);
								playerNavTargetField = playerNavType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((FieldInfo fi) => (fi.Name.IndexOf("target", StringComparison.OrdinalIgnoreCase) >= 0 || fi.Name.IndexOf("planet", StringComparison.OrdinalIgnoreCase) >= 0 || fi.Name.IndexOf("navigate", StringComparison.OrdinalIgnoreCase) >= 0) && (fi.FieldType == typeof(int) || fi.FieldType == typeof(PlanetData) || fi.FieldType == typeof(int?)));
								playerNavTargetProperty = playerNavType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((PropertyInfo pi) => pi.CanWrite && (pi.Name.IndexOf("target", StringComparison.OrdinalIgnoreCase) >= 0 || pi.Name.IndexOf("planet", StringComparison.OrdinalIgnoreCase) >= 0 || pi.Name.IndexOf("navigate", StringComparison.OrdinalIgnoreCase) >= 0) && (pi.PropertyType == typeof(int) || pi.PropertyType == typeof(PlanetData) || pi.PropertyType == typeof(int?)));
								if (playerNavSetMethod != null)
								{
									PlanetExplorerPlugin.Log.LogInfo((object)("  Selected PlayerNavigation method: " + playerNavSetMethod.Name));
								}
								if (playerNavTargetField != null)
								{
									PlanetExplorerPlugin.Log.LogInfo((object)("  Selected PlayerNavigation field: " + playerNavTargetField.Name));
								}
								if (playerNavTargetProperty != null)
								{
									PlanetExplorerPlugin.Log.LogInfo((object)("  Selected PlayerNavigation property: " + playerNavTargetProperty.Name));
								}
							}
							catch (Exception ex3)
							{
								PlanetExplorerPlugin.Log.LogWarning((object)("  PlayerNavigation analysis failed: " + ex3.Message));
							}
						}
					}
				}
				catch (Exception ex4)
				{
					PlanetExplorerPlugin.Log.LogWarning((object)("Find PlayerAction_Navigate from player failed: " + ex4.Message));
				}
				if (navigateMethod != null)
				{
					PlanetExplorerPlugin.Log.LogInfo((object)("Selected method: " + navigateMethod.DeclaringType?.Name + "." + navigateMethod.Name));
				}
				if (navigateField != null)
				{
					PlanetExplorerPlugin.Log.LogInfo((object)("Selected field: " + navigateField.DeclaringType?.Name + "." + navigateField.Name));
				}
				if (navigateProperty != null)
				{
					PlanetExplorerPlugin.Log.LogInfo((object)("Selected property: " + navigateProperty.DeclaringType?.Name + "." + navigateProperty.Name));
				}
				if (list2.Count == 0)
				{
					PlanetExplorerPlugin.Log.LogWarning((object)"No navigation members found");
				}
			}
			catch (Exception ex5)
			{
				PlanetExplorerPlugin.Log.LogWarning((object)("Navigation init failed: " + ex5.Message));
			}
		}

		private static void ScanAllAssemblies(List<(Type type, object instance, string label)> candidates)
		{
			try
			{
				List<Type> list = (from t in (from a in AppDomain.CurrentDomain.GetAssemblies()
						where a.GetName().Name.Contains("Assembly-CSharp") || a.GetName().Name.Contains("Unity")
						select a).SelectMany(delegate(Assembly a)
					{
						try
						{
							return a.GetTypes();
						}
						catch
						{
							return new Type[0];
						}
					}).ToList()
					where SearchKeywords.Any((string k) => t.Name.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0)
					where !ExcludeKeywords.Any((string k) => t.Name.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0)
					select t).ToList();
				PlanetExplorerPlugin.Log.LogInfo((object)$"=== Found {list.Count} navigation-related types ===");
				foreach (Type item in list)
				{
					PlanetExplorerPlugin.Log.LogInfo((object)("  Type: " + item.FullName));
					PropertyInfo property = item.GetProperty("instance", BindingFlags.Static | BindingFlags.Public);
					FieldInfo field = item.GetField("instance", BindingFlags.Static | BindingFlags.Public);
					object obj = null;
					if (property != null)
					{
						obj = property.GetValue(null);
					}
					else if (field != null)
					{
						obj = field.GetValue(null);
					}
					if (obj != null)
					{
						candidates.Add((item, obj, item.Name));
						PlanetExplorerPlugin.Log.LogInfo((object)"    -> Added as candidate with instance");
					}
				}
			}
			catch (Exception ex)
			{
				PlanetExplorerPlugin.Log.LogWarning((object)("Assembly scan failed: " + ex.Message));
			}
		}

		private static void AnalyzeKeyType(string typeName, List<(Type type, object instance, string label)> candidates)
		{
			try
			{
				List<Type> list = (from t in (from a in AppDomain.CurrentDomain.GetAssemblies()
						where a.GetName().Name.Contains("Assembly-CSharp")
						select a).SelectMany(delegate(Assembly a)
					{
						try
						{
							return a.GetTypes();
						}
						catch
						{
							return new Type[0];
						}
					})
					where t.Name == typeName
					select t).ToList();
				if (list.Count == 0)
				{
					PlanetExplorerPlugin.Log.LogInfo((object)("Type " + typeName + " not found"));
					return;
				}
				Type type = list[0];
				PlanetExplorerPlugin.Log.LogInfo((object)("=== Deep analysis: " + typeName + " ==="));
				PlanetExplorerPlugin.Log.LogInfo((object)"  Methods:");
				foreach (MethodInfo item in from m in type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
					where !m.Name.StartsWith("get_") && !m.Name.StartsWith("set_")
					orderby m.Name
					select m)
				{
					PlanetExplorerPlugin.Log.LogInfo((object)("    " + item.Name + "(" + string.Join(", ", from p in item.GetParameters()
						select p.ParameterType.Name + " " + p.Name) + ")"));
				}
				PlanetExplorerPlugin.Log.LogInfo((object)"  Fields:");
				FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					PlanetExplorerPlugin.Log.LogInfo((object)("    " + fieldInfo.Name + " [Field:" + fieldInfo.FieldType.Name + "]"));
				}
				PlanetExplorerPlugin.Log.LogInfo((object)"  Properties:");
				PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (PropertyInfo propertyInfo in properties)
				{
					PlanetExplorerPlugin.Log.LogInfo((object)$"    {propertyInfo.Name} [Property:{propertyInfo.PropertyType.Name}] CanWrite={propertyInfo.CanWrite}");
				}
				PropertyInfo property = type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public);
				FieldInfo field = type.GetField("instance", BindingFlags.Static | BindingFlags.Public);
				object obj = null;
				if (property != null)
				{
					obj = property.GetValue(null);
				}
				else if (field != null)
				{
					obj = field.GetValue(null);
				}
				if (obj != null)
				{
					candidates.Add((type, obj, typeName));
					PlanetExplorerPlugin.Log.LogInfo((object)"  -> Added as candidate with static instance");
				}
			}
			catch (Exception ex)
			{
				PlanetExplorerPlugin.Log.LogWarning((object)("Analyze " + typeName + " failed: " + ex.Message));
			}
		}

		private static void AnalyzeEnum(string enumName)
		{
			try
			{
				List<Type> list = (from t in (from a in AppDomain.CurrentDomain.GetAssemblies()
						where a.GetName().Name.Contains("Assembly-CSharp")
						select a).SelectMany(delegate(Assembly a)
					{
						try
						{
							return a.GetTypes();
						}
						catch
						{
							return new Type[0];
						}
					})
					where t.Name == enumName && t.IsEnum
					select t).ToList();
				if (list.Count == 0)
				{
					PlanetExplorerPlugin.Log.LogInfo((object)("Enum " + enumName + " not found"));
					return;
				}
				Type enumType = list[0];
				PlanetExplorerPlugin.Log.LogInfo((object)("=== Enum: " + enumName + " ==="));
				string[] names = Enum.GetNames(enumType);
				foreach (string text in names)
				{
					PlanetExplorerPlugin.Log.LogInfo((object)$"  {text} = {Convert.ToInt32(Enum.Parse(enumType, text))}");
				}
			}
			catch (Exception ex)
			{
				PlanetExplorerPlugin.Log.LogWarning((object)("Analyze enum " + enumName + " failed: " + ex.Message));
			}
		}

		public static bool NavigateToPlanet(int planetId)
		{
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: 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_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			Init();
			try
			{
				PlanetData val = GameMain.galaxy.PlanetById(planetId);
				PlanetExplorerPlugin.Log.LogInfo((object)$"Navigate to planet: {((val != null) ? val.displayName : null)} (ID={planetId})");
				object playerNavigation = GetPlayerNavigation();
				if (playerNavigation != null)
				{
					try
					{
						MethodInfo method = playerNavType.GetMethod("Abort", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (method != null)
						{
							FieldInfo field = playerNavType.GetField("navigating", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							if (field != null && (bool)field.GetValue(playerNavigation))
							{
								method.Invoke(playerNavigation, null);
								PlanetExplorerPlugin.Log.LogInfo((object)"Aborted previous auto-navigation");
							}
						}
						FieldInfo field2 = playerNavType.GetField("_indicatorAstroId", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field2 != null)
						{
							field2.SetValue(playerNavigation, planetId);
							FieldInfo field3 = playerNavType.GetField("_indicatorMsgId", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							if (field3 != null)
							{
								field3.SetValue(playerNavigation, 0);
							}
							FieldInfo field4 = playerNavType.GetField("_indicatorEnemyId", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							if (field4 != null)
							{
								field4.SetValue(playerNavigation, 0);
							}
							PlanetExplorerPlugin.Log.LogInfo((object)$"Set _indicatorAstroId={planetId}");
							return true;
						}
					}
					catch (Exception ex)
					{
						PlanetExplorerPlugin.Log.LogWarning((object)("Set _indicatorAstroId failed: " + ex.Message));
					}
				}
				if (spaceGuideType != null && setEntryMethod != null && planetGuideTypeValue != null)
				{
					try
					{
						if (spaceGuideInstance == null || spaceGuideInstance.Equals(null))
						{
							spaceGuideInstance = typeof(Object).GetMethod("FindObjectOfType", new Type[0]).MakeGenericMethod(spaceGuideType).Invoke(null, null);
							PlanetExplorerPlugin.Log.LogInfo((object)$"Re-found UISpaceGuide instance: {spaceGuideInstance != null}");
						}
						if (spaceGuideInstance != null && !spaceGuideInstance.Equals(null))
						{
							MethodInfo method2 = spaceGuideType.GetMethod("_Open", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							if (method2 == null)
							{
								method2 = spaceGuideType.GetMethod("Open", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							}
							if (method2 != null && method2.GetParameters().Length == 0)
							{
								method2.Invoke(spaceGuideInstance, null);
								PlanetExplorerPlugin.Log.LogInfo((object)"Called UISpaceGuide._Open()");
							}
							Vector3 val2 = Vector3.zero;
							float num = 0f;
							try
							{
								FieldInfo field5 = ((object)val).GetType().GetField("uPosition", BindingFlags.Instance | BindingFlags.Public);
								if (field5 != null)
								{
									object value = field5.GetValue(val);
									FieldInfo field6 = value.GetType().GetField("x");
									FieldInfo field7 = value.GetType().GetField("y");
									FieldInfo field8 = value.GetType().GetField("z");
									if (field6 != null && field7 != null && field8 != null)
									{
										double num2 = Convert.ToDouble(field6.GetValue(value));
										double num3 = Convert.ToDouble(field7.GetValue(value));
										double num4 = Convert.ToDouble(field8.GetValue(value));
										try
										{
											Player mainPlayer = GameMain.mainPlayer;
											if (mainPlayer != null)
											{
												FieldInfo field9 = ((object)mainPlayer).GetType().GetField("uPosition", BindingFlags.Instance | BindingFlags.Public);
												if (field9 != null)
												{
													object value2 = field9.GetValue(mainPlayer);
													FieldInfo field10 = value2.GetType().GetField("x");
													FieldInfo field11 = value2.GetType().GetField("y");
													FieldInfo field12 = value2.GetType().GetField("z");
													if (field10 != null && field11 != null && field12 != null)
													{
														double num5 = Convert.ToDouble(field10.GetValue(value2));
														double num6 = Convert.ToDouble(field11.GetValue(value2));
														double num7 = Convert.ToDouble(field12.GetValue(value2));
														val2 = new Vector3((float)(num2 - num5), (float)(num3 - num6), (float)(num4 - num7));
														PlanetExplorerPlugin.Log.LogInfo((object)$"Using relative position: {val2}");
													}
												}
											}
										}
										catch
										{
										}
										if (val2 == Vector3.zero)
										{
											val2 = new Vector3((float)num2, (float)num3, (float)num4);
										}
									}
								}
								FieldInfo field13 = ((object)val).GetType().GetField("radius", BindingFlags.Instance | BindingFlags.Public);
								if (field13 != null)
								{
									num = Convert.ToSingle(field13.GetValue(val));
								}
							}
							catch (Exception ex2)
							{
								PlanetExplorerPlugin.Log.LogWarning((object)("Get planet pos failed: " + ex2.Message));
							}
							PlanetExplorerPlugin.Log.LogInfo((object)$"Planet pos: {val2}, radius: {num}");
							object[] array = new object[6] { spaceGuideCount, planetGuideTypeValue, planetId, 0, val2, num };
							setEntryMethod.Invoke(spaceGuideInstance, array);
							spaceGuideCount = (int)array[0];
							PlanetExplorerPlugin.Log.LogInfo((object)$"Called UISpaceGuide.SetEntry(Planet, objId={planetId}), guidecnt={spaceGuideCount}");
							MethodInfo method3 = spaceGuideType.GetMethod("MarkDirty", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							if (method3 != null && method3.GetParameters().Length == 0)
							{
								method3.Invoke(spaceGuideInstance, null);
								PlanetExplorerPlugin.Log.LogInfo((object)"Called UISpaceGuide.MarkDirty()");
							}
							return true;
						}
					}
					catch (Exception ex3)
					{
						PlanetExplorerPlugin.Log.LogWarning((object)("UISpaceGuide.SetEntry failed: " + ex3.Message + "\n" + ex3.StackTrace));
					}
				}
				if (navigateMethod != null)
				{
					ParameterInfo[] parameters = navigateMethod.GetParameters();
					object obj2 = ((parameters[0].ParameterType == typeof(PlanetData)) ? val : ((!(parameters[0].ParameterType == typeof(StarData))) ? ((object)planetId) : val?.star));
					navigateMethod.Invoke(navigateTarget, new object[1] { obj2 });
					PlanetExplorerPlugin.Log.LogInfo((object)("Called method: " + navigateMethod.DeclaringType?.Name + "." + navigateMethod.Name));
					return true;
				}
				if (navigateField != null)
				{
					object value3 = ((navigateField.FieldType == typeof(PlanetData)) ? val : ((object)planetId));
					navigateField.SetValue(navigateTarget, value3);
					PlanetExplorerPlugin.Log.LogInfo((object)$"Set field: {navigateField.DeclaringType?.Name}.{navigateField.Name}={planetId}");
					TryTriggerNavigate();
					return true;
				}
				if (navigateProperty != null)
				{
					object value4 = ((navigateProperty.PropertyType == typeof(PlanetData)) ? val : ((object)planetId));
					navigateProperty.SetValue(navigateTarget, value4);
					PlanetExplorerPlugin.Log.LogInfo((object)$"Set property: {navigateProperty.DeclaringType?.Name}.{navigateProperty.Name}={planetId}");
					TryTriggerNavigate();
					return true;
				}
				return OpenStarmapAndSelect(planetId);
			}
			catch (Exception ex4)
			{
				PlanetExplorerPlugin.Log.LogWarning((object)("Navigation failed: " + ex4.Message));
				return false;
			}
		}

		private static void TryTriggerNavigate()
		{
			try
			{
				UIStarmap val = UIRoot.instance?.uiGame?.starmap;
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Type type = ((object)val).GetType();
				string[] array = new string[9] { "OnNavigateClick", "SetNavigateTarget", "StartNavigate", "NavigateToTarget", "ShowNavigateIndicator", "UpdateNavigateIndicator", "OnLocateClick", "SetLocateTarget", "StartLocate" };
				foreach (string text in array)
				{
					MethodInfo method = type.GetMethod(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (method != null && method.GetParameters().Length == 0)
					{
						method.Invoke(val, null);
						PlanetExplorerPlugin.Log.LogInfo((object)("Called trigger: " + text));
						return;
					}
				}
				PlanetExplorerPlugin.Log.LogInfo((object)"No trigger method found in UIStarmap");
			}
			catch (Exception ex)
			{
				PlanetExplorerPlugin.Log.LogWarning((object)("Trigger navigation failed: " + ex.Message));
			}
		}

		private static bool OpenStarmapAndSelect(int planetId)
		{
			try
			{
				UIStarmap val = UIRoot.instance?.uiGame?.starmap;
				if ((Object)(object)val == (Object)null)
				{
					PlanetExplorerPlugin.Log.LogWarning((object)"Starmap UI not available");
					return false;
				}
				MethodInfo method = ((object)val).GetType().GetMethod("Open", BindingFlags.Instance | BindingFlags.Public);
				if (method != null)
				{
					method.Invoke(val, null);
				}
				PlanetData val2 = GameMain.galaxy.PlanetById(planetId);
				PlanetExplorerPlugin.Log.LogInfo((object)("Opened starmap, target: " + ((val2 != null) ? val2.displayName : null) + ", right-click planet to set navigation"));
				return true;
			}
			catch (Exception ex)
			{
				PlanetExplorerPlugin.Log.LogWarning((object)("Open starmap failed: " + ex.Message));
				return false;
			}
		}
	}
	public class PlanetExplorerUI : MonoBehaviour
	{
		private const float designWindowWidth = 1850f;

		private const float designWindowHeight = 1050f;

		private const float screenMargin = 12f;

		private bool visible;

		private Rect windowRect = new Rect(0f, 0f, 1850f, 1050f);

		private float uiScale = 1f;

		private bool layoutInitialized;

		private int layoutScreenWidth = -1;

		private int layoutScreenHeight = -1;

		private Vector2 scrollPosition;

		private List<PlanetInfo> allPlanets = new List<PlanetInfo>();

		private List<StarGroup> starGroups = new List<StarGroup>();

		private bool dataLoaded;

		private volatile bool dataDirty;

		private float lastReloadTime = -1f;

		private int lastObserveLevel;

		private int hiddenStarCount;

		private bool showVeinAmount;

		private bool isInfiniteResource;

		private bool sortKeyMode;

		private float miningSpeedScale = 1f;

		private string searchText = "";

		private int filterPlanetTypeIdx;

		private int filterHasVeinIdx;

		private bool allExpanded = true;

		private int sortColumn = -1;

		private bool sortAscending = true;

		private int viewMode;

		private List<SortCondition> sortConditions = new List<SortCondition>();

		private bool showSortPanel;

		private Rect sortPanelRect = new Rect(200f, 200f, 550f, 500f);

		private Vector2 sortPanelScroll;

		private int activeDropdown = -1;

		private Vector2 dropdownScroll;

		private List<TableRow> flatRows = new List<TableRow>();

		private const float rowHeight = 30f;

		private const float headerRowHeight = 30f;

		private bool rowsDirty = true;

		private static readonly string[] veinNames = new string[14]
		{
			"铁", "铜", "硅", "钛", "石", "煤", "石油", "可燃冰", "金伯利", "分形硅",
			"有机晶体", "光栅石", "刺笋结晶", "单极磁石"
		};

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

		private const int oilVeinIdx = 6;

		private const int oilVeinId = 7;

		private const double oilSpeedMultiplier = 4E-05;

		private static readonly string[] gasNames = new string[3] { "氢气", "重氢", "可燃冰(气体)" };

		private static readonly int[] gasIds = new int[3] { 1120, 1121, 1011 };

		private const float mineralColWidth = 70f;

		private const float gasColWidth = 96f;

		private static readonly float[] baseColWidthsNormal = new float[7] { 185f, 75f, 55f, 45f, 45f, 65f, 52f };

		private static readonly float[] baseColWidthsGlobal = new float[8] { 140f, 125f, 60f, 45f, 45f, 45f, 60f, 46f };

		private static readonly string[] planetTypes = new string[12]
		{
			"全部", "地中海", "熔岩", "气态", "冰原冻土", "贫瘠荒漠", "火山灰", "樱林海", "猩红冰湖", "红石",
			"高产气巨", "极寒冻土"
		};

		private GUIStyle headerStyle;

		private GUIStyle cellStyle;

		private GUIStyle boldCellStyle;

		private GUIStyle leftCellStyle;

		private GUIStyle boldLeftCellStyle;

		private GUIStyle energyHighlightStyle;

		private GUIStyle groupHeaderStyle;

		private GUIStyle dropdownStyle;

		private GUIStyle tipStyle;

		private bool stylesInitialized;

		private bool guiLogged;

		private void InitStyles()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003e: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_004d: 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_0060: Expected O, but got Unknown
			//IL_006b: 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_0077: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_00e5: 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_00f4: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//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_011f: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Expected O, but got Unknown
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Expected O, but got Unknown
			//IL_0229: Expected O, but got Unknown
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			//IL_024d: Expected O, but got Unknown
			//IL_0258: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Expected O, but got Unknown
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			if (!stylesInitialized)
			{
				headerStyle = new GUIStyle(GUI.skin.button)
				{
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4,
					fontSize = 16,
					padding = new RectOffset(2, 2, 2, 2),
					margin = new RectOffset(1, 1, 1, 1),
					wordWrap = false,
					clipping = (TextClipping)1
				};
				cellStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontSize = 16,
					padding = new RectOffset(2, 2, 2, 2),
					margin = new RectOffset(1, 1, 1, 1),
					wordWrap = false,
					clipping = (TextClipping)1
				};
				boldCellStyle = new GUIStyle(GUI.skin.label)
				{
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4,
					fontSize = 16,
					padding = new RectOffset(2, 2, 2, 2),
					margin = new RectOffset(1, 1, 1, 1),
					wordWrap = false,
					clipping = (TextClipping)1
				};
				leftCellStyle = new GUIStyle(cellStyle)
				{
					alignment = (TextAnchor)3
				};
				boldLeftCellStyle = new GUIStyle(boldCellStyle)
				{
					alignment = (TextAnchor)3
				};
				energyHighlightStyle = new GUIStyle(boldCellStyle);
				Color highlightColor = default(Color);
				((Color)(ref highlightColor))..ctor(1f, 0.72f, 0.2f, 1f);
				if ((Object)(object)UIRoot.instance != (Object)null && (Object)(object)UIRoot.instance.uiGame != (Object)null && (Object)(object)UIRoot.instance.uiGame.planetDetail != (Object)null && (Object)(object)UIRoot.instance.uiGame.planetDetail.entryPrafab != (Object)null)
				{
					highlightColor = UIRoot.instance.uiGame.planetDetail.entryPrafab.highlightColor;
				}
				energyHighlightStyle.normal.textColor = highlightColor;
				groupHeaderStyle = new GUIStyle(GUI.skin.box)
				{
					fontStyle = (FontStyle)1,
					fontSize = 17,
					alignment = (TextAnchor)3,
					padding = new RectOffset(4, 4, 2, 2),
					margin = new RectOffset(1, 1, 1, 1)
				};
				dropdownStyle = new GUIStyle(GUI.skin.box)
				{
					padding = new RectOffset(2, 2, 2, 2)
				};
				tipStyle = new GUIStyle(GUI.skin.label)
				{
					fontStyle = (FontStyle)1,
					fontSize = 14,
					wordWrap = false,
					clipping = (TextClipping)1
				};
				stylesInitialized = true;
			}
		}

		private void UpdateResponsiveLayout()
		{
			int num = Mathf.Max(1, Screen.width);
			int num2 = Mathf.Max(1, Screen.height);
			float num3 = Mathf.Max(1f, (float)num - 24f);
			float num4 = Mathf.Max(1f, (float)num2 - 24f);
			uiScale = Mathf.Max(0.25f, Mathf.Min(1f, Mathf.Min(num3 / 1850f, num4 / 1050f)));
			bool flag = num != layoutScreenWidth || num2 != layoutScreenHeight;
			if (!layoutInitialized || flag)
			{
				((Rect)(ref windowRect)).width = 1850f;
				((Rect)(ref windowRect)).height = 1050f;
				CenterRectOnScreen(ref windowRect);
				CenterRectOnScreen(ref sortPanelRect);
				layoutInitialized = true;
				layoutScreenWidth = num;
				layoutScreenHeight = num2;
			}
		}

		private void CenterRectOnScreen(ref Rect rect)
		{
			float num = (float)Screen.width / uiScale;
			float num2 = (float)Screen.height / uiScale;
			((Rect)(ref rect)).x = Mathf.Max(0f, (num - ((Rect)(ref rect)).width) * 0.5f);
			((Rect)(ref rect)).y = Mathf.Max(0f, (num2 - ((Rect)(ref rect)).height) * 0.5f);
		}

		private void ClampRectToScreen(ref Rect rect)
		{
			float num = (float)Screen.width / uiScale;
			float num2 = (float)Screen.height / uiScale;
			float num3 = 12f / uiScale;
			float num4 = Mathf.Max(num3, num - ((Rect)(ref rect)).width - num3);
			float num5 = Mathf.Max(num3, num2 - ((Rect)(ref rect)).height - num3);
			((Rect)(ref rect)).x = Mathf.Clamp(((Rect)(ref rect)).x, num3, num4);
			((Rect)(ref rect)).y = Mathf.Clamp(((Rect)(ref rect)).y, num3, num5);
		}

		private Rect GetScreenRect(Rect logicalRect)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref logicalRect)).x * uiScale, ((Rect)(ref logicalRect)).y * uiScale, ((Rect)(ref logicalRect)).width * uiScale, ((Rect)(ref logicalRect)).height * uiScale);
		}

		private unsafe void OnGUI()
		{
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_0115: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			if (!visible)
			{
				return;
			}
			InitStyles();
			CheckDataDirty();
			UpdateResponsiveLayout();
			if (!guiLogged)
			{
				ManualLogSource log = PlanetExplorerPlugin.Log;
				string[] obj = new string[8]
				{
					"[DEBUG] OnGUI running, screen=",
					Screen.width.ToString(),
					"x",
					Screen.height.ToString(),
					", uiScale=",
					uiScale.ToString("F3"),
					", windowRect=",
					null
				};
				Rect val = windowRect;
				obj[7] = ((object)(*(Rect*)(&val))/*cast due to .constrained prefix*/).ToString();
				log.LogInfo((object)string.Concat(obj));
				guiLogged = true;
			}
			Matrix4x4 matrix = GUI.matrix;
			GUI.matrix = Matrix4x4.Scale(new Vector3(uiScale, uiScale, 1f)) * matrix;
			try
			{
				windowRect = GUILayout.Window(12345, windowRect, new WindowFunction(DrawWindow), "\ud83d\udd0d 戴森球行星探索器 v3.2.4", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(1850f),
					GUILayout.Height(1050f)
				});
				ClampRectToScreen(ref windowRect);
				if (showSortPanel)
				{
					sortPanelRect = GUILayout.Window(12346, sortPanelRect, new WindowFunction(DrawSortPanel), "\ud83d\udccb 多条件排序设置", (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(500f),
						GUILayout.Height(400f)
					});
					ClampRectToScreen(ref sortPanelRect);
				}
			}
			finally
			{
				GUI.matrix = matrix;
			}
			if (Event.current.isMouse && IsMouseOverPanel(Event.current.mousePosition))
			{
				Event.current.Use();
			}
		}

		public bool IsVisible()
		{
			return visible;
		}

		public bool IsMouseOverPanel()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (!visible)
			{
				return false;
			}
			Vector2 guiMousePosition = default(Vector2);
			((Vector2)(ref guiMousePosition))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y);
			return IsMouseOverPanel(guiMousePosition);
		}

		private bool IsMouseOverPanel(Vector2 guiMousePosition)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			Rect screenRect = GetScreenRect(windowRect);
			if (!((Rect)(ref screenRect)).Contains(guiMousePosition))
			{
				if (showSortPanel)
				{
					screenRect = GetScreenRect(sortPanelRect);
					return ((Rect)(ref screenRect)).Contains(guiMousePosition);
				}
				return false;
			}
			return true;
		}

		public void Hide()
		{
			visible = false;
		}

		public void Toggle()
		{
			visible = !visible;
			if (visible && !dataLoaded)
			{
				LoadData();
			}
		}

		public void OnGameBegin()
		{
			dataLoaded = false;
			allPlanets.Clear();
			starGroups.Clear();
			dataDirty = false;
			lastReloadTime = -1f;
		}

		public void MarkDataDirty()
		{
			dataDirty = true;
		}

		private void CheckDataDirty()
		{
			if (dataDirty && (lastReloadTime < 0f || Time.time - lastReloadTime >= 0.4f))
			{
				dataDirty = false;
				lastReloadTime = Time.time;
				LoadData();
			}
		}

		private void LoadData()
		{
			try
			{
				try
				{
					isInfiniteResource = GameMain.data.gameDesc.isInfiniteResource;
				}
				catch
				{
				}
				try
				{
					miningSpeedScale = GameMain.history.miningSpeedScale;
				}
				catch
				{
				}
				allPlanets = DataCollector.CollectAllPlanets();
				BuildStarGroups();
				ApplyFilters();
				CacheAllStrings();
				dataLoaded = true;
				UpdateObserveInfo();
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PlanetExplorer] 加载数据失败: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		private void UpdateObserveInfo()
		{
			hiddenStarCount = 0;
			lastObserveLevel = 0;
			try
			{
				if ((Object)(object)GameMain.instance == (Object)null || GameMain.galaxy == null || GameMain.galaxy.stars == null)
				{
					return;
				}
				lastObserveLevel = GameMain.history.universeObserveLevel;
				StarData birthStar = ((GameMain.galaxy.birthStarId >= 0) ? GameMain.galaxy.StarById(GameMain.galaxy.birthStarId) : null);
				StarData[] stars = GameMain.galaxy.stars;
				foreach (StarData val in stars)
				{
					if (val != null && lastObserveLevel < PlanetExplorerPlugin.GetStarNeedLevel(val, birthStar))
					{
						hiddenStarCount++;
					}
				}
			}
			catch
			{
			}
		}

		private void DrawTechHint()
		{
			if (hiddenStarCount > 0)
			{
				GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
				GUILayout.Label("⚙ 宇宙观测等级 Lv." + lastObserveLevel + ":未达到该等级的恒星系(" + hiddenStarCount + " 个)为「未探索」,其行星与资源不会显示在面板中。升级科技「宇宙探索」后会自动解锁显示。", Array.Empty<GUILayoutOption>());
				GUILayout.EndHorizontal();
			}
		}

		private void BuildStarGroups()
		{
			starGroups = (from p in allPlanets
				group p by p.starName into g
				select new StarGroup
				{
					starName = g.Key,
					starType = g.First().starType,
					starLuminosity = g.First().starLuminosity,
					planets = g.ToList(),
					expanded = allExpanded
				}).ToList();
			foreach (StarGroup starGroup in starGroups)
			{
				starGroup.isObserved = starGroup.planets.Count > 0 && starGroup.planets[0].isObserved;
				SummarizeGroup(starGroup);
				SummarizeGroupSort(starGroup);
			}
			rowsDirty = true;
		}

		private void SummarizeGroup(StarGroup group)
		{
			group.veinSummary = new long[veinIds.Length];
			group.gasSummary = new float[gasIds.Length];
			group.veinSummaryText = new string[veinIds.Length];
			group.gasSummaryText = new string[gasIds.Length];
			group.oilRateSummary = 0.0;
			foreach (PlanetInfo planet in group.planets)
			{
				for (int i = 0; i < veinIds.Length; i++)
				{
					int key = veinIds[i];
					if (i == 6)
					{
						group.oilRateSummary += GetOilRate(planet);
					}
					else if (showVeinAmount)
					{
						group.veinSummary[i] += (planet.veinAmounts.ContainsKey(key) ? planet.veinAmounts[key] : 0);
					}
					else
					{
						group.veinSummary[i] += (planet.veinCounts.ContainsKey(key) ? planet.veinCounts[key] : 0);
					}
				}
				for (int j = 0; j < gasIds.Length; j++)
				{
					group.gasSummary[j] += (planet.gasSpeeds.ContainsKey(gasIds[j]) ? planet.gasSpeeds[gasIds[j]] : 0f);
				}
			}
			for (int k = 0; k < veinIds.Length; k++)
			{
				if (k == 6)
				{
					group.veinSummaryText[k] = (group.isObserved ? FormatOilRate(group.oilRateSummary) : "未探索");
				}
				else
				{
					group.veinSummaryText[k] = (group.isObserved ? FormatSummaryVein(k, group.veinSummary[k]) : "未探索");
				}
			}
			for (int l = 0; l < gasIds.Length; l++)
			{
				group.gasSummaryText[l] = (group.isObserved ? ((group.gasSummary[l] > 0f) ? (group.gasSummary[l].ToString("F4") + "/s") : "-") : "未探索");
			}
		}

		private void SummarizeGroupSort(StarGroup group)
		{
			group.veinSummarySort = new long[veinIds.Length];
			group.oilRateSummarySort = 0.0;
			foreach (PlanetInfo planet in group.planets)
			{
				for (int i = 0; i < veinIds.Length; i++)
				{
					int key = veinIds[i];
					if (i == 6)
					{
						group.oilRateSummarySort += GetOilRate(planet);
					}
					else if (sortKeyMode)
					{
						group.veinSummarySort[i] += (planet.veinAmounts.ContainsKey(key) ? planet.veinAmounts[key] : 0);
					}
					else
					{
						group.veinSummarySort[i] += (planet.veinCounts.ContainsKey(key) ? planet.veinCounts[key] : 0);
					}
				}
			}
		}

		private void UpdateSortSummaries()
		{
			foreach (StarGroup starGroup in starGroups)
			{
				SummarizeGroupSort(starGroup);
			}
		}

		private void DrawWindow(int windowID)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			DrawToolbar();
			DrawFilterBar();
			DrawTechHint();
			DrawTable();
			DrawStatusBar();
			GUILayout.EndVertical();
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
		}

		private void DrawToolbar()
		{
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Expected O, but got Unknown
			GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("\ud83d\udd04 刷新", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }))
			{
				LoadData();
			}
			if (!isInfiniteResource && GUILayout.Button(showVeinAmount ? "矿脉: 储量" : "矿脉: 数量", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
			{
				showVeinAmount = !showVeinAmount;
				RebuildTexts();
			}
			if (GUILayout.Button(allExpanded ? "▼ 全部折叠" : "▶ 全部展开", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }))
			{
				allExpanded = !allExpanded;
				foreach (StarGroup starGroup in starGroups)
				{
					starGroup.expanded = allExpanded;
				}
			}
			GUILayout.Space(10f);
			GUILayout.Label("搜索:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) });
			searchText = GUILayout.TextField(searchText, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) });
			if (GUI.changed)
			{
				ApplyFilters();
			}
			GUILayout.FlexibleSpace();
			int num = starGroups.Sum((StarGroup g) => g.planets.Count);
			int num2 = starGroups.Where((StarGroup g) => g.expanded).Sum((StarGroup g) => g.planets.Count);
			GUILayout.Label($"{starGroups.Count} 恒星系 / {num} 行星 (显示 {num2})", new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1
			}, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
		}

		private void DrawFilterBar()
		{
			GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.Space(10f);
			GUILayout.Label("视图:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(35f) });
			if (GUILayout.Button((new string[3] { "分组显示", "仅恒星系", "行星(卫星)" })[viewMode], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) }))
			{
				viewMode = (viewMode + 1) % 3;
				rowsDirty = true;
				int num = ((viewMode == 2) ? 8 : 7) + gasNames.Length + veinNames.Length - 1;
				if (sortColumn > num)
				{
					sortColumn = -1;
				}
				if (sortColumn >= 0)
				{
					SortByColumn(sortColumn, sortAscending);
				}
			}
			GUILayout.Space(10f);
			if (GUILayout.Button("\ud83d\udccb 排序设置", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }))
			{
				showSortPanel = !showSortPanel;
			}
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("重置", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }))
			{
				ResetFilters();
			}
			GUILayout.EndHorizontal();
			if (activeDropdown >= 0)
			{
				DrawDropdownList();
			}
		}

		private void DrawDropdown(int id, string[] options, ref int selectedIdx, float width)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width) });
			if (GUILayout.Button(options[selectedIdx] + " ▼", GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(width - 20f) }))
			{
				activeDropdown = ((activeDropdown == id) ? (-1) : id);
				dropdownScroll = Vector2.zero;
			}
			GUILayout.EndHorizontal();
		}

		private void DrawDropdownList()
		{
			//IL_006b: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			string[] array = ((activeDropdown == 0) ? planetTypes : ((Func<string[]>)delegate
			{
				string[] array2 = new string[veinNames.Length + 1];
				array2[0] = "全部";
				Array.Copy(veinNames, 0, array2, 1, veinNames.Length);
				return array2;
			})());
			int num = ((activeDropdown == 0) ? filterPlanetTypeIdx : filterHasVeinIdx);
			GUILayout.BeginVertical(dropdownStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
			dropdownScroll = GUILayout.BeginScrollView(dropdownScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height((float)Mathf.Min(200, array.Length * 22)) });
			for (int num2 = 0; num2 < array.Length; num2++)
			{
				if (GUILayout.Button(array[num2], (num2 == num) ? boldCellStyle : cellStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) }))
				{
					if (activeDropdown == 0)
					{
						filterPlanetTypeIdx = num2;
					}
					else
					{
						filterHasVeinIdx = num2;
					}
					activeDropdown = -1;
					ApplyFilters();
				}
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
		}

		private void ResetFilters()
		{
			searchText = "";
			sortColumn = -1;
			viewMode = 0;
			ApplyFilters();
		}

		private void ApplyFilters()
		{
			List<PlanetInfo> list = allPlanets.Where(delegate(PlanetInfo p)
			{
				if (!string.IsNullOrEmpty(searchText))
				{
					string value = searchText.ToLower();
					if (!p.starName.ToLower().Contains(value) && !p.planetName.ToLower().Contains(value))
					{
						return false;
					}
				}
				return true;
			}).ToList();
			allPlanets = list;
			BuildStarGroups();
			if (sortColumn >= 0)
			{
				SortByColumn(sortColumn, sortAscending);
			}
		}

		private string FormatFluidAmount(long amount)
		{
			if (amount <= 0)
			{
				return "-";
			}
			if (amount >= 100000000)
			{
				return ((double)amount / 100000000.0).ToString("F2") + "亿";
			}
			if (amount >= 10000)
			{
				return ((double)amount / 10000.0).ToString("F1") + "万";
			}
			return amount.ToString();
		}

		private double GetOilRate(PlanetInfo p)
		{
			return (double)(p.veinAmounts.ContainsKey(7) ? p.veinAmounts[7] : 0) * 4E-05 * (double)miningSpeedScale;
		}

		private string FormatOilRate(double rate)
		{
			if (rate <= 0.0)
			{
				return "-";
			}
			if (rate >= 100.0)
			{
				return rate.ToString("F0") + "/s";
			}
			return rate.ToString("F1") + "/s";
		}

		private void CacheAllStrings()
		{
			foreach (PlanetInfo allPlanet in allPlanets)
			{
				allPlanet.cachedLuminosity = FormatEnergyPercent(allPlanet.luminosity);
				allPlanet.cachedWind = FormatEnergyPercent(allPlanet.windStrength);
				allPlanet.cachedDistance = allPlanet.distanceToBirth.ToString("F2") + "ly";
				BuildPlanetResourceTexts(allPlanet);
			}
			rowsDirty = true;
		}

		private static string FormatEnergyPercent(float value)
		{
			return (uint)(value * 100f + 0.4999f) + "%";
		}

		private void BuildPlanetResourceTexts(PlanetInfo p)
		{
			if (p.cachedVeinTexts == null || p.cachedVeinTexts.Length != veinIds.Length)
			{
				p.cachedVeinTexts = new string[veinIds.Length];
			}
			if (p.cachedGasTexts == null || p.cachedGasTexts.Length != gasIds.Length)
			{
				p.cachedGasTexts = new string[gasIds.Length];
			}
			if (!p.isObserved)
			{
				for (int i = 0; i < veinIds.Length; i++)
				{
					p.cachedVeinTexts[i] = "未探索";
				}
				for (int j = 0; j < gasIds.Length; j++)
				{
					p.cachedGasTexts[j] = "未探索";
				}
				return;
			}
			for (int k = 0; k < veinIds.Length; k++)
			{
				int key = veinIds[k];
				if (p.isGas)
				{
					p.cachedVeinTexts[k] = "-";
				}
				else if (k == 6)
				{
					p.cachedVeinTexts[k] = FormatOilRate(GetOilRate(p));
				}
				else if (showVeinAmount)
				{
					long num = (p.veinAmounts.ContainsKey(key) ? p.veinAmounts[key] : 0);
					p.cachedVeinTexts[k] = ((num > 0) ? FormatFluidAmount(num) : "-");
				}
				else
				{
					int num2 = (p.veinCounts.ContainsKey(key) ? p.veinCounts[key] : 0);
					p.cachedVeinTexts[k] = ((num2 > 0) ? num2.ToString() : "-");
				}
			}
			for (int l = 0; l < gasIds.Length; l++)
			{
				if (p.isGas)
				{
					float num3 = (p.gasSpeeds.ContainsKey(gasIds[l]) ? p.gasSpeeds[gasIds[l]] : 0f);
					p.cachedGasTexts[l] = ((num3 > 0f) ? (num3.ToString("F4") + "/s") : "-");
				}
				else
				{
					p.cachedGasTexts[l] = "-";
				}
			}
		}

		private void RebuildTexts()
		{
			foreach (PlanetInfo allPlanet in allPlanets)
			{
				BuildPlanetResourceTexts(allPlanet);
			}
			foreach (StarGroup starGroup in starGroups)
			{
				SummarizeGroup(starGroup);
				SummarizeGroupSort(starGroup);
			}
			rowsDirty = true;
		}

		private void BuildFlatRows()
		{
			try
			{
				flatRows.Clear();
				if (viewMode == 2)
				{
					foreach (PlanetInfo allPlanet in allPlanets)
					{
						flatRows.Add(new TableRow
						{
							isStar = false,
							planet = allPlanet
						});
					}
				}
				else
				{
					for (int i = 0; i < starGroups.Count; i++)
					{
						StarGroup starGroup = starGroups[i];
						if (starGroup == null)
						{
							continue;
						}
						flatRows.Add(new TableRow
						{
							isStar = true,
							starGroup = starGroup,
							starGroupIdx = i
						});
						if (viewMode != 0 || !starGroup.expanded)
						{
							continue;
						}
						foreach (PlanetInfo planet in starGroup.planets)
						{
							if (planet != null)
							{
								flatRows.Add(new TableRow
								{
									isStar = false,
									planet = planet,
									starGroupIdx = i
								});
							}
						}
					}
				}
				rowsDirty = false;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PlanetExplorer] BuildFlatRows出错: " + ex.Message + "\n" + ex.StackTrace));
				rowsDirty = false;
			}
		}

		private string FormatSummaryVein(int idx, long amount)
		{
			if (amount <= 0)
			{
				return "-";
			}
			if (showVeinAmount)
			{
				return FormatFluidAmount(amount);
			}
			return amount.ToString("N0");
		}

		private void DrawTable()
		{
			//IL_00ae: 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_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: 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_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Expected O, but got Unknown
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			bool flag = viewMode == 2;
			string[] array = ((!flag) ? new string[7] { "星球", "类型", "海洋", "光能", "风能", "距离", "定位" } : new string[8] { "恒星系", "星球", "类型", "海洋", "光能", "风能", "距离", "定位" });
			float[] array2 = (flag ? baseColWidthsGlobal : baseColWidthsNormal);
			Rect rect = GUILayoutUtility.GetRect(10f, 30f);
			float num = ((Rect)(ref rect)).x;
			if (!flag)
			{
				num += 20f;
			}
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i];
				bool num2 = (flag ? (i >= 2) : (i >= 1));
				if (num2 && sortColumn == i)
				{
					text += (sortAscending ? " ▲" : " ▼");
				}
				if (num2)
				{
					if (GUI.Button(new Rect(num, ((Rect)(ref rect)).y, array2[i], 30f), text, headerStyle))
					{
						if (sortColumn == i)
						{
							sortAscending = !sortAscending;
						}
						else
						{
							sortColumn = i;
							sortAscending = true;
						}
						sortKeyMode = showVeinAmount;
						UpdateSortSummaries();
						SortByColumn(sortColumn, sortAscending);
					}
				}
				else
				{
					GUI.Label(new Rect(num, ((Rect)(ref rect)).y, array2[i], 30f), text, headerStyle);
				}
				num += array2[i];
			}
			for (int j = 0; j < gasNames.Length; j++)
			{
				string text2 = gasNames[j];
				int num3 = array.Length + j;
				if (sortColumn == num3)
				{
					text2 += (sortAscending ? " ▲" : " ▼");
				}
				if (GUI.Button(new Rect(num, ((Rect)(ref rect)).y, 96f, 30f), text2, headerStyle))
				{
					if (sortColumn == num3)
					{
						sortAscending = !sortAscending;
					}
					else
					{
						sortColumn = num3;
						sortAscending = true;
					}
					sortKeyMode = showVeinAmount;
					UpdateSortSummaries();
					SortByColumn(sortColumn, sortAscending);
				}
				num += 96f;
			}
			for (int k = 0; k < veinNames.Length; k++)
			{
				string text3 = veinNames[k];
				int num4 = array.Length + gasNames.Length + k;
				if (sortColumn == num4)
				{
					text3 += (sortAscending ? " ▲" : " ▼");
				}
				GUIContent val = ((k == 6) ? new GUIContent(text3, "石油按当前开采速率(/s,含矿物利用科技加成)显示与排序") : new GUIContent(text3));
				if (GUI.Button(new Rect(num, ((Rect)(ref rect)).y, 70f, 30f), val, headerStyle))
				{
					if (sortColumn == num4)
					{
						sortAscending = !sortAscending;
					}
					else
					{
						sortColumn = num4;
						sortAscending = true;
					}
					sortKeyMode = showVeinAmount;
					UpdateSortSummaries();
					SortByColumn(sortColumn, sortAscending);
				}
				num += 70f;
			}
			if (rowsDirty)
			{
				BuildFlatRows();
			}
			scrollPosition = GUILayout.BeginScrollView(scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			float num5 = (float)flatRows.Count * 30f;
			Rect rect2 = GUILayoutUtility.GetRect(10f, num5);
			int num6 = Mathf.Max(0, (int)(scrollPosition.y / 30f) - 1);
			int num7 = 33;
			int num8 = Mathf.Min(flatRows.Count, num6 + num7);
			try
			{
				for (int l = num6; l < num8; l++)
				{
					float y = ((Rect)(ref rect2)).y + (float)l * 30f;
					TableRow tableRow = flatRows[l];
					if (tableRow.isStar)
					{
						DrawStarRowGUI(tableRow.starGroup, y, flag);
					}
					else
					{
						DrawPlanetRowGUI(tableRow.planet, y, flag);
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PlanetExplorer] 渲染行出错: " + ex.Message + "\n" + ex.StackTrace));
			}
			GUILayout.EndScrollView();
		}

		private void DrawStarRowGUI(StarGroup group, float y, bool globalMode)
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			//IL_0128: 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)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			float[] array = (globalMode ? baseColWidthsGlobal : baseColWidthsNormal);
			int num2 = 0;
			if (!globalMode)
			{
				if (viewMode == 0 && GUI.Button(new Rect(num, y, 20f, 30f), group.expanded ? "▼" : "▶"))
				{
					group.expanded = !group.expanded;
					rowsDirty = true;
				}
				num += 20f;
			}
			string text = "恒星系: " + group.starName + "(行星 " + group.planets.Count + " 颗)";
			GUI.Label(new Rect(num, y, array[num2], 30f), new GUIContent("★ " + group.starName + " (" + group.planets.Count + ")", text), boldLeftCellStyle);
			num += array[num2];
			num2++;
			GUI.Label(new Rect(num, y, array[num2], 30f), group.starType, cellStyle);
			num += array[num2];
			num2++;
			GUI.Label(new Rect(num, y, array[num2], 30f), "-", cellStyle);
			num += array[num2];
			num2++;
			GUI.Label(new Rect(num, y, array[num2], 30f), "", cellStyle);
			num += array[num2];
			num2++;
			GUI.Label(new Rect(num, y, array[num2], 30f), "", cellStyle);
			num += array[num2];
			num2++;
			string text2 = ((group.planets.Count > 0 && group.planets[0].cachedDistance != null) ? group.planets[0].cachedDistance : "-");
			GUI.Label(new Rect(num, y, array[num2], 30f), text2, cellStyle);
			num += array[num2];
			num2++;
			if (group.planets.Count > 0)
			{
				if (GUI.Button(new Rect(num, y, array[num2], 30f), "\ud83d\udccd"))
				{
					PlanetNavigator.NavigateToPlanet(group.planets[0].planetId);
				}
			}
			else
			{
				GUI.Label(new Rect(num, y, array[num2], 30f), "-", cellStyle);
			}
			num += array[num2];
			num2++;
			for (int i = 0; i < gasNames.Length; i++)
			{
				GUI.Label(new Rect(num, y, 96f, 30f), group.gasSummaryText[i], boldCellStyle);
				num += 96f;
			}
			for (int j = 0; j < veinNames.Length; j++)
			{
				GUI.Label(new Rect(num, y, 70f, 30f), group.veinSummaryText[j], boldCellStyle);
				num += 70f;
			}
		}

		private void DrawPlanetRowGUI(PlanetInfo planet, float y, bool globalMode)
		{
			//IL_006f: 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_009a: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_005b: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			float[] array = (globalMode ? baseColWidthsGlobal : baseColWidthsNormal);
			int num2 = 0;
			if (!globalMode)
			{
				num += 20f;
			}
			if (globalMode)
			{
				GUI.Label(new Rect(num, y, array[num2], 30f), new GUIContent(planet.starName, "恒星系: " + planet.starName), cellStyle);
				num += array[num2];
				num2++;
			}
			GUI.Label(new Rect(num, y, array[num2], 30f), new GUIContent(planet.planetName, "星球: " + planet.planetName), leftCellStyle);
			num += array[num2];
			num2++;
			GUI.Label(new Rect(num, y, array[num2], 30f), planet.planetType, cellStyle);
			num += array[num2];
			num2++;
			GUI.Label(new Rect(num, y, array[num2], 30f), planet.oceanType ?? "-", cellStyle);
			num += array[num2];
			num2++;
			GUI.Label(new Rect(num, y, array[num2], 30f), planet.cachedLuminosity ?? FormatEnergyPercent(planet.luminosity), (planet.luminosity > 1.499f) ? energyHighlightStyle : cellStyle);
			num += array[num2];
			num2++;
			GUI.Label(new Rect(num, y, array[num2], 30f), planet.cachedWind ?? FormatEnergyPercent(planet.windStrength), (planet.windStrength > 1.499f) ? energyHighlightStyle : cellStyle);
			num += array[num2];
			num2++;
			GUI.Label(new Rect(num, y, array[num2], 30f), planet.cachedDistance ?? (planet.distanceToBirth.ToString("F2") + "ly"), cellStyle);
			num += array[num2];
			num2++;
			if (GUI.Button(new Rect(num, y, array[num2], 30f), "\ud83d\udccd"))
			{
				PlanetNavigator.NavigateToPlanet(planet.planetId);
			}
			num += array[num2];
			num2++;
			for (int i = 0; i < gasNames.Length; i++)
			{
				string text = ((planet.cachedGasTexts != null) ? planet.cachedGasTexts[i] : "-");
				GUIStyle val = ((text != "-" && text != null) ? boldCellStyle : cellStyle);
				GUI.Label(new Rect(num, y, 96f, 30f), text, val);
				num += 96f;
			}
			for (int j = 0; j < veinNames.Length; j++)
			{
				string text2 = ((planet.cachedVeinTexts != null) ? planet.cachedVeinTexts[j] : "-");
				GUIStyle val2 = ((text2 != "-" && text2 != null) ? boldCellStyle : cellStyle);
				GUI.Label(new Rect(num, y, 70f, 30f), text2, val2);
				num += 70f;
			}
		}

		private void SortByColumn(int col, bool asc)
		{
			int num = ((viewMode == 2) ? 8 : 7);
			int num2 = gasNames.Length;
			Func<PlanetInfo, object> func = null;
			Func<StarGroup, object> func2 = null;
			if (col < num)
			{
				if (viewMode == 2)
				{
					switch (col)
					{
					case 0:
						func = (PlanetInfo p) => p.starName;
						break;
					case 1:
						func = (PlanetInfo p) => p.planetName;
						break;
					case 2:
						func = (PlanetInfo p) => p.planetType;
						break;
					case 3:
						func = (PlanetInfo p) => p.oceanType;
						break;
					case 4:
						func = (PlanetInfo p) => p.luminosity;
						break;
					case 5:
						func = (PlanetInfo p) => p.windStrength;
						break;
					case 6:
						func = (PlanetInfo p) => p.distanceToBirth;
						break;
					}
				}
				else
				{
					switch (col)
					{
					case 0:
						func = (PlanetInfo p) => p.planetName;
						func2 = (StarGroup g) => g.starName;
						break;
					case 1:
						func = (PlanetInfo p) => p.planetType;
						func2 = (StarGroup g) => g.starType;
						break;
					case 2:
						func = (PlanetInfo p) => p.oceanType;
						break;
					case 3:
						func = (PlanetInfo p) => p.luminosity;
						func2 = (StarGroup g) => g.starLuminosity;
						break;
					case 4:
						func = (PlanetInfo p) => p.windStrength;
						break;
					case 5:
						func = (PlanetInfo p) => p.distanceToBirth;
						func2 = (StarGroup g) => (g.planets.Count > 0) ? g.planets[0].distanceToBirth : 0.0;
						break;
					}
				}
			}
			else if (col < num + num2)
			{
				int num3 = col - num;
				if (num3 >= 0 && num3 < gasIds.Length)
				{
					int gid = gasIds[num3];
					func = (PlanetInfo p) => p.gasSpeeds.ContainsKey(gid) ? p.gasSpeeds[gid] : 0f;
					int gi = num3;
					func2 = (StarGroup g) => g.gasSummary[gi];
				}
			}
			else
			{
				int num4 = col - num - num2;
				if (num4 >= 0 && num4 < veinIds.Length)
				{
					int vid = veinIds[num4];
					int vi = num4;
					if (num4 != 6)
					{
						func = ((!sortKeyMode) ? ((Func<PlanetInfo, object>)((PlanetInfo p) => p.veinCounts.ContainsKey(vid) ? p.veinCounts[vid] : 0)) : ((Func<PlanetInfo, object>)((PlanetInfo p) => p.veinAmounts.ContainsKey(vid) ? p.veinAmounts[vid] : 0)));
					}
					else
					{
						func = (PlanetInfo p) => GetOilRate(p);
						func2 = (StarGroup g) => g.oilRateSummarySort;
					}
					if (func2 == null)
					{
						func2 = (StarGroup g) => g.veinSummarySort[vi];
					}
				}
			}
			if (func == null && func2 == null)
			{
				return;
			}
			if (viewMode == 2)
			{
				if (func != null)
				{
					List<PlanetInfo> list = allPlanets.OrderBy(func).ToList();
					if (!asc)
					{
						list.Reverse();
					}
					allPlanets = list;
					BuildStarGroups();
				}
			}
			else if (viewMode == 1)
			{
				if (func2 != null)
				{
					List<StarGroup> list2 = starGroups.OrderBy(func2).ToList();
					if (!asc)
					{
						list2.Reverse();
					}
					starGroups = list2;
				}
			}
			else
			{
				if (func2 != null)
				{
					List<StarGroup> list3 = starGroups.OrderBy(func2).ToList();
					if (!asc)
					{
						list3.Reverse();
					}
					starGroups = list3;
				}
				if (func != null)
				{
					foreach (StarGroup starGroup in starGroups)
					{
						List<PlanetInfo> list4 = starGroup.planets.OrderBy(func).ToList();
						if (!asc)
						{
							list4.Reverse();
						}
						starGroup.planets = list4;
					}
				}
			}
			rowsDirty = true;
		}

		private void DrawStatusBar()
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
			string arg = "";
			try
			{
				if ((Object)(object)GameMain.instance != (Object)null && GameMain.galaxy != null)
				{
					arg = " | 宇宙观测Lv." + GameMain.history.universeObserveLevel + " | 未扫描星系" + GameMain.galaxy.unscannedStarCount;
				}
			}
			catch
			{
			}
			GUILayout.Label(string.Format("数据: {0} | {1}开关 | 点击列标题排序 | \ud83d\udccd定位星球{2}", dataLoaded ? "已加载" : "未加载", PlanetExplorerPlugin.toggleKey.Value, arg), Array.Empty<GUILayoutOption>());
			string tooltip = GUI.tooltip;
			GUILayout.Label(string.IsNullOrEmpty(tooltip) ? "" : tooltip, tipStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
		}

		private string[] GetAllSortColumnNames()
		{
			List<string> list = new List<string>();
			list.Add("恒星系");
			list.Add("行星名");
			list.Add("类型");
			list.Add("海洋");
			list.Add("光能");
			list.Add("风能");
			list.Add("距离");
			string[] array = gasNames;
			foreach (string text in array)
			{
				list.Add("气体:" + text);
			}
			array = veinNames;
			foreach (string text2 in array)
			{
				list.Add("矿物:" + text2);
			}
			return list.ToArray();
		}

		private Func<PlanetInfo, object> GetKeySelectorForGlobalCol(int globalCol)
		{
			if (globalCol <= 6)
			{
				switch (globalCol)
				{
				case 0:
					return (PlanetInfo p) => p.starName;
				case 1:
					return (PlanetInfo p) => p.planetName;
				case 2:
					return (PlanetInfo p) => p.planetType;
				case 3:
					return (PlanetInfo p) => p.oceanType;
				case 4:
					return (PlanetInfo p) => p.luminosity;
				case 5:
					return (PlanetInfo p) => p.windStrength;
				case 6:
					return (PlanetInfo p) => p.distanceToBirth;
				}
			}
			else if (globalCol <= 9)
			{
				int num = globalCol - 7;
				if (num >= 0 && num < gasIds.Length)
				{
					int gid = gasIds[num];
					return (PlanetInfo p) => p.gasSpeeds.ContainsKey(gid) ? p.gasSpeeds[gid] : 0f;
				}
			}
			else
			{
				int num2 = globalCol - 10;
				if (num2 >= 0 && num2 < veinIds.Length)
				{
					int vid = veinIds[num2];
					if (num2 == 6)
					{
						return (PlanetInfo p) => GetOilRate(p);
					}
					if (showVeinAmount)
					{
						return (PlanetInfo p) => p.veinAmounts.ContainsKey(vid) ? p.veinAmounts[vid] : 0;
					}
					return (PlanetInfo p) => p.veinCounts.ContainsKey(vid) ? p.veinCounts[vid] : 0;
				}
			}
			return null;
		}

		private void DrawSortPanel(int windowID)
		{
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.Label("当前排序条件(按优先级从上到下):", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) });
			for (int i = 0; i < sortConditions.Count; i++)
			{
				SortCondition sortCondition = sortConditions[i];
				GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
				GUILayout.Label($"{i + 1}.", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(25f) });
				GUILayout.Label(sortCondition.columnName, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) });
				if (GUILayout.Button(sortCondition.ascending ? "升序 ▲" : "降序 ▼", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }))
				{
					sortCondition.ascending = !sortCondition.ascending;
				}
				if (GUILayout.Button("↑", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }) && i > 0)
				{
					SortCondition value = sortConditions[i];
					sortConditions[i] = sortConditions[i - 1];
					sortConditions[i - 1] = value;
				}
				if (GUILayout.Button("↓", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) }) && i < sortConditions.Count - 1)
				{
					SortCondition value2 = sortConditions[i];
					sortConditions[i] = sortConditions[i + 1];
					sortConditions[i + 1] = value2;
				}
				if (GUILayout.Button("删除", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
				{
					sortConditions.RemoveAt(i);
					i--;
				}
				else
				{
					GUILayout.EndHorizontal();
				}
			}
			if (sortConditions.Count == 0)
			{
				GUILayout.Label("(暂无排序条件,点击下方列表添加)", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) });
			}
			GUILayout.Space(10f);
			GUILayout.Label("点击列名添加排序条件:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) });
			string[] allSortColumn