Decompiled source of CruiseAssistor v0.1.40

CruiseAssistor.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CruiseAssistor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CruiseAssistor")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9cdb5e0f-fb97-46ff-a4fb-a9a400443fd3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace tanu.CruiseAssist;

public class ListUtils
{
	public static string ToString(List<int> list)
	{
		if (list == null || list.Count == 0)
		{
			return "";
		}
		return list.Select((int id) => id.ToString()).Aggregate((string a, string b) => a + "," + b);
	}

	public static string ToString(List<string> list)
	{
		if (list == null || list.Count == 0)
		{
			return "";
		}
		return list.Aggregate((string a, string b) => a + "," + b);
	}

	public static List<int> ParseToIntList(string str)
	{
		if (str == null || str.Length == 0)
		{
			return new List<int>();
		}
		int result;
		return (from s in str.Split(new char[1] { ',' })
			where int.TryParse(s, out result)
			select s).Select(int.Parse).ToList();
	}

	public static List<string> ParseToStringList(string str)
	{
		if (str == null || str.Length == 0)
		{
			return new List<string>();
		}
		return str.Split(new char[1] { ',' }).ToList();
	}
}
public static class MyLogger
{
	public static string LogString = "";

	private static int _logStringMaxLength = 2000;

	public static void LogToGame(string message)
	{
		string text = "\r\n" + message;
		if (LogString.Length + text.Length > _logStringMaxLength)
		{
			int startIndex = LogString.Length + text.Length - _logStringMaxLength;
			LogString = LogString.Substring(startIndex);
		}
		LogString += text;
	}

	public static void LogMessageToFile(string message, string filePath = "MyDspLog.txt")
	{
		using StreamWriter streamWriter = new StreamWriter(filePath, append: true);
		streamWriter.WriteLine($"[{DateTime.Now}] Message :");
		streamWriter.WriteLine(message ?? "");
	}

	public static void LogExceptionToFile(Exception ex, string filePath = "MyDspLog.txt")
	{
		using StreamWriter streamWriter = new StreamWriter(filePath, append: true);
		streamWriter.WriteLine($"[{DateTime.Now}] An exception occurred:");
		streamWriter.WriteLine("Message: " + ex.Message);
		if (!string.IsNullOrEmpty(ex.StackTrace))
		{
			string[] array = ex.StackTrace.Split(new string[1] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length != 0)
			{
				string text = array[0];
				int num = text.LastIndexOf(" in ");
				if (num != -1)
				{
					string text2 = text.Substring(num + 4);
					streamWriter.WriteLine("File and Line: " + text2);
				}
			}
		}
		streamWriter.WriteLine("StackTrace: " + ex.StackTrace);
		if (ex.TargetSite != null)
		{
			streamWriter.WriteLine($"TargetSite: {ex.TargetSite}");
		}
		if (ex.Data.Count > 0)
		{
			streamWriter.WriteLine("Additional Information:");
			foreach (object key in ex.Data.Keys)
			{
				streamWriter.WriteLine($"- {key}: {ex.Data[key]}");
			}
		}
		streamWriter.WriteLine();
	}
}
public class CruiseAssistorConfigManager : ConfigManager
{
	public CruiseAssistorConfigManager(ConfigFile Config)
		: base(Config)
	{
	}

	protected override void CheckConfigImplements(Step step)
	{
		bool flag = false;
		if (step == Step.AWAKE)
		{
			ConfigManager.Bind("Base", "ModVersion", "0.1.40", "Don't change.").Value = "0.1.40";
			ConfigManager.Migration("State", "MainWindow0Left", 100, "State", "InfoWindowLeft");
			ConfigManager.Migration("State", "MainWindow0Top", 100, "State", "InfoWindowTop");
			ConfigManager.Migration("State", "MainWindow0Left", 100, "State", "MainWindowLeft");
			ConfigManager.Migration("State", "MainWindow0Top", 100, "State", "MainWindowTop");
			ConfigManager.Migration("State", "StarListWindow0Left", 100, "State", "StarListWindowLeft");
			ConfigManager.Migration("State", "StarListWindow0Top", 100, "State", "StarListWindowTop");
			flag = true;
		}
		switch (step)
		{
		case Step.AWAKE:
		case Step.GAME_MAIN_BEGIN:
		{
			CruiseAssistorDebugUI.Show = ConfigManager.Bind("Debug", "DebugWindowShow", defaultValue: false).Value;
			CruiseAssistor.Enabled = ConfigManager.Bind("Setting", "Enable", defaultValue: true).Value;
			CruiseAssistor.MarkVisitedFlag = ConfigManager.Bind("Setting", "MarkVisited", defaultValue: true).Value;
			CruiseAssistor.SelectFocusFlag = ConfigManager.Bind("Setting", "SelectFocus", defaultValue: true).Value;
			CruiseAssistor.HideDuplicateHistoryFlag = ConfigManager.Bind("Setting", "HideDuplicateHistory", defaultValue: true).Value;
			CruiseAssistor.AutoDisableLockCursorFlag = ConfigManager.Bind("Setting", "AutoDisableLockCursor", defaultValue: false).Value;
			CruiseAssistorMainUI.Scale = ConfigManager.Bind("Setting", "UIScale", 150).Value;
			EnumUtils.TryParse<CruiseAssistMainUIViewMode>(ConfigManager.Bind("Setting", "MainWindowViewMode", CruiseAssistMainUIViewMode.FULL.ToString()).Value, out CruiseAssistorMainUI.ViewMode);
			for (int j = 0; j < 2; j++)
			{
				((Rect)(ref CruiseAssistorMainUI.Rect[j])).x = ConfigManager.Bind("State", $"MainWindow{j}Left", 100).Value;
				((Rect)(ref CruiseAssistorMainUI.Rect[j])).y = ConfigManager.Bind("State", $"MainWindow{j}Top", 100).Value;
				((Rect)(ref CruiseAssistorStarListUI.Rect[j])).x = ConfigManager.Bind("State", $"StarListWindow{j}Left", 100).Value;
				((Rect)(ref CruiseAssistorStarListUI.Rect[j])).y = ConfigManager.Bind("State", $"StarListWindow{j}Top", 100).Value;
				((Rect)(ref CruiseAssistorConfigUI.Rect[j])).x = ConfigManager.Bind("State", $"ConfigWindow{j}Left", 100).Value;
				((Rect)(ref CruiseAssistorConfigUI.Rect[j])).y = ConfigManager.Bind("State", $"ConfigWindow{j}Top", 100).Value;
			}
			CruiseAssistorStarListUI.ListSelected = ConfigManager.Bind("State", "StarListWindowListSelected", 0).Value;
			((Rect)(ref CruiseAssistorDebugUI.Rect)).x = ConfigManager.Bind("State", "DebugWindowLeft", 100).Value;
			((Rect)(ref CruiseAssistorDebugUI.Rect)).y = ConfigManager.Bind("State", "DebugWindowTop", 100).Value;
			if (!DSPGame.IsMenuDemo && GameMain.galaxy != null)
			{
				CruiseAssistor.History = ListUtils.ParseToIntList(ConfigManager.Bind("Save", $"History_{GameMain.galaxy.seed}", "").Value);
				CruiseAssistor.Bookmark = ListUtils.ParseToIntList(ConfigManager.Bind("Save", $"Bookmark_{GameMain.galaxy.seed}", "").Value);
			}
			else
			{
				CruiseAssistor.History = new List<int>();
				CruiseAssistor.Bookmark = new List<int>();
			}
			break;
		}
		case Step.STATE:
		{
			LogManager.LogInfo("check state.");
			flag |= ConfigManager.UpdateEntry("Setting", "Enable", CruiseAssistor.Enabled);
			flag |= ConfigManager.UpdateEntry("Setting", "MarkVisited", CruiseAssistor.MarkVisitedFlag);
			flag |= ConfigManager.UpdateEntry("Setting", "SelectFocus", CruiseAssistor.SelectFocusFlag);
			flag |= ConfigManager.UpdateEntry("Setting", "HideDuplicateHistory", CruiseAssistor.HideDuplicateHistoryFlag);
			flag |= ConfigManager.UpdateEntry("Setting", "AutoDisableLockCursor", CruiseAssistor.AutoDisableLockCursorFlag);
			flag |= ConfigManager.UpdateEntry("Setting", "UIScale", (int)CruiseAssistorMainUI.Scale);
			flag |= ConfigManager.UpdateEntry("Setting", "MainWindowViewMode", CruiseAssistorMainUI.ViewMode.ToString());
			for (int i = 0; i < 2; i++)
			{
				flag |= ConfigManager.UpdateEntry("State", $"MainWindow{i}Left", (int)((Rect)(ref CruiseAssistorMainUI.Rect[i])).x);
				flag |= ConfigManager.UpdateEntry("State", $"MainWindow{i}Top", (int)((Rect)(ref CruiseAssistorMainUI.Rect[i])).y);
				flag |= ConfigManager.UpdateEntry("State", $"StarListWindow{i}Left", (int)((Rect)(ref CruiseAssistorStarListUI.Rect[i])).x);
				flag |= ConfigManager.UpdateEntry("State", $"StarListWindow{i}Top", (int)((Rect)(ref CruiseAssistorStarListUI.Rect[i])).y);
				flag |= ConfigManager.UpdateEntry("State", $"ConfigWindow{i}Left", (int)((Rect)(ref CruiseAssistorConfigUI.Rect[i])).x);
				flag |= ConfigManager.UpdateEntry("State", $"ConfigWindow{i}Top", (int)((Rect)(ref CruiseAssistorConfigUI.Rect[i])).y);
			}
			flag |= ConfigManager.UpdateEntry("State", "StarListWindowListSelected", CruiseAssistorStarListUI.ListSelected);
			flag |= ConfigManager.UpdateEntry("State", "DebugWindowLeft", (int)((Rect)(ref CruiseAssistorDebugUI.Rect)).x);
			flag |= ConfigManager.UpdateEntry("State", "DebugWindowTop", (int)((Rect)(ref CruiseAssistorDebugUI.Rect)).y);
			if (!DSPGame.IsMenuDemo && GameMain.galaxy != null)
			{
				if (!ConfigManager.ContainsKey("Save", $"History_{GameMain.galaxy.seed}") || !ConfigManager.ContainsKey("Save", $"Bookmark_{GameMain.galaxy.seed}"))
				{
					ConfigManager.Bind("Save", $"History_{GameMain.galaxy.seed}", "");
					ConfigManager.Bind("Save", $"Bookmark_{GameMain.galaxy.seed}", "");
					flag = true;
				}
				flag |= ConfigManager.UpdateEntry("Save", $"History_{GameMain.galaxy.seed}", ListUtils.ToString(CruiseAssistor.History));
				flag |= ConfigManager.UpdateEntry("Save", $"Bookmark_{GameMain.galaxy.seed}", ListUtils.ToString(CruiseAssistor.Bookmark));
			}
			CruiseAssistorMainUI.NextCheckGameTick = long.MaxValue;
			break;
		}
		}
		if (flag)
		{
			ConfigManager.Save();
		}
	}
}
[BepInPlugin("OFark.CruiseAssistor", "CruiseAssist", "0.1.40")]
public class CruiseAssistor : BaseUnityPlugin
{
	public const string ModGuid = "OFark.CruiseAssistor";

	public const string ModName = "CruiseAssist";

	public const string ModVersion = "0.1.40";

	public static bool Enabled = true;

	public static bool MarkVisitedFlag = true;

	public static bool SelectFocusFlag = false;

	public static bool HideDuplicateHistoryFlag = true;

	public static bool AutoDisableLockCursorFlag = false;

	public static StarData ReticuleTargetStar = null;

	public static PlanetData ReticuleTargetPlanet = null;

	public static StarData SelectTargetStar = null;

	public static PlanetData SelectTargetPlanet = null;

	public static int SelectTargetAstroId = 0;

	public static int SelectTargetEnemyId = 0;

	public static StarData TargetStar = null;

	public static PlanetData TargetPlanet = null;

	public static EnemyData? TargetEnemy = null;

	public static CruiseAssistState State = CruiseAssistState.INACTIVE;

	public static List<int> History = new List<int>();

	public static List<int> Bookmark = new List<int>();

	public static Func<StarData, string> GetStarName = (StarData star) => star.displayName;

	public static Func<PlanetData, string> GetPlanetName = (PlanetData planet) => planet.displayName;

	private Harmony harmony;

	public void Awake()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		LogManager.Logger = ((BaseUnityPlugin)this).Logger;
		new CruiseAssistorConfigManager(((BaseUnityPlugin)this).Config);
		ConfigManager.CheckConfig(ConfigManager.Step.AWAKE);
		harmony = new Harmony("OFark.CruiseAssistor.Patch");
		harmony.PatchAll(typeof(Patch_GameMain));
		harmony.PatchAll(typeof(Patch_UISailPanel));
		harmony.PatchAll(typeof(Patch_UIStarmap));
		harmony.PatchAll(typeof(Patch_PlayerMoveSail));
	}

	public void OnDestroy()
	{
		harmony.UnpatchAll((string)null);
	}

	public void OnGUI()
	{
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		if (DSPGame.IsMenuDemo || GameMain.mainPlayer == null)
		{
			return;
		}
		UIGame uiGame = UIRoot.instance.uiGame;
		if (uiGame.guideComplete && !((ManualBehaviour)uiGame.techTree).active && !((ManualBehaviour)uiGame.escMenu).active && !((ManualBehaviour)uiGame.globemap).active && !uiGame.hideAllUI0 && !uiGame.hideAllUI1 && (GameMain.mainPlayer.sailing || ((ManualBehaviour)uiGame.starmap).active))
		{
			Check();
			CruiseAssistorMainUI.wIdx = (((ManualBehaviour)uiGame.starmap).active ? 1 : 0);
			float num = CruiseAssistorMainUI.Scale / 100f;
			GUIUtility.ScaleAroundPivot(new Vector2(num, num), Vector2.zero);
			CruiseAssistorMainUI.OnGUI();
			if (CruiseAssistorStarListUI.Show[CruiseAssistorMainUI.wIdx])
			{
				CruiseAssistorStarListUI.OnGUI();
			}
			if (CruiseAssistorConfigUI.Show[CruiseAssistorMainUI.wIdx])
			{
				CruiseAssistorConfigUI.OnGUI();
			}
			if (CruiseAssistorDebugUI.Show)
			{
				CruiseAssistorDebugUI.OnGUI();
			}
			bool flag = false;
			flag = ResetInput(CruiseAssistorMainUI.Rect[CruiseAssistorMainUI.wIdx], num);
			if (!flag && CruiseAssistorStarListUI.Show[CruiseAssistorMainUI.wIdx])
			{
				flag = ResetInput(CruiseAssistorStarListUI.Rect[CruiseAssistorMainUI.wIdx], num);
			}
			if (!flag && CruiseAssistorConfigUI.Show[CruiseAssistorMainUI.wIdx])
			{
				flag = ResetInput(CruiseAssistorConfigUI.Rect[CruiseAssistorMainUI.wIdx], num);
			}
			if (!flag && CruiseAssistorDebugUI.Show)
			{
				flag = ResetInput(CruiseAssistorDebugUI.Rect, num);
			}
		}
	}

	private void Check()
	{
		try
		{
			int indicatorAstroId = GameMain.mainPlayer.navigation.indicatorAstroId;
			int indicatorEnemyId = GameMain.mainPlayer.navigation.indicatorEnemyId;
			if (SelectTargetAstroId != indicatorAstroId)
			{
				SelectTargetAstroId = indicatorAstroId;
				if (indicatorAstroId % 100 != 0)
				{
					SelectTargetPlanet = GameMain.galaxy.PlanetById(indicatorAstroId);
					SelectTargetStar = SelectTargetPlanet.star;
				}
				else
				{
					SelectTargetPlanet = null;
					SelectTargetStar = GameMain.galaxy.StarById(indicatorAstroId / 100);
				}
			}
			if (SelectTargetEnemyId != indicatorEnemyId)
			{
				SelectTargetEnemyId = indicatorEnemyId;
			}
			if (GameMain.localPlanet != null && (History.Count == 0 || History.Last() != GameMain.localPlanet.id))
			{
				if (History.Count >= 128)
				{
					History.RemoveAt(0);
				}
				History.Add(GameMain.localPlanet.id);
				ConfigManager.CheckConfig(ConfigManager.Step.STATE);
			}
		}
		catch (Exception ex)
		{
			MyLogger.LogToGame(ex.Message);
		}
	}

	private bool ResetInput(Rect rect, float scale)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		float num = ((Rect)(ref rect)).xMin * scale;
		float num2 = ((Rect)(ref rect)).xMax * scale;
		float num3 = ((Rect)(ref rect)).yMin * scale;
		float num4 = ((Rect)(ref rect)).yMax * scale;
		float x = Input.mousePosition.x;
		float num5 = (float)Screen.height - Input.mousePosition.y;
		if (num <= x && x <= num2 && num3 <= num5 && num5 <= num4 && (((IEnumerable<int>)new int[3] { 0, 1, 2 }).Any((Func<int, bool>)Input.GetMouseButton) || Input.mouseScrollDelta.y != 0f))
		{
			Input.ResetInputAxes();
			return true;
		}
		return false;
	}
}
public abstract class ConfigManager
{
	public enum Step
	{
		AWAKE,
		GAME_MAIN_BEGIN,
		UNIVERSE_GEN_CREATE_GALAXY,
		STATE
	}

	private static ConfigManager instance;

	private static Dictionary<ConfigDefinition, string> orphanedEntries;

	public static ConfigFile Config { get; private set; }

	protected ConfigManager(ConfigFile config)
	{
		instance = this;
		Config = config;
		Config.SaveOnConfigSet = false;
	}

	public static void CheckConfig(Step step)
	{
		instance.CheckConfigImplements(step);
	}

	protected abstract void CheckConfigImplements(Step step);

	public static ConfigEntry<T> Bind<T>(ConfigDefinition configDefinition, T defaultValue, ConfigDescription configDescription = null)
	{
		return Config.Bind<T>(configDefinition, defaultValue, configDescription);
	}

	public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, ConfigDescription configDescription = null)
	{
		return Config.Bind<T>(section, key, defaultValue, configDescription);
	}

	public static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description)
	{
		return Config.Bind<T>(section, key, defaultValue, description);
	}

	public static ConfigEntry<T> GetEntry<T>(ConfigDefinition configDefinition)
	{
		try
		{
			return (ConfigEntry<T>)(object)Config[configDefinition];
		}
		catch (KeyNotFoundException ex)
		{
			LogManager.LogError($"{ex.GetType()}: configDefinition={configDefinition}");
			throw;
		}
	}

	public static ConfigEntry<T> GetEntry<T>(string section, string key)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		return GetEntry<T>(new ConfigDefinition(section, key));
	}

	public static T GetValue<T>(ConfigDefinition configDefinition)
	{
		return GetEntry<T>(configDefinition).Value;
	}

	public static T GetValue<T>(string section, string key)
	{
		return GetEntry<T>(section, key).Value;
	}

	public static bool ContainsKey(ConfigDefinition configDefinition)
	{
		return Config.ContainsKey(configDefinition);
	}

	public static bool ContainsKey(string section, string key)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		return Config.ContainsKey(new ConfigDefinition(section, key));
	}

	public static bool UpdateEntry<T>(string section, string key, T value) where T : IComparable
	{
		ConfigEntry<T> entry = GetEntry<T>(section, key);
		if (entry.Value.CompareTo(value) == 0)
		{
			return false;
		}
		entry.Value = value;
		return true;
	}

	public static bool RemoveEntry(ConfigDefinition key)
	{
		return Config.Remove(key);
	}

	public static Dictionary<ConfigDefinition, string> GetOrphanedEntries()
	{
		if (orphanedEntries == null)
		{
			orphanedEntries = Traverse.Create((object)Config).Property<Dictionary<ConfigDefinition, string>>("OrphanedEntries", (object[])null).Value;
		}
		return orphanedEntries;
	}

	public static void Migration<T>(string newSection, string newKey, T defaultValue, string oldSection, string oldKey)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		GetOrphanedEntries();
		ConfigDefinition key = new ConfigDefinition(oldSection, oldKey);
		if (orphanedEntries.TryGetValue(key, out var value))
		{
			((ConfigEntryBase)Bind(newSection, newKey, defaultValue)).SetSerializedValue(value);
			orphanedEntries.Remove(key);
			LogManager.LogInfo("migration " + oldSection + "." + oldKey + "(" + value + ") => " + newSection + "." + newKey);
		}
	}

	public static void Save(bool clearOrphanedEntries = false)
	{
		if (clearOrphanedEntries)
		{
			GetOrphanedEntries().Clear();
		}
		Config.Save();
		LogManager.LogInfo("save config.");
	}
}
[HarmonyPatch(typeof(UIStarmap))]
public class Patch_UIStarmap
{
	[HarmonyPatch("_OnClose")]
	[HarmonyPrefix]
	public static void OnClose_Prefix()
	{
		ConfigManager.CheckConfig(ConfigManager.Step.STATE);
	}
}
[HarmonyPatch(typeof(UITechTree))]
public class Patch_UITechTree
{
	[HarmonyPatch("_OnOpen")]
	[HarmonyPrefix]
	public static void OnOpen_Prefix()
	{
		ConfigManager.CheckConfig(ConfigManager.Step.STATE);
	}
}
public class CruiseAssistorConfigUI
{
	private static int wIdx = 0;

	public const float WindowWidth = 400f;

	public const float WindowHeight = 400f;

	public static bool[] Show = new bool[2];

	public static Rect[] Rect = (Rect[])(object)new Rect[2]
	{
		new Rect(0f, 0f, 400f, 400f),
		new Rect(0f, 0f, 400f, 400f)
	};

	private static float lastCheckWindowLeft = float.MinValue;

	private static float lastCheckWindowTop = float.MinValue;

	public static float TempScale = 150f;

	public static void OnGUI()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		wIdx = CruiseAssistorMainUI.wIdx;
		GUIStyle val = new GUIStyle(GUI.skin.window);
		val.fontSize = 11;
		Rect[wIdx] = GUILayout.Window(99030293, Rect[wIdx], new WindowFunction(WindowFunction), "Cruise Assistor - Config", val, Array.Empty<GUILayoutOption>());
		float num = CruiseAssistorMainUI.Scale / 100f;
		if ((float)Screen.width / num < ((Rect)(ref Rect[wIdx])).xMax)
		{
			((Rect)(ref Rect[wIdx])).x = (float)Screen.width / num - ((Rect)(ref Rect[wIdx])).width;
		}
		if (((Rect)(ref Rect[wIdx])).x < 0f)
		{
			((Rect)(ref Rect[wIdx])).x = 0f;
		}
		if ((float)Screen.height / num < ((Rect)(ref Rect[wIdx])).yMax)
		{
			((Rect)(ref Rect[wIdx])).y = (float)Screen.height / num - ((Rect)(ref Rect[wIdx])).height;
		}
		if (((Rect)(ref Rect[wIdx])).y < 0f)
		{
			((Rect)(ref Rect[wIdx])).y = 0f;
		}
		if (lastCheckWindowLeft != float.MinValue && (((Rect)(ref Rect[wIdx])).x != lastCheckWindowLeft || ((Rect)(ref Rect[wIdx])).y != lastCheckWindowTop))
		{
			CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
		}
		lastCheckWindowLeft = ((Rect)(ref Rect[wIdx])).x;
		lastCheckWindowTop = ((Rect)(ref Rect[wIdx])).y;
	}

	public static void WindowFunction(int windowId)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Expected O, but got Unknown
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Expected O, but got Unknown
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Expected O, but got Unknown
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Expected O, but got Unknown
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Expected O, but got Unknown
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Expected O, but got Unknown
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d0: Expected O, but got Unknown
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_0362: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b1: 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_0446: Expected O, but got Unknown
		//IL_0400: Unknown result type (might be due to invalid IL or missing references)
		//IL_0480: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUIStyle val = new GUIStyle(GUI.skin.label);
		val.fixedWidth = 120f;
		val.fixedHeight = 20f;
		val.fontSize = 12;
		val.alignment = (TextAnchor)3;
		GUILayout.Label("Main Window Style :", val, Array.Empty<GUILayoutOption>());
		GUIStyle val2 = new GUIStyle(GUI.skin.button);
		val2.fixedWidth = 80f;
		val2.fixedHeight = 20f;
		val2.fontSize = 12;
		string[] array = new string[2] { "FULL", "MINI" };
		int num = ((CruiseAssistorMainUI.ViewMode != CruiseAssistMainUIViewMode.FULL) ? 1 : 0);
		GUI.changed = false;
		int num2 = GUILayout.Toolbar(num, array, val2, Array.Empty<GUILayoutOption>());
		if (GUI.changed)
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
		}
		if (num2 != num)
		{
			switch (num2)
			{
			case 0:
				CruiseAssistorMainUI.ViewMode = CruiseAssistMainUIViewMode.FULL;
				break;
			case 1:
				CruiseAssistorMainUI.ViewMode = CruiseAssistMainUIViewMode.MINI;
				break;
			}
			CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUIStyle val3 = new GUIStyle(GUI.skin.label);
		val3.fixedWidth = 60f;
		val3.fixedHeight = 20f;
		val3.fontSize = 12;
		val3.alignment = (TextAnchor)3;
		GUILayout.Label("UI Scale :", val3, Array.Empty<GUILayoutOption>());
		GUIStyle val4 = new GUIStyle(GUI.skin.horizontalSlider);
		val4.fixedWidth = 180f;
		val4.margin.top = 10;
		val4.alignment = (TextAnchor)3;
		GUIStyle val5 = new GUIStyle(GUI.skin.horizontalSliderThumb);
		TempScale = GUILayout.HorizontalSlider(TempScale, 80f, 240f, val4, val5, Array.Empty<GUILayoutOption>());
		TempScale = (int)TempScale / 5 * 5;
		GUIStyle val6 = new GUIStyle(GUI.skin.label);
		val6.fixedWidth = 40f;
		val6.fixedHeight = 20f;
		val6.fontSize = 12;
		val6.alignment = (TextAnchor)3;
		GUILayout.Label(TempScale.ToString("0") + "%", val6, Array.Empty<GUILayoutOption>());
		GUIStyle val7 = new GUIStyle(GUI.skin.button);
		val7.fixedWidth = 60f;
		val7.fixedHeight = 18f;
		val7.margin.top = 6;
		val7.fontSize = 12;
		if (GUILayout.Button("SET", val7, Array.Empty<GUILayoutOption>()))
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			CruiseAssistorMainUI.Scale = TempScale;
			CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
		}
		GUILayout.EndHorizontal();
		GUIStyle val8 = new GUIStyle(GUI.skin.toggle);
		val8.fixedHeight = 20f;
		val8.fontSize = 12;
		GUI.changed = false;
		CruiseAssistor.MarkVisitedFlag = GUILayout.Toggle(CruiseAssistor.MarkVisitedFlag, "Mark the visited system and planet.", val8, Array.Empty<GUILayoutOption>());
		if (GUI.changed)
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
		}
		GUI.changed = false;
		CruiseAssistor.SelectFocusFlag = GUILayout.Toggle(CruiseAssistor.SelectFocusFlag, "Focus when target selected.", val8, Array.Empty<GUILayoutOption>());
		if (GUI.changed)
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
		}
		GUI.changed = false;
		CruiseAssistor.HideDuplicateHistoryFlag = GUILayout.Toggle(CruiseAssistor.HideDuplicateHistoryFlag, "Hide duplicate history.", val8, Array.Empty<GUILayoutOption>());
		if (GUI.changed)
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
		}
		GUI.changed = false;
		CruiseAssistor.AutoDisableLockCursorFlag = GUILayout.Toggle(CruiseAssistor.AutoDisableLockCursorFlag, "Disable lock cursor when starting sail mode.", val8, Array.Empty<GUILayoutOption>());
		if (GUI.changed)
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
		}
		GUILayout.FlexibleSpace();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.FlexibleSpace();
		GUIStyle val9 = new GUIStyle(GUI.skin.button);
		val9.fixedWidth = 80f;
		val9.fixedHeight = 20f;
		val9.fontSize = 12;
		if (GUILayout.Button("Close", val9, Array.Empty<GUILayoutOption>()))
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			Show[wIdx] = false;
		}
		GUILayout.EndHorizontal();
		GUILayout.EndVertical();
		GUI.DragWindow();
	}
}
public class CruiseAssistorDebugUI
{
	public static bool Show = false;

	public static Rect Rect = new Rect(0f, 0f, 400f, 400f);

	private static float lastCheckWindowLeft = float.MinValue;

	private static float lastCheckWindowTop = float.MinValue;

	private static long nextCheckGameTick = long.MaxValue;

	private static Vector2 scrollPos = Vector2.zero;

	public static int ListSelected = 0;

	public static void OnGUI()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		GUIStyle val = new GUIStyle(GUI.skin.window);
		val.fontSize = 11;
		Rect = GUILayout.Window(99030294, Rect, new WindowFunction(WindowFunction), "CruiseAssistor - Debug", val, Array.Empty<GUILayoutOption>());
		_ = CruiseAssistorMainUI.Scale / 100f;
		if ((float)Screen.width < ((Rect)(ref Rect)).xMax)
		{
			((Rect)(ref Rect)).x = (float)Screen.width - ((Rect)(ref Rect)).width;
		}
		if (((Rect)(ref Rect)).x < 0f)
		{
			((Rect)(ref Rect)).x = 0f;
		}
		if ((float)Screen.height < ((Rect)(ref Rect)).yMax)
		{
			((Rect)(ref Rect)).y = (float)Screen.height - ((Rect)(ref Rect)).height;
		}
		if (((Rect)(ref Rect)).y < 0f)
		{
			((Rect)(ref Rect)).y = 0f;
		}
		if (lastCheckWindowLeft != float.MinValue && (((Rect)(ref Rect)).x != lastCheckWindowLeft || ((Rect)(ref Rect)).y != lastCheckWindowTop))
		{
			nextCheckGameTick = GameMain.gameTick + 300;
		}
		lastCheckWindowLeft = ((Rect)(ref Rect)).x;
		lastCheckWindowTop = ((Rect)(ref Rect)).y;
		if (nextCheckGameTick <= GameMain.gameTick)
		{
			ConfigManager.CheckConfig(ConfigManager.Step.STATE);
			nextCheckGameTick = long.MaxValue;
		}
	}

	public static void WindowFunction(int windowId)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ac: Expected O, but got Unknown
		//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		string[] array = new string[2] { "Debug", "Logs" };
		GUIStyle val = new GUIStyle(GUI.skin.button);
		val.fixedWidth = 80f;
		val.fixedHeight = 20f;
		val.fontSize = 12;
		GUI.changed = false;
		int num = GUILayout.Toolbar(ListSelected, array, val, Array.Empty<GUILayoutOption>());
		if (GUI.changed)
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
		}
		ListSelected = ((num != ListSelected) ? num : ListSelected);
		GUILayout.EndHorizontal();
		if (ListSelected == 0)
		{
			GUIStyle val2 = new GUIStyle(GUI.skin.label);
			val2.fontSize = 12;
			scrollPos = GUILayout.BeginScrollView(scrollPos, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"CruiseAssistor.ReticuleTargetStar.id={CruiseAssistor.ReticuleTargetStar?.id}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"CruiseAssistor.ReticuleTargetPlanet.id={CruiseAssistor.ReticuleTargetPlanet?.id}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"CruiseAssistor.SelectTargetStar.id={CruiseAssistor.SelectTargetStar?.id}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"CruiseAssistor.SelectTargetPlanet.id={CruiseAssistor.SelectTargetPlanet?.id}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GameMain.mainPlayer.navigation.indicatorAstroId={GameMain.mainPlayer.navigation.indicatorAstroId}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GameMain.mainPlayer.controller.input0.w={GameMain.mainPlayer.controller.input0.w}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GameMain.mainPlayer.controller.input0.x={GameMain.mainPlayer.controller.input0.x}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GameMain.mainPlayer.controller.input0.y={GameMain.mainPlayer.controller.input0.y}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GameMain.mainPlayer.controller.input0.z={GameMain.mainPlayer.controller.input0.z}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GameMain.mainPlayer.controller.input1.w={GameMain.mainPlayer.controller.input1.w}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GameMain.mainPlayer.controller.input1.x={GameMain.mainPlayer.controller.input1.x}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GameMain.mainPlayer.controller.input1.y={GameMain.mainPlayer.controller.input1.y}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GameMain.mainPlayer.controller.input1.z={GameMain.mainPlayer.controller.input1.z}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"VFInput._sailSpeedUp={VFInput._sailSpeedUp}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"CruiseAssistor.Enabled={CruiseAssistor.Enabled}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"CruiseAssistor.History={CruiseAssistor.History.Count()}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label("CruiseAssistor.History=" + ListUtils.ToString(CruiseAssistor.History), val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GUI.skin.window.margin.top={GUI.skin.window.margin.top}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GUI.skin.window.border.top={GUI.skin.window.border.top}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GUI.skin.window.padding.top={GUI.skin.window.padding.top}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"GUI.skin.window.overflow.top={GUI.skin.window.overflow.top}", val2, Array.Empty<GUILayoutOption>());
			GUILayout.EndScrollView();
		}
		else
		{
			GUIStyle val3 = new GUIStyle(GUI.skin.textArea);
			val3.stretchWidth = true;
			val3.stretchHeight = true;
			scrollPos = GUILayout.BeginScrollView(scrollPos, Array.Empty<GUILayoutOption>());
			GUILayout.TextArea(MyLogger.LogString, val3, Array.Empty<GUILayoutOption>());
			GUILayout.EndScrollView();
		}
		GUILayout.EndVertical();
		GUI.DragWindow();
	}
}
public enum CruiseAssistMainUIViewMode
{
	FULL,
	MINI
}
public class CruiseAssistorStarListUI
{
	private static int wIdx = 0;

	public const float WindowWidth = 400f;

	public const float WindowHeight = 480f;

	public static bool[] Show = new bool[2];

	public static Rect[] Rect = (Rect[])(object)new Rect[2]
	{
		new Rect(0f, 0f, 400f, 480f),
		new Rect(0f, 0f, 400f, 480f)
	};

	public static int ListSelected = 0;

	public static int[] actionSelected = new int[3];

	private static float lastCheckWindowLeft = float.MinValue;

	private static float lastCheckWindowTop = float.MinValue;

	private static Vector2[] scrollPos = (Vector2[])(object)new Vector2[3]
	{
		Vector2.zero,
		Vector2.zero,
		Vector2.zero
	};

	private const string VisitedMark = "● ";

	private const string NonVisitMark = "";

	private static string searchString = "";

	public static void OnGUI()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		wIdx = CruiseAssistorMainUI.wIdx;
		GUIStyle val = new GUIStyle(GUI.skin.window);
		val.fontSize = 11;
		Rect[wIdx] = GUILayout.Window(99030292, Rect[wIdx], new WindowFunction(WindowFunction), "Cruise Assistor - StarList", val, Array.Empty<GUILayoutOption>());
		float num = CruiseAssistorMainUI.Scale / 100f;
		if ((float)Screen.width / num < ((Rect)(ref Rect[wIdx])).xMax)
		{
			((Rect)(ref Rect[wIdx])).x = (float)Screen.width / num - ((Rect)(ref Rect[wIdx])).width;
		}
		if (((Rect)(ref Rect[wIdx])).x < 0f)
		{
			((Rect)(ref Rect[wIdx])).x = 0f;
		}
		if ((float)Screen.height / num < ((Rect)(ref Rect[wIdx])).yMax)
		{
			((Rect)(ref Rect[wIdx])).y = (float)Screen.height / num - ((Rect)(ref Rect[wIdx])).height;
		}
		if (((Rect)(ref Rect[wIdx])).y < 0f)
		{
			((Rect)(ref Rect[wIdx])).y = 0f;
		}
		if (lastCheckWindowLeft != float.MinValue && (((Rect)(ref Rect[wIdx])).x != lastCheckWindowLeft || ((Rect)(ref Rect[wIdx])).y != lastCheckWindowTop))
		{
			CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
		}
		lastCheckWindowLeft = ((Rect)(ref Rect[wIdx])).x;
		lastCheckWindowTop = ((Rect)(ref Rect[wIdx])).y;
	}

	public static void WindowFunction(int windowId)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Expected O, but got Unknown
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Expected O, but got Unknown
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Expected O, but got Unknown
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Expected O, but got Unknown
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Expected O, but got Unknown
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Expected O, but got Unknown
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Expected O, but got Unknown
		//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ae: Expected O, but got Unknown
		//IL_045a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUIStyle val = new GUIStyle(GUI.skin.button);
		val.fixedWidth = 80f;
		val.fixedHeight = 20f;
		val.fontSize = 12;
		string[] array = new string[3] { "Normal", "History", "Bookmark" };
		GUI.changed = false;
		int num = GUILayout.Toolbar(ListSelected, array, val, Array.Empty<GUILayoutOption>());
		if (GUI.changed)
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
		}
		if (num != ListSelected)
		{
			ListSelected = num;
			CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
		}
		GUILayout.EndHorizontal();
		scrollPos[ListSelected] = GUILayout.BeginScrollView(scrollPos[ListSelected], Array.Empty<GUILayoutOption>());
		GUIStyle nameLabelStyle = new GUIStyle(GUI.skin.label);
		nameLabelStyle.fixedWidth = 240f;
		nameLabelStyle.stretchHeight = true;
		nameLabelStyle.fontSize = 14;
		nameLabelStyle.alignment = (TextAnchor)3;
		GUIStyle nRangeLabelStyle = new GUIStyle(GUI.skin.label);
		nRangeLabelStyle.fixedWidth = 60f;
		nRangeLabelStyle.fixedHeight = 20f;
		nRangeLabelStyle.fontSize = 14;
		nRangeLabelStyle.alignment = (TextAnchor)5;
		GUIStyle hRangeLabelStyle = new GUIStyle(nRangeLabelStyle);
		hRangeLabelStyle.fixedHeight = 40f;
		GUIStyle nActionButtonStyle = new GUIStyle(GUI.skin.button);
		nActionButtonStyle.fixedWidth = 40f;
		nActionButtonStyle.fixedHeight = 18f;
		nActionButtonStyle.margin.top = 6;
		nActionButtonStyle.fontSize = 12;
		GUIStyle hActionButtonStyle = new GUIStyle(nActionButtonStyle);
		hActionButtonStyle.margin.top = 16;
		GUIStyle nSortButtonStyle = new GUIStyle(GUI.skin.button);
		nSortButtonStyle.fixedWidth = 20f;
		nSortButtonStyle.fixedHeight = 18f;
		nSortButtonStyle.margin.top = 6;
		nSortButtonStyle.fontSize = 12;
		GUIStyle hSortButtonStyle = new GUIStyle(nSortButtonStyle);
		hSortButtonStyle.margin.top = 16;
		if (ListSelected == 0)
		{
			CollectionExtensions.Do<Tuple<StarData, double>>((IEnumerable<Tuple<StarData, double>>)(from tuple in GameMain.galaxy.stars.Select(delegate(StarData star)
				{
					//IL_0002: 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_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					VectorLF3 val7 = star.uPosition - GameMain.mainPlayer.uPosition;
					return new Tuple<StarData, double>(star, ((VectorLF3)(ref val7)).magnitude);
				})
				orderby tuple.v2
				select tuple), (Action<Tuple<StarData, double>>)delegate(Tuple<StarData, double> tuple)
			{
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_0188: Unknown result type (might be due to invalid IL or missing references)
				//IL_024f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0264: Expected O, but got Unknown
				//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
				StarData star3 = tuple.v1;
				double range = tuple.v2;
				string starName = CruiseAssistor.GetStarName(star3);
				bool flag3 = false;
				if (GameMain.localStar != null && star3.id == GameMain.localStar.id)
				{
					flag3 = true;
				}
				else if (CruiseAssistor.SelectTargetStar != null && star3.id == CruiseAssistor.SelectTargetStar.id && GameMain.history.universeObserveLevel >= ((range >= 14400000.0) ? 4 : 3))
				{
					flag3 = true;
				}
				if (flag3)
				{
					IEnumerable<Tuple<PlanetData, double>> enumerable4 = from x in star3.planets.Select(delegate(PlanetData planet)
						{
							//IL_0002: 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_0011: Unknown result type (might be due to invalid IL or missing references)
							//IL_0016: Unknown result type (might be due to invalid IL or missing references)
							VectorLF3 val6 = planet.uPosition - GameMain.mainPlayer.uPosition;
							return new Tuple<PlanetData, double>(planet, ((VectorLF3)(ref val6)).magnitude);
						})
						where x.v1.displayName.ToLower().Contains(searchString.ToLower())
						select x;
					VectorLF3 val5 = star3.uPosition - GameMain.mainPlayer.uPosition;
					CollectionExtensions.Do<Tuple<PlanetData, double>>((IEnumerable<Tuple<PlanetData, double>>)(from tuple2 in CollectionExtensions.AddItem<Tuple<PlanetData, double>>(enumerable4, new Tuple<PlanetData, double>(null, ((VectorLF3)(ref val5)).magnitude))
						orderby tuple2.v2
						select tuple2), (Action<Tuple<PlanetData, double>>)delegate(Tuple<PlanetData, double> tuple2)
					{
						//IL_002a: Unknown result type (might be due to invalid IL or missing references)
						//IL_0044: Unknown result type (might be due to invalid IL or missing references)
						//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
						//IL_0213: Expected O, but got Unknown
						//IL_0170: Unknown result type (might be due to invalid IL or missing references)
						//IL_018a: Unknown result type (might be due to invalid IL or missing references)
						//IL_0127: Unknown result type (might be due to invalid IL or missing references)
						//IL_0141: Expected O, but got Unknown
						//IL_0089: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
						//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
						GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
						PlanetData v = tuple2.v1;
						double v2 = tuple2.v2;
						nameLabelStyle.normal.textColor = Color.white;
						nRangeLabelStyle.normal.textColor = Color.white;
						float num6;
						if (v == null)
						{
							if (CruiseAssistor.SelectTargetPlanet == null && CruiseAssistor.SelectTargetStar != null && star3.id == CruiseAssistor.SelectTargetStar.id)
							{
								nameLabelStyle.normal.textColor = Color.cyan;
								nRangeLabelStyle.normal.textColor = Color.cyan;
							}
							string text4 = starName;
							if (CruiseAssistor.MarkVisitedFlag)
							{
								text4 = ((star3.planets.Where((PlanetData p) => p.factory != null).Count() > 0) ? "● " : "") + text4;
							}
							GUILayout.Label(text4, nameLabelStyle, Array.Empty<GUILayoutOption>());
							num6 = nameLabelStyle.CalcHeight(new GUIContent(text4), nameLabelStyle.fixedWidth);
						}
						else
						{
							if (CruiseAssistor.SelectTargetPlanet != null && v.id == CruiseAssistor.SelectTargetPlanet.id)
							{
								nameLabelStyle.normal.textColor = Color.cyan;
								nRangeLabelStyle.normal.textColor = Color.cyan;
							}
							string text5 = starName + " - " + CruiseAssistor.GetPlanetName(v);
							if (CruiseAssistor.MarkVisitedFlag)
							{
								text5 = ((v.factory != null) ? "● " : "") + text5;
							}
							GUILayout.Label(text5, nameLabelStyle, Array.Empty<GUILayoutOption>());
							num6 = nameLabelStyle.CalcHeight(new GUIContent(text5), nameLabelStyle.fixedWidth);
						}
						GUILayout.FlexibleSpace();
						GUILayout.Label(CruiseAssistorMainUI.RangeToString((v == null) ? range : v2), (num6 < 30f) ? nRangeLabelStyle : hRangeLabelStyle, Array.Empty<GUILayoutOption>());
						if (GUILayout.Button((actionSelected[ListSelected] == 0) ? "SET" : ((v == null) ? "-" : (CruiseAssistor.Bookmark.Contains(v.id) ? "DEL" : "ADD")), (num6 < 30f) ? nActionButtonStyle : hActionButtonStyle, Array.Empty<GUILayoutOption>()))
						{
							VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
							if (actionSelected[ListSelected] == 0)
							{
								SelectStar(star3, v);
							}
							else if (v != null)
							{
								if (CruiseAssistor.Bookmark.Contains(v.id))
								{
									CruiseAssistor.Bookmark.Remove(v.id);
								}
								else if (CruiseAssistor.Bookmark.Count <= 128)
								{
									CruiseAssistor.Bookmark.Add(v.id);
									CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
								}
							}
						}
						GUILayout.EndHorizontal();
					});
				}
				else
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					nameLabelStyle.normal.textColor = Color.white;
					nRangeLabelStyle.normal.textColor = Color.white;
					if (CruiseAssistor.SelectTargetStar != null && star3.id == CruiseAssistor.SelectTargetStar.id)
					{
						nameLabelStyle.normal.textColor = Color.cyan;
						nRangeLabelStyle.normal.textColor = Color.cyan;
					}
					string text3 = starName;
					if (CruiseAssistor.MarkVisitedFlag)
					{
						text3 = ((star3.planets.Where((PlanetData p) => p.factory != null).Count() > 0) ? "● " : "") + text3;
					}
					GUILayout.Label(text3, nameLabelStyle, Array.Empty<GUILayoutOption>());
					float num5 = nameLabelStyle.CalcHeight(new GUIContent(text3), nameLabelStyle.fixedWidth);
					GUILayout.FlexibleSpace();
					GUILayout.Label(CruiseAssistorMainUI.RangeToString(range), (num5 < 30f) ? nRangeLabelStyle : hRangeLabelStyle, Array.Empty<GUILayoutOption>());
					if (GUILayout.Button((actionSelected[ListSelected] == 0) ? "SET" : "-", (num5 < 30f) ? nActionButtonStyle : hActionButtonStyle, Array.Empty<GUILayoutOption>()))
					{
						VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
						if (actionSelected[ListSelected] == 0)
						{
							SelectStar(star3, null);
						}
					}
					GUILayout.EndHorizontal();
				}
			});
		}
		else if (ListSelected == 1 || ListSelected == 2)
		{
			bool highlighted = false;
			IEnumerable<int> enumerable2;
			if (ListSelected != 1)
			{
				IEnumerable<int> enumerable = CruiseAssistor.Bookmark.ToList();
				enumerable2 = enumerable;
			}
			else
			{
				enumerable2 = Enumerable.Reverse(CruiseAssistor.History);
			}
			IEnumerable<int> enumerable3 = enumerable2;
			if (ListSelected == 1 && actionSelected[ListSelected] != 2 && CruiseAssistor.HideDuplicateHistoryFlag)
			{
				enumerable3 = enumerable3.Distinct();
			}
			int listIndex = -1;
			CollectionExtensions.Do<int>(enumerable3, (Action<int>)delegate(int id)
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Expected O, but got Unknown
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0359: 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_0294: Unknown result type (might be due to invalid IL or missing references)
				int num2 = listIndex + 1;
				listIndex = num2;
				PlanetData val3 = GameMain.galaxy.PlanetById(id);
				if (val3 != null)
				{
					StarData star2 = val3.star;
					string text = CruiseAssistor.GetStarName(star2);
					VectorLF3 val4 = val3.uPosition - GameMain.mainPlayer.uPosition;
					double magnitude = ((VectorLF3)(ref val4)).magnitude;
					nameLabelStyle.normal.textColor = Color.white;
					nRangeLabelStyle.normal.textColor = Color.white;
					if (!highlighted && CruiseAssistor.SelectTargetPlanet != null && val3.id == CruiseAssistor.SelectTargetPlanet.id)
					{
						nameLabelStyle.normal.textColor = Color.cyan;
						nRangeLabelStyle.normal.textColor = Color.cyan;
						highlighted = true;
					}
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					string text2 = text + " - " + CruiseAssistor.GetPlanetName(val3);
					if (CruiseAssistor.MarkVisitedFlag)
					{
						text2 = ((val3.factory != null) ? "● " : "") + text2;
					}
					GUILayout.Label(text2, nameLabelStyle, Array.Empty<GUILayoutOption>());
					float num3 = nameLabelStyle.CalcHeight(new GUIContent(text2), nameLabelStyle.fixedWidth);
					GUILayout.FlexibleSpace();
					GUILayout.Label(CruiseAssistorMainUI.RangeToString(magnitude), (num3 < 30f) ? nRangeLabelStyle : hRangeLabelStyle, Array.Empty<GUILayoutOption>());
					if (ListSelected == 2 && actionSelected[ListSelected] == 1)
					{
						int num4 = CruiseAssistor.Bookmark.IndexOf(id);
						bool flag = num4 == 0;
						bool flag2 = num4 == CruiseAssistor.Bookmark.Count - 1;
						if (GUILayout.Button(flag2 ? "-" : "↓", (num3 < 30f) ? nSortButtonStyle : hSortButtonStyle, Array.Empty<GUILayoutOption>()))
						{
							VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
							if (!flag2)
							{
								CruiseAssistor.Bookmark.RemoveAt(num4);
								CruiseAssistor.Bookmark.Insert(num4 + 1, id);
							}
						}
						if (GUILayout.Button(flag ? "-" : "↑", (num3 < 30f) ? nSortButtonStyle : hSortButtonStyle, Array.Empty<GUILayoutOption>()))
						{
							VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
							if (!flag)
							{
								CruiseAssistor.Bookmark.RemoveAt(num4);
								CruiseAssistor.Bookmark.Insert(num4 - 1, id);
							}
						}
					}
					else if (GUILayout.Button((actionSelected[ListSelected] == 0) ? "SET" : ((actionSelected[ListSelected] != 2) ? (CruiseAssistor.Bookmark.Contains(id) ? "DEL" : "ADD") : ((ListSelected == 1 && listIndex == 0) ? "-" : "DEL")), (num3 < 30f) ? nActionButtonStyle : hActionButtonStyle, Array.Empty<GUILayoutOption>()))
					{
						VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
						if (actionSelected[ListSelected] == 0)
						{
							SelectStar(star2, val3);
						}
						else if (actionSelected[ListSelected] == 1)
						{
							if (ListSelected == 1)
							{
								if (CruiseAssistor.Bookmark.Contains(id))
								{
									CruiseAssistor.Bookmark.Remove(id);
								}
								else if (CruiseAssistor.Bookmark.Count <= 128)
								{
									CruiseAssistor.Bookmark.Add(id);
									CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
								}
							}
						}
						else if (actionSelected[ListSelected] == 2)
						{
							if (ListSelected == 1)
							{
								if (listIndex != 0)
								{
									CruiseAssistor.History.RemoveAt(CruiseAssistor.History.Count - 1 - listIndex);
									CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
								}
							}
							else if (ListSelected == 2)
							{
								CruiseAssistor.Bookmark.Remove(val3.id);
								CruiseAssistorMainUI.NextCheckGameTick = GameMain.gameTick + 300;
							}
						}
					}
					GUILayout.EndHorizontal();
				}
			});
		}
		GUILayout.EndScrollView();
		GUILayout.FlexibleSpace();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUIStyle val2 = new GUIStyle(GUI.skin.button);
		val2.fixedWidth = 80f;
		val2.fixedHeight = 20f;
		val2.fontSize = 12;
		string[][] array2 = new string[3][]
		{
			new string[2] { "Target", "Bookmark" },
			new string[3] { "Target", "Bookmark", "Delete" },
			new string[3] { "Target", "Sort", "Delete" }
		};
		if (GUILayout.Button(array2[ListSelected][actionSelected[ListSelected]], val2, Array.Empty<GUILayoutOption>()))
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			actionSelected[ListSelected]++;
			actionSelected[ListSelected] %= array2[ListSelected].Length;
		}
		searchString = GUILayout.TextField(searchString, Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Close", val2, Array.Empty<GUILayoutOption>()))
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			Show[wIdx] = false;
		}
		GUILayout.EndHorizontal();
		GUILayout.EndVertical();
		GUI.DragWindow();
	}

	public static void SelectStar(StarData star, PlanetData planet)
	{
		CruiseAssistor.SelectTargetStar = star;
		CruiseAssistor.SelectTargetPlanet = planet;
		UIGame uiGame = UIRoot.instance.uiGame;
		if (CruiseAssistor.SelectFocusFlag && ((ManualBehaviour)uiGame.starmap).active)
		{
			if (star != null)
			{
				UIStarmapStar val = uiGame.starmap.starUIs.Where((UIStarmapStar s) => s.star.id == star.id).FirstOrDefault();
				if ((Object)(object)val != (Object)null)
				{
					UIStarmap_OnStarClick(uiGame.starmap, val);
					uiGame.starmap.OnCursorFunction2Click(0);
				}
			}
			if (planet != null)
			{
				UIStarmapPlanet val2 = uiGame.starmap.planetUIs.Where((UIStarmapPlanet p) => p.planet.id == planet.id).FirstOrDefault();
				if ((Object)(object)val2 != (Object)null)
				{
					UIStarmap_OnPlanetClick(uiGame.starmap, val2);
					uiGame.starmap.OnCursorFunction2Click(0);
				}
			}
		}
		if (planet != null)
		{
			GameMain.mainPlayer.navigation.indicatorAstroId = planet.id;
		}
		else if (star != null)
		{
			GameMain.mainPlayer.navigation.indicatorAstroId = star.id * 100;
		}
		else
		{
			GameMain.mainPlayer.navigation.indicatorAstroId = 0;
		}
		CruiseAssistor.SelectTargetAstroId = GameMain.mainPlayer.navigation.indicatorAstroId;
	}

	private static void UIStarmap_OnStarClick(UIStarmap starmap, UIStarmapStar star)
	{
		Traverse val = Traverse.Create((object)starmap);
		if ((Object)(object)starmap.focusStar != (Object)(object)star)
		{
			if (starmap.viewPlanet != null || (starmap.viewStar != null && star.star != starmap.viewStar))
			{
				starmap.screenCameraController.DisablePositionLock();
			}
			starmap.focusPlanet = null;
			starmap.focusStar = star;
			val.Field("_lastClickTime").SetValue((object)0.0);
		}
		val.Field("forceUpdateCursorView").SetValue((object)true);
	}

	private static void UIStarmap_OnPlanetClick(UIStarmap starmap, UIStarmapPlanet planet)
	{
		Traverse val = Traverse.Create((object)starmap);
		if ((Object)(object)starmap.focusPlanet != (Object)(object)planet)
		{
			if ((starmap.viewPlanet != null && planet.planet != starmap.viewPlanet) || starmap.viewStar != null)
			{
				starmap.screenCameraController.DisablePositionLock();
			}
			starmap.focusPlanet = planet;
			starmap.focusStar = null;
			val.Field("_lastClickTime").SetValue((object)0.0);
		}
		val.Field("forceUpdateCursorView").SetValue((object)true);
	}
}
public enum CruiseAssistState
{
	TO_STAR,
	TO_PLANET,
	TO_ENEMY,
	INACTIVE
}
public class CruiseAssistorMainUI
{
	public static float Scale = 150f;

	public static int wIdx = 0;

	public static CruiseAssistMainUIViewMode ViewMode = CruiseAssistMainUIViewMode.FULL;

	public const float WindowWidthFull = 398f;

	public const float WindowHeightFull = 150f;

	public const float WindowWidthMini = 273f;

	public const float WindowHeightMini = 70f;

	public static Rect[] Rect = (Rect[])(object)new Rect[2]
	{
		new Rect(0f, 0f, 398f, 150f),
		new Rect(0f, 0f, 398f, 150f)
	};

	private static float lastCheckWindowLeft = float.MinValue;

	private static float lastCheckWindowTop = float.MinValue;

	public static long NextCheckGameTick = long.MaxValue;

	public static void OnGUI()
	{
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Expected O, but got Unknown
		//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)
		switch (ViewMode)
		{
		case CruiseAssistMainUIViewMode.FULL:
			((Rect)(ref Rect[wIdx])).width = 398f;
			((Rect)(ref Rect[wIdx])).height = 150f;
			break;
		case CruiseAssistMainUIViewMode.MINI:
			((Rect)(ref Rect[wIdx])).width = 273f;
			((Rect)(ref Rect[wIdx])).height = 70f;
			break;
		}
		GUIStyle val = new GUIStyle(GUI.skin.window);
		val.fontSize = 11;
		Rect[wIdx] = GUILayout.Window(99030291, Rect[wIdx], new WindowFunction(WindowFunction), "Cruise Assistor", val, Array.Empty<GUILayoutOption>());
		float num = Scale / 100f;
		if ((float)Screen.width / num < ((Rect)(ref Rect[wIdx])).xMax)
		{
			((Rect)(ref Rect[wIdx])).x = (float)Screen.width / num - ((Rect)(ref Rect[wIdx])).width;
		}
		if (((Rect)(ref Rect[wIdx])).x < 0f)
		{
			((Rect)(ref Rect[wIdx])).x = 0f;
		}
		if ((float)Screen.height / num < ((Rect)(ref Rect[wIdx])).yMax)
		{
			((Rect)(ref Rect[wIdx])).y = (float)Screen.height / num - ((Rect)(ref Rect[wIdx])).height;
		}
		if (((Rect)(ref Rect[wIdx])).y < 0f)
		{
			((Rect)(ref Rect[wIdx])).y = 0f;
		}
		if (lastCheckWindowLeft != float.MinValue && (((Rect)(ref Rect[wIdx])).x != lastCheckWindowLeft || ((Rect)(ref Rect[wIdx])).y != lastCheckWindowTop))
		{
			NextCheckGameTick = GameMain.gameTick + 300;
		}
		lastCheckWindowLeft = ((Rect)(ref Rect[wIdx])).x;
		lastCheckWindowTop = ((Rect)(ref Rect[wIdx])).y;
		if (NextCheckGameTick <= GameMain.gameTick)
		{
			ConfigManager.CheckConfig(ConfigManager.Step.STATE);
			NextCheckGameTick = long.MaxValue;
		}
	}

	public static void WindowFunction(int windowId)
	{
		//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Expected O, but got Unknown
		//IL_0412: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_043c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0443: Expected O, but got Unknown
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_048f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Expected O, but got Unknown
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0548: Unknown result type (might be due to invalid IL or missing references)
		//IL_0586: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Expected O, but got Unknown
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Expected O, but got Unknown
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Expected O, but got Unknown
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Expected O, but got Unknown
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Expected O, but got Unknown
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_034c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		if (ViewMode == CruiseAssistMainUIViewMode.FULL)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			Color textColor = ((CruiseAssistor.State == CruiseAssistState.TO_STAR) ? Color.cyan : Color.white);
			Color textColor2 = ((CruiseAssistor.State == CruiseAssistState.TO_PLANET) ? Color.cyan : Color.white);
			Color textColor3 = ((CruiseAssistor.State == CruiseAssistState.TO_ENEMY) ? Color.red : Color.white);
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUIStyle val = new GUIStyle(GUI.skin.label);
			val.fixedWidth = 50f;
			val.fixedHeight = 36f;
			val.fontSize = 12;
			val.alignment = (TextAnchor)0;
			GUIStyle val2 = new GUIStyle(val);
			val.normal.textColor = textColor;
			GUILayout.Label("Target\n System:", val, Array.Empty<GUILayoutOption>());
			val2.normal.textColor = textColor2;
			GUILayout.Label((CruiseAssistor.State == CruiseAssistState.TO_ENEMY) ? "Target:" : "Target\n Planet:", val2, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUIStyle val3 = new GUIStyle(GUI.skin.label);
			val3.fixedWidth = 240f;
			val3.fixedHeight = 36f;
			val3.fontSize = 14;
			val3.alignment = (TextAnchor)3;
			GUIStyle val4 = new GUIStyle(val3);
			GUIStyle val5 = new GUIStyle(val3);
			if (CruiseAssistor.TargetStar != null)
			{
				val3.normal.textColor = textColor;
				GUILayout.Label(CruiseAssistor.GetStarName(CruiseAssistor.TargetStar), val3, Array.Empty<GUILayoutOption>());
			}
			else
			{
				GUILayout.Label(" ", val3, Array.Empty<GUILayoutOption>());
			}
			if (CruiseAssistor.TargetPlanet != null)
			{
				val4.normal.textColor = textColor2;
				GUILayout.Label(CruiseAssistor.GetPlanetName(CruiseAssistor.TargetPlanet), val4, Array.Empty<GUILayoutOption>());
			}
			else if (CruiseAssistor.TargetEnemy.HasValue)
			{
				val5.normal.textColor = textColor3;
				val5.alignment = (TextAnchor)0;
				GUILayout.Label("Seed", val5, Array.Empty<GUILayoutOption>());
			}
			else
			{
				GUILayout.Label(" ", val4, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndVertical();
			GUILayout.FlexibleSpace();
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			PlayerMove_Sail actionSail = GameMain.mainPlayer.controller.actionSail;
			VectorLF3 visual_uvel = actionSail.visual_uvel;
			VectorLF3 val6;
			double magnitude;
			if (GameMain.mainPlayer.warping)
			{
				val6 = visual_uvel + actionSail.currentWarpVelocity;
				magnitude = ((VectorLF3)(ref val6)).magnitude;
			}
			else
			{
				magnitude = ((VectorLF3)(ref visual_uvel)).magnitude;
			}
			GUIStyle val7 = new GUIStyle(GUI.skin.label);
			val7.fixedWidth = 80f;
			val7.fixedHeight = 36f;
			val7.fontSize = 12;
			val7.alignment = (TextAnchor)5;
			GUIStyle val8 = new GUIStyle(val7);
			if (CruiseAssistor.TargetStar != null)
			{
				val7.normal.textColor = textColor;
				val6 = CruiseAssistor.TargetStar.uPosition - GameMain.mainPlayer.uPosition;
				double num = ((VectorLF3)(ref val6)).magnitude - (double)(CruiseAssistor.TargetStar.viewRadius - 120f);
				GUILayout.Label(RangeToString(num) + "\n" + TimeToString(num / magnitude), val7, Array.Empty<GUILayoutOption>());
			}
			else
			{
				GUILayout.Label(" \n ", val7, Array.Empty<GUILayoutOption>());
			}
			if (CruiseAssistor.TargetPlanet != null)
			{
				val8.normal.textColor = textColor2;
				val6 = CruiseAssistor.TargetPlanet.uPosition - GameMain.mainPlayer.uPosition;
				double num2 = ((VectorLF3)(ref val6)).magnitude - (double)CruiseAssistor.TargetPlanet.realRadius;
				GUILayout.Label(RangeToString(num2) + "\n" + TimeToString(num2 / magnitude), val8, Array.Empty<GUILayoutOption>());
			}
			else
			{
				GUILayout.Label(" \n ", val8, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
		}
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUIStyle val9 = new GUIStyle(GUI.skin.label);
		val9.fixedWidth = 145f;
		val9.fixedHeight = 32f;
		val9.fontSize = 14;
		val9.alignment = (TextAnchor)3;
		if (CruiseAssistor.State == CruiseAssistState.INACTIVE)
		{
			GUILayout.Label("Cruise Assist Inactive.", val9, Array.Empty<GUILayoutOption>());
		}
		else
		{
			val9.normal.textColor = Color.cyan;
			GUILayout.Label("Cruise Assist Active.", val9, Array.Empty<GUILayoutOption>());
		}
		GUILayout.FlexibleSpace();
		GUIStyle val10 = new GUIStyle(GUI.skin.button);
		val10.fixedWidth = 50f;
		val10.fixedHeight = 18f;
		val10.fontSize = 11;
		val10.alignment = (TextAnchor)4;
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Config", val10, Array.Empty<GUILayoutOption>()))
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			ref bool reference = ref CruiseAssistorConfigUI.Show[wIdx];
			reference = !reference;
			if (CruiseAssistorConfigUI.Show[wIdx])
			{
				CruiseAssistorConfigUI.TempScale = Scale;
			}
		}
		if (GUILayout.Button(CruiseAssistor.Enabled ? "Disable" : "Enable", val10, Array.Empty<GUILayoutOption>()))
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			CruiseAssistor.Enabled = !CruiseAssistor.Enabled;
			NextCheckGameTick = GameMain.gameTick + 300;
		}
		GUILayout.EndVertical();
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("StarList", val10, Array.Empty<GUILayoutOption>()))
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			ref bool reference2 = ref CruiseAssistorStarListUI.Show[wIdx];
			reference2 = !reference2;
		}
		if (GUILayout.Button("Cancel", val10, Array.Empty<GUILayoutOption>()))
		{
			VFAudio.Create("ui-click-0", (Transform)null, Vector3.zero, true, 0, -1, -1L);
			CruiseAssistorStarListUI.SelectStar(null, null);
		}
		GUILayout.EndVertical();
		GUILayout.EndHorizontal();
		GUILayout.EndVertical();
		GUI.DragWindow();
	}

	public static string RangeToString(double range)
	{
		if (range < 10000.0)
		{
			return (int)(range + 0.5) + "m ";
		}
		if (range < 600000.0)
		{
			return (range / 40000.0).ToString("0.00") + "AU";
		}
		return (range / 2400000.0).ToString("0.00") + "Ly";
	}

	public static string TimeToString(double time)
	{
		int num = (int)(time + 0.5);
		int num2 = num / 60;
		int num3 = num2 / 60;
		num %= 60;
		num2 %= 60;
		return $"{num3:00} {num2:00} {num:00}";
	}
}
public class EnumUtils
{
	public static bool TryParse<TEnum>(string value, out TEnum result) where TEnum : struct
	{
		if (value == null || !Enum.IsDefined(typeof(TEnum), value))
		{
			result = (TEnum)Enum.GetValues(typeof(TEnum)).GetValue(0);
			return false;
		}
		result = (TEnum)Enum.Parse(typeof(TEnum), value);
		return true;
	}
}
public static class LogManager
{
	public static ManualLogSource Logger { private get; set; }

	public static void LogInfo(object data)
	{
		Logger.LogInfo(data);
	}

	public static void LogInfo(MethodBase method)
	{
		Logger.LogInfo((object)(method.DeclaringType.Name + "." + method.Name));
	}

	public static void LogError(object data)
	{
		Logger.LogError(data);
	}

	public static void LogError(MethodBase method, object data)
	{
		Logger.LogError((object)(method.DeclaringType.Name + "." + method.Name + ": " + data));
	}
}
[HarmonyPatch(typeof(PlayerMove_Sail))]
public class Patch_PlayerMoveSail
{
	private static readonly double SPEEDCONTROLRANGE = 0.9;

	private static readonly double SPEEDREDUCTIONRANGEMAX = Math.Log(100000.0);

	private static readonly double SPEEDREDUCTIONRANGEMIN = Math.Log(1000.0);

	private static readonly double SPEEDREDUCTIONRANGEMULTIPLIER = SPEEDCONTROLRANGE / (SPEEDREDUCTIONRANGEMAX - SPEEDREDUCTIONRANGEMIN);

	private static readonly double SPEEDREDUCTIONCURVE = 0.1 - SPEEDREDUCTIONRANGEMULTIPLIER * SPEEDREDUCTIONRANGEMIN;

	[HarmonyPatch("GameTick")]
	[HarmonyPrefix]
	public static void GameTick_Prefix(PlayerMove_Sail __instance)
	{
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		CruiseAssistor.State = CruiseAssistState.INACTIVE;
		Player player = ((PlayerAction)__instance).player;
		if (!player.sailing || !CruiseAssistor.Enabled)
		{
			return;
		}
		CruiseAssistor.TargetStar = null;
		CruiseAssistor.TargetPlanet = null;
		CruiseAssistor.TargetEnemy = null;
		if (CruiseAssistor.SelectTargetStar != null)
		{
			if (GameMain.localStar != null && CruiseAssistor.SelectTargetStar.id == GameMain.localStar.id)
			{
				if (CruiseAssistor.SelectTargetPlanet == null && GameMain.localPlanet != null)
				{
					CruiseAssistor.SelectTargetStar = null;
					CruiseAssistor.SelectTargetAstroId = 0;
					GameMain.mainPlayer.navigation.indicatorAstroId = 0;
					return;
				}
				if (CruiseAssistor.SelectTargetPlanet != null)
				{
					if (GameMain.localPlanet != null && CruiseAssistor.SelectTargetPlanet.id == GameMain.localPlanet.id)
					{
						CruiseAssistor.SelectTargetStar = null;
						CruiseAssistor.SelectTargetPlanet = null;
						CruiseAssistor.SelectTargetAstroId = 0;
						GameMain.mainPlayer.navigation.indicatorAstroId = 0;
						return;
					}
					CruiseAssistor.TargetPlanet = CruiseAssistor.SelectTargetPlanet;
				}
				else if (CruiseAssistor.ReticuleTargetPlanet != null)
				{
					CruiseAssistor.TargetPlanet = CruiseAssistor.ReticuleTargetPlanet;
				}
			}
			else
			{
				CruiseAssistor.TargetStar = CruiseAssistor.SelectTargetStar;
			}
		}
		else if (CruiseAssistor.SelectTargetEnemyId != 0)
		{
			CruiseAssistor.TargetEnemy = GameMain.spaceSector.enemyPool[CruiseAssistor.SelectTargetEnemyId];
		}
		else if (CruiseAssistor.ReticuleTargetPlanet != null)
		{
			CruiseAssistor.TargetPlanet = CruiseAssistor.ReticuleTargetPlanet;
		}
		else if (CruiseAssistor.ReticuleTargetStar != null)
		{
			CruiseAssistor.TargetStar = CruiseAssistor.ReticuleTargetStar;
		}
		if (GameMain.mainPlayer.controller.input0 != Vector4.zero || GameMain.mainPlayer.controller.input1 != Vector4.zero)
		{
			return;
		}
		if (CruiseAssistor.TargetPlanet != null)
		{
			CruiseAssistor.State = CruiseAssistState.TO_PLANET;
		}
		else if (CruiseAssistor.TargetStar != null)
		{
			CruiseAssistor.State = CruiseAssistState.TO_STAR;
		}
		else
		{
			if (!CruiseAssistor.TargetEnemy.HasValue)
			{
				return;
			}
			CruiseAssistor.State = CruiseAssistState.TO_ENEMY;
			EnemyData value = CruiseAssistor.TargetEnemy.Value;
			double num = ((VectorLF3)(ref value.pos)).Distance(player.uPosition);
			if (GameMain.mainPlayer.warping)
			{
				GameMain.mainPlayer.controller.actionSail.warpSpeedControl = GetSpeedReducer(num);
				if (num < 3000.0)
				{
					GameMain.mainPlayer.warpCommand = false;
				}
			}
		}
		int indicatorAstroId = player.navigation.indicatorAstroId;
		int indicatorEnemyId = player.navigation.indicatorEnemyId;
		VectorLF3 val = CalculateInterceptVelocity(indicatorAstroId, indicatorEnemyId, GameMain.spaceSector, player);
		float num2 = Vector3.Angle(VectorLF3.op_Implicit(val), VectorLF3.op_Implicit(player.uVelocity));
		float num3 = 1.6f / Mathf.Max(10f, num2);
		player.uVelocity = VectorLF3.op_Implicit(Vector3.Slerp(VectorLF3.op_Implicit(player.uVelocity), VectorLF3.op_Implicit(((VectorLF3)(ref val)).normalized * ((VectorLF3)(ref player.uVelocity)).magnitude), num3));
	}

	private static double GetSpeedReducer(double distance)
	{
		return Math.Min(1.0, Math.Max(0.1, SPEEDREDUCTIONCURVE + SPEEDREDUCTIONRANGEMULTIPLIER * Math.Log(distance)));
	}

	protected static VectorLF3 CalculateInterceptVelocity(int astroId, int enemyId, SpaceSector sector, Player player)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: 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_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		VectorLF3 val = VectorLF3.zero;
		if (astroId > 1000000)
		{
			val = sector.astros[astroId - 1000000].uPos;
		}
		else if (astroId > 0)
		{
			val = sector.galaxyAstros[astroId].uPos;
		}
		else if (enemyId != 0)
		{
			ref EnemyData reference = ref sector.enemyPool[enemyId];
			sector.TransformFromAstro(reference.astroId, ref val, reference.pos);
		}
		VectorLF3 val2 = VectorLF3.zero;
		if (astroId > 1000000)
		{
			val2 = (sector.astros[astroId - 1000000].uPosNext - val) * 60.0;
		}
		else if (astroId > 0)
		{
			val2 = (sector.galaxyAstros[astroId].uPosNext - val) * 60.0;
		}
		else if (enemyId > 0)
		{
			val2 = VectorLF3.op_Implicit(sector.enemyPool[enemyId].vel);
		}
		VectorLF3 uPosition = player.uPosition;
		VectorLF3 val3 = player.uVelocity + player.controller.actionSail.currentWarpVelocity;
		double magnitude = ((VectorLF3)(ref val3)).magnitude;
		VectorLF3 val4 = val - uPosition;
		double num = ((VectorLF3)(ref val2)).sqrMagnitude - magnitude * magnitude;
		double num2 = 2.0 * VectorLF3.Dot(val4, val2);
		double sqrMagnitude = ((VectorLF3)(ref val4)).sqrMagnitude;
		double num3;
		if (Math.Abs(num) < 1E-06)
		{
			num3 = ((!(Math.Abs(num2) < 1E-06)) ? ((0.0 - sqrMagnitude) / num2) : 0.0);
		}
		else
		{
			double num4 = num2 * num2 - 4.0 * num * sqrMagnitude;
			if (num4 < 0.0)
			{
				num3 = 0.0;
			}
			else
			{
				double num5 = Math.Sqrt(num4);
				double num6 = (0.0 - num2 + num5) / (2.0 * num);
				double num7 = (0.0 - num2 - num5) / (2.0 * num);
				num3 = ((num6 > 0.0 && num7 > 0.0) ? Math.Min(num6, num7) : ((num6 > 0.0) ? num6 : ((!(num7 > 0.0)) ? Math.Max(num6, num7) : num7)));
			}
		}
		VectorLF3 val5 = val + val2 * num3 - uPosition;
		return ((VectorLF3)(ref val5)).normalized * magnitude;
	}
}
[HarmonyPatch(typeof(GameMain))]
public class Patch_GameMain
{
	[HarmonyPatch("Begin")]
	[HarmonyPostfix]
	public static void Begin_Postfix()
	{
		ConfigManager.CheckConfig(ConfigManager.Step.GAME_MAIN_BEGIN);
	}

	[HarmonyPatch("Pause")]
	[HarmonyPrefix]
	public static void Pause_Prefix()
	{
		ConfigManager.CheckConfig(ConfigManager.Step.STATE);
	}
}
[HarmonyPatch(typeof(UISailPanel))]
public class Patch_UISailPanel
{
	[HarmonyPatch("_OnUpdate")]
	[HarmonyTranspiler]
	public static IEnumerable<CodeInstruction> OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Expected O, but got Unknown
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Expected O, but got Unknown
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Expected O, but got Unknown
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Expected O, but got Unknown
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Expected O, but got Unknown
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Expected O, but got Unknown
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Expected O, but got Unknown
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Expected O, but got Unknown
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Expected O, but got Unknown
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Expected O, but got Unknown
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Expected O, but got Unknown
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Expected O, but got Unknown
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Expected O, but got Unknown
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Expected O, but got Unknown
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Expected O, but got Unknown
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Expected O, but got Unknown
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Expected O, but got Unknown
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Expected O, but got Unknown
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Expected O, but got Unknown
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: Expected O, but got Unknown
		CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
		val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
		{
			new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null)
		});
		val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Action>((Action)delegate
		{
			CruiseAssistor.ReticuleTargetPlanet = null;
			CruiseAssistor.ReticuleTargetStar = null;
		}) });
		val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[7]
		{
			new CodeMatch((OpCode?)OpCodes.Bge_Un, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null)
		});
		val.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
		{
			new CodeInstruction(OpCodes.Ldloc_0, (object)null)
		}).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
		{
			new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(StarData), "planets"))
		})
			.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldloc_S, (object)21)
			})
			.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Action<PlanetData[], int>>((Action<PlanetData[], int>)delegate(PlanetData[] planets, int planetIndex)
			{
				CruiseAssistor.ReticuleTargetPlanet = planets[planetIndex];
			}) });
		val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[7]
		{
			new CodeMatch((OpCode?)OpCodes.Bge_Un, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null),
			new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null)
		});
		val.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
		{
			new CodeInstruction(OpCodes.Ldloc_S, (object)20)
		}).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
		{
			new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(GalaxyData), "stars"))
		})
			.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Ldloc_S, (object)24)
			})
			.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Action<StarData[], int>>((Action<StarData[], int>)delegate(StarData[] stars, int starIndex)
			{
				CruiseAssistor.ReticuleTargetStar = stars[starIndex];
			}) });
		return val.InstructionEnumeration();
	}

	[HarmonyPatch("_OnOpen")]
	[HarmonyPrefix]
	public static void OnOpen_Prefix()
	{
		if (CruiseAssistor.AutoDisableLockCursorFlag)
		{
			UIRoot.instance.uiGame.disableLockCursor = true;
		}
	}

	[HarmonyPatch("_OnClose")]
	[HarmonyPrefix]
	public static void OnClose_Prefix()
	{
		ConfigManager.CheckConfig(ConfigManager.Step.STATE);
	}
}
public struct Tuple<T1, T2>
{
	public T1 v1 { get; set; }

	public T2 v2 { get; set; }

	public Tuple(T1 v1, T2 v2)
	{
		this.v1 = v1;
		this.v2 = v2;
	}
}