LSTM.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LSTM")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LSTM")]
[assembly: AssemblyCopyright("Copyright © 2024 hetima")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("87e23036-abd9-49ee-8782-a6bed450feb4")]
[assembly: AssemblyFileVersion("0.9.3.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.9.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 LSTM
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LSTM";

		public const string PLUGIN_NAME = "LSTM";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LSTMMod
{
	public class ConstructionPoint
	{
		public static class Patch
		{
			public static ItemProto ModLDBItemSelect(ItemProtoSet itemProtoSet, int id)
			{
				ItemProto val = ((ProtoSet<ItemProto>)(object)itemProtoSet).Select(id);
				if (LSTM.setConstructionPointToGround.Value && val?.prefabDesc != null && val.prefabDesc.isStation)
				{
					return null;
				}
				return val;
			}

			[HarmonyTranspiler]
			[HarmonyPatch(typeof(ConstructionSystem), "_obj_hpos", new Type[] { typeof(int) })]
			public static IEnumerable<CodeInstruction> MechaDroneLogic__obj_hpos_Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				List<CodeInstruction> list = instructions.ToList();
				MethodInfo method = typeof(Patch).GetMethod("ModLDBItemSelect");
				for (int i = 0; i < list.Count; i++)
				{
					if (list[i].opcode == OpCodes.Callvirt && list[i].operand is MethodInfo methodInfo && methodInfo.ToString() == "ItemProto Select(Int32)")
					{
						list[i].opcode = OpCodes.Call;
						list[i].operand = method;
						break;
					}
				}
				return list.AsEnumerable();
			}
		}
	}
	[BepInPlugin("com.hetima.dsp.LSTM", "LSTM", "0.9.3")]
	public class LSTM : BaseUnityPlugin
	{
		private static class Patch
		{
			internal static bool _initialized;

			internal static GameObject starmapBtnGO;

			internal static GameObject stationWindowControls;

			private static float _lastClick;

			internal static void AddButtonToStationWindow()
			{
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				UIStationWindow stationWindow = UIRoot.instance.uiGame.stationWindow;
				UIButton val = Util.MakeIconButtonB(Util.astroIndicatorIcon, 22f);
				if ((Object)(object)val != (Object)null)
				{
					((Object)((Component)val).gameObject).name = "lstm-locate-btn";
					RectTransform obj = Util.NormalizeRectD(((Component)val).gameObject);
					((Transform)obj).SetParent((Transform)(object)stationWindow.windowTrans, false);
					obj.anchoredPosition = Vector2.op_Implicit(new Vector3(534f, -60f));
					val.onClick += OnStationWinLocateButtonClick;
					val.tips.tipTitle = "Locate Station";
					val.tips.tipText = "Show navigation to this station";
					val.tips.corner = 8;
					val.tips.offset = new Vector2(0f, 8f);
					stationWindowControls = ((Component)val).gameObject;
					stationWindowControls.SetActive(true);
				}
				UIStationStorage[] array = AccessTools.FieldRefAccess<UIStationWindow, UIStationStorage[]>(stationWindow, "storageUIs");
				for (int i = 0; i < array.Length; i++)
				{
					UIStationStorageAgent.MakeUIStationStorageAgent(array[i]);
				}
				showButtonInStationWindow.SettingChanged += delegate
				{
					foreach (UIStationStorageAgent agent in UIStationStorageAgent.agents)
					{
						agent.RefreshValues();
					}
				};
			}

			internal static void AddButtonToStarmap()
			{
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				UIPlanetDetail planetDetail = UIRoot.instance.uiGame.planetDetail;
				Transform val = ((planetDetail != null) ? ((Component)planetDetail).transform : null);
				if ((Object)(object)val != (Object)null)
				{
					UIButton obj = Util.MakeSmallTextButton("LSTM", 38f, 20f);
					((Object)((Component)obj).gameObject).name = "lstm-show-btn";
					RectTransform obj2 = Util.NormalizeRectD(((Component)obj).gameObject);
					((Transform)obj2).SetParent(val, false);
					obj2.anchoredPosition3D = new Vector3(-2f, -36f, 0f);
					((Transform)obj2).localScale = Vector3.one;
					obj.onClick += OnStarmapButtonClick;
					starmapBtnGO = ((Component)obj).gameObject;
					starmapBtnGO.SetActive(showButtonInStarmap.Value);
					showButtonInStarmap.SettingChanged += delegate
					{
						starmapBtnGO.SetActive(showButtonInStarmap.Value);
					};
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(UIGame), "_OnCreate")]
			public static void UIGame__OnCreate_Prefix()
			{
				if (!_initialized)
				{
					UIStatisticsWindowAgent.PreCreate();
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(UIGame), "_OnCreate")]
			public static void UIGame__OnCreate_Postfix()
			{
				if (!_initialized)
				{
					_initialized = true;
					_configWin = UIConfigWindow.CreateInstance();
					_win = UIBalanceWindow.CreateInstance();
					_logWindow = UILogWindow.CreateInstance();
					TrafficLog.trafficLogDelegate = _logWindow;
					AddButtonToStarmap();
					AddButtonToStationWindow();
					UIStatisticsWindowAgent.PostCreate();
					stationSignRenderer = new StationSignRenderer();
					stationSignRenderer.Init();
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(GameMain), "Begin")]
			public static void GameMain_Begin_Prefix()
			{
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(UIGame), "OnPlayerInspecteeChange")]
			public static void UIGame_OnPlayerInspecteeChange_Prefix(UIGame __instance, EObjectType objType, int objId)
			{
				//IL_000f: 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_0040: Invalid comparison between Unknown and I4
				int planetId = GameMain.mainPlayer.planetId;
				if (planetId > 0 && (int)objType == 0 && objId > 0 && navi.naviLine.entityId == objId && navi.naviLine.planetId == planetId && (int)UIGame.viewMode < 3)
				{
					navi.Disable();
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(PlanetFactory), "RemoveEntityWithComponents")]
			public static void PlanetFactory_RemoveEntityWithComponents_Prefix(PlanetFactory __instance, int id)
			{
				if (navi.naviLine.entityId == id && navi.naviLine.planetId == __instance.planetId)
				{
					navi.Disable();
				}
				if (__instance.entityPool[id].stationId != 0)
				{
					((ManualBehaviour)_win)._Close();
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(UIStationWindow), "OnStationIdChange")]
			public static void UIStationWindow_OnStationIdChange_Postfix(UIStationWindow __instance)
			{
				if (!((Object)(object)stationWindowControls != (Object)null) || !((ManualBehaviour)__instance).active || __instance.stationId == 0 || __instance.factory == null)
				{
					return;
				}
				StationComponent val = __instance.transport.stationPool[__instance.stationId];
				if (val != null || val.id == __instance.stationId)
				{
					if (val.isVeinCollector)
					{
						stationWindowControls.SetActive(false);
					}
					else
					{
						stationWindowControls.SetActive(true);
					}
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(PlayerControlGizmo), "GameTick")]
			public static void PlayerControlGizmo_GameTick_Postfix()
			{
				navi.naviLine.GameTick();
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(EntitySignRenderer), "Draw")]
			public static void Mod_entitySignPool_Postfix(EntitySignRenderer __instance)
			{
				if (GameMain.localPlanet != null && __instance != null)
				{
					stationSignRenderer.Draw(__instance.factory);
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(RaycastLogic), "GameTick")]
			public static void RaycastLogic_GameTick_Postfix()
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Invalid comparison between Unknown and I4
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: 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_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				if ((int)UIGame.viewMode != 3 || !enableNaviToEverywhere.Value || GameMain.localPlanet == null || (!Input.GetMouseButtonDown(0) && !Input.GetMouseButtonDown(1)))
				{
					return;
				}
				float time = Time.time;
				if (_lastClick + 0.035f < time && _lastClick + 0.5f > time)
				{
					Ray val = Camera.main.ScreenPointToRay(Input.mousePosition);
					RCHCPU val2 = default(RCHCPU);
					if (Phys.RayCastSphere(((Ray)(ref val)).origin, ((Ray)(ref val)).direction, 1600f, Vector3.zero, GameMain.localPlanet.realRadius, ref val2))
					{
						navi.Disable();
						navi.SetPointNavi(val2.point + val2.normal * 2f, GameMain.localPlanet.id);
					}
					_lastClick = 0f;
				}
				else
				{
					_lastClick = time;
				}
			}

			public static void SuppressOrOpenInventory(UIGame uiGame)
			{
				if (!suppressOpenInventory.Value)
				{
					uiGame.OpenPlayerInventory();
				}
			}

			[HarmonyTranspiler]
			[HarmonyPatch(typeof(UIGame), "OnPlayerInspecteeChange")]
			public static IEnumerable<CodeInstruction> UIGame_OnPlayerInspecteeChange_Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				List<CodeInstruction> list = instructions.ToList();
				MethodInfo method = typeof(UIGame).GetMethod("OpenStationWindow");
				MethodInfo method2 = typeof(UIGame).GetMethod("OpenPlayerInventory");
				MethodInfo method3 = typeof(Patch).GetMethod("SuppressOrOpenInventory");
				int num = 0;
				for (int num2 = list.Count - 10; num2 > 10; num2--)
				{
					if (list[num2].opcode == OpCodes.Call && list[num2].operand is MethodInfo methodInfo && methodInfo == method && list[num2 - 2].opcode == OpCodes.Call && list[num2 - 2].operand is MethodInfo methodInfo2 && methodInfo2 == method2)
					{
						list[num2 - 2].opcode = OpCodes.Call;
						list[num2 - 2].operand = method3;
						num++;
						break;
					}
				}
				if (num != 1)
				{
					Log("UIGame_OnPlayerInspecteeChange_Transpiler (OpenStationWindow) seems wrong");
				}
				return list.AsEnumerable();
			}
		}

		public const string __NAME__ = "LSTM";

		public const string __GUID__ = "com.hetima.dsp.LSTM";

		public static LSTM instance;

		public static LSTMNavi navi;

		public static UIBalanceWindow _win;

		public static UILogWindow _logWindow;

		public static UIConfigWindow _configWin;

		public static StationSignRenderer stationSignRenderer;

		public static ConfigEntry<KeyboardShortcut> mainWindowHotkey;

		public static ConfigEntry<KeyboardShortcut> logWindowHotkey;

		public static ConfigEntry<KeyboardShortcut> switchDisplayModeHotkey;

		public static ConfigEntry<bool> dropSorterKeyEracesNavi;

		public static ConfigEntry<bool> showButtonInStationWindow;

		public static ConfigEntry<bool> showButtonInStatisticsWindow;

		public static ConfigEntry<bool> showButtonInStarmap;

		public static ConfigEntry<bool> showStatInStatisticsWindow;

		public static ConfigEntry<bool> actAsStandardPanel;

		public static ConfigEntry<bool> indicatesWarperSign;

		public static ConfigEntry<bool> reactClosePanelKeyE;

		public static ConfigEntry<bool> showMaterialPicker;

		public static ConfigEntry<bool> setConstructionPointToGround;

		public static ConfigEntry<bool> showStationInfo;

		public static ConfigEntry<bool> showStationInfoOnlyInPlanetView;

		public static ConfigEntry<float> stationInfoIconSize;

		public static ConfigEntry<bool> enableNaviToEverywhere;

		public static ConfigEntry<bool> hideStoragedSlot;

		public static ConfigEntry<bool> suppressOpenInventory;

		public static ConfigEntry<bool> enableTrafficLog;

		public static bool enableTrafficLogInThisSession;

		public static ConfigEntry<int> trafficLogDisplayMax;

		public static ConfigEntry<bool> _showStatInStatisticsWindow;

		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Expected O, but got Unknown
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Expected O, but got Unknown
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			instance = this;
			navi = new LSTMNavi();
			MyWindowCtl.useMyWindowInterface = true;
			mainWindowHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keyboard Shortcuts", "mainWindowHotkey", KeyboardShortcut.Deserialize("T + LeftControl"), "Hotkey to open/close LSTM window");
			logWindowHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keyboard Shortcuts", "logWindowHotkey", KeyboardShortcut.Deserialize(""), "Hotkey to open/close Traffic Log window");
			switchDisplayModeHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keyboard Shortcuts", "switchDisplayModeHotkey", KeyboardShortcut.Deserialize("Tab"), "Hotkey to switch display mode of LSTM window");
			showButtonInStationWindow = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "showButtonInStationWindow", true, "Add open LSTM button to Station Window (needs restart)");
			showButtonInStatisticsWindow = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "showButtonInStatisticsWindow", false, "Add open LSTM button to Statistics Window");
			showButtonInStarmap = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "showButtonInStarmap", true, "Add open LSTM button to detail panel on starmap");
			showStatInStatisticsWindow = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "showStatInStatisticsWindow", true, "Add station stat to Statistics Window");
			setConstructionPointToGround = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "setConstructionPointToGround", false, "set the construction point to ground instead of top of the tower (currently disabled)");
			actAsStandardPanel = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "actAsStandardPanel", true, "true: close with other panels by esc key. false: one more esc needed");
			dropSorterKeyEracesNavi = ((BaseUnityPlugin)this).Config.Bind<bool>("Keyboard Shortcuts", "dropSorterKeyEracesNavi", false, "clear navi line when \"Remove Copied Sorter Previews\" shortcut is pressed");
			indicatesWarperSign = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "indicatesWarperSign", false, "show sign on the list if station has warper.");
			reactClosePanelKeyE = ((BaseUnityPlugin)this).Config.Bind<bool>("Keyboard Shortcuts", "reactClosePanelKeyE", true, "close window when close panel key(E) is pressed.");
			showMaterialPicker = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "showMaterialPicker", true, "Add Material Picker for quick item switching to LSTM window");
			showStationInfo = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "showStationInfo", false, "Show station contents and empty slot count as icon. Also affected by in-game building icon display setting");
			showStationInfoOnlyInPlanetView = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "showStationInfoOnlyInPlanetView", false, "showStationInfo is only displayed in planet view");
			stationInfoIconSize = ((BaseUnityPlugin)this).Config.Bind<float>("Interface", "stationInfoIconSize", 10f, new ConfigDescription("station Info icon size. min=5.0 max=15.0. default is 10.0f", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 15f), Array.Empty<object>()));
			enableNaviToEverywhere = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "enableNaviToEverywhere", false, "double-click on Planet View to display navigation to anywhere");
			hideStoragedSlot = ((BaseUnityPlugin)this).Config.Bind<bool>("Interface", "hideStoragedSlot", true, "hide storaged slot in list view");
			_showStatInStatisticsWindow = ((BaseUnityPlugin)this).Config.Bind<bool>("Z", "_showStatInStatisticsWindow", true, "Internal setting. Do not change directly");
			suppressOpenInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "suppressOpenInventory", false, "Suppress open inventory when opening station window");
			enableTrafficLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "enableTrafficLog", false, "Enable traffic log window (needs restart game)");
			trafficLogDisplayMax = ((BaseUnityPlugin)this).Config.Bind<int>("Other", "trafficLogDisplayMax", 2000, new ConfigDescription("Maximum rows that can be displayed in the log window. min=100 max=9999. original behavior is 2000", (AcceptableValueBase)(object)new AcceptableValueRange<int>(100, 9999), Array.Empty<object>()));
			enableTrafficLogInThisSession = enableTrafficLog.Value;
			Harmony val = new Harmony("com.hetima.dsp.LSTM");
			val.PatchAll(typeof(Patch));
			val.PatchAll(typeof(LSTMStarDistance.Patch));
			val.PatchAll(typeof(MyWindowCtl.Patch));
			val.PatchAll(typeof(UIStatisticsWindowAgent.Patch));
			val.PatchAll(typeof(UIStationStorageAgent.Patch));
			if (enableTrafficLogInThisSession)
			{
				val.PatchAll(typeof(TrafficLog.Patch));
			}
		}

		public static void Log(string str)
		{
			Logger.LogInfo((object)str);
		}

		public static int RemoteStationMaxItemCount()
		{
			return 10000 + GameMain.history.remoteStationExtraStorage;
		}

		public static void OpenBalanceWindow(StationComponent targetStation, int index, bool isLocal, PlanetFactory targetFactory = null)
		{
			int num = ((targetFactory != null) ? targetFactory.planetId : 0);
			_win.SetUpAndOpen(targetStation.storage[index].itemId, isLocal ? num : 0, isLocal);
		}

		public static void OpenBalanceWindow(int itemId, int planetId = 0, int starId = 0)
		{
			_win.SetUpAndOpen(itemId, planetId, _isLocal: false, starId);
		}

		public static void OpenBalanceWindow()
		{
			_win.SetUpAndOpen(0, 0, _isLocal: true);
		}

		public static void OpenStationWindow(StationComponent station, int planetId)
		{
			if (GameMain.mainPlayer.factory != null && planetId == GameMain.mainPlayer.factory.planetId && station != null)
			{
				_win.keepOpen = true;
				GameMain.mainPlayer.controller.actionInspect.SetInspectee((EObjectType)0, station.entityId);
				_win.keepOpen = false;
			}
		}

		public static void IntegrationOpenPlanetId(int planetId)
		{
			_win.SetUpAndOpen(0, planetId, _isLocal: false);
		}

		public static void IntegrationOpenItemId(int itemId)
		{
			_win.SetUpAndOpen(itemId, 0, _isLocal: false);
		}

		public static void LocateStation(StationComponent station, int planetId)
		{
			navi.Disable();
			if (planetId <= 0)
			{
				return;
			}
			_win.keepOpen = true;
			int num = ((GameMain.localPlanet != null) ? GameMain.localPlanet.id : 0);
			if (station != null)
			{
				navi.SetStationNavi(station, planetId);
			}
			if (num != planetId || ((ManualBehaviour)UIRoot.instance.uiGame.starmap).active)
			{
				if (GameMain.history.universeObserveLevel >= 4)
				{
					UIRoot.instance.uiGame.ShutPlayerInventory();
					UIRoot.instance.uiGame.ShutAllFunctionWindow();
					UIRoot.instance.uiGame.OpenStarmap();
					int num2 = planetId / 100 - 1;
					int num3 = planetId % 100 - 1;
					UIStarmap starmap = UIRoot.instance.uiGame.starmap;
					if (GameMain.galaxy.PlanetById(planetId) != null)
					{
						starmap.focusPlanet = null;
						starmap.focusStar = starmap.starUIs[num2];
						starmap.OnCursorFunction2Click(0);
						if ((Object)(object)starmap.focusStar == (Object)null)
						{
							starmap.focusPlanet = starmap.planetUIs[num3];
							starmap.OnCursorFunction2Click(0);
							starmap.focusPlanet = starmap.planetUIs[num3];
							starmap.focusStar = null;
						}
					}
				}
				else
				{
					UIMessageBox.Show(Localization.Translate("Upgrades Required"), Localization.Translate("To use this feature, Universe Exploration 4 is required."), "OK", 0);
				}
			}
			_win.keepOpen = false;
		}

		public static void OnStarmapButtonClick(int obj)
		{
			PlanetData planet = UIRoot.instance.uiGame.planetDetail.planet;
			if (planet != null)
			{
				_win.SetUpAndOpen(0, planet.id, _isLocal: false);
			}
		}

		public static void OnStationWinLocateButtonClick(int obj)
		{
			UIStationWindow stationWindow = UIRoot.instance.uiGame.stationWindow;
			LocateStation(stationWindow.transport.stationPool[stationWindow.stationId], stationWindow.transport.planet.id);
		}

		public static void ToggleBalanceWindow()
		{
			int num = ItemIdHintUnderMouse();
			if (num > 0)
			{
				_win.SetUpAndOpen(num, 0, _isLocal: false);
			}
			else if (((ManualBehaviour)_win).active)
			{
				((ManualBehaviour)_win)._Close();
			}
			else
			{
				_win.OpenWithoutSetting();
			}
		}

		public static void ToggleLogWindow()
		{
			if (((ManualBehaviour)_logWindow).active)
			{
				((ManualBehaviour)_logWindow)._Close();
			}
			else
			{
				_logWindow.OpenWithoutSetting();
			}
		}

		public static int ItemIdHintUnderMouse()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			List<RaycastResult> list = new List<RaycastResult>();
			PointerEventData val = new PointerEventData(EventSystem.current);
			val.position = Vector2.op_Implicit(Input.mousePosition);
			EventSystem.current.RaycastAll(val, list);
			foreach (RaycastResult item in list)
			{
				RaycastResult current = item;
				UIButton componentInParent = ((RaycastResult)(ref current)).gameObject.GetComponentInParent<UIButton>();
				if (componentInParent != null)
				{
					_ = componentInParent.tips;
					if (componentInParent.tips.itemId > 0)
					{
						return componentInParent.tips.itemId;
					}
				}
				if ((Object)(object)((RaycastResult)(ref current)).gameObject.GetComponentInParent<UIBalanceWindow>() != (Object)null)
				{
					return 0;
				}
				UIReplicatorWindow componentInParent2 = ((RaycastResult)(ref current)).gameObject.GetComponentInParent<UIReplicatorWindow>();
				if ((Object)(object)componentInParent2 != (Object)null)
				{
					int num = AccessTools.FieldRefAccess<UIReplicatorWindow, int>(componentInParent2, "mouseRecipeIndex");
					RecipeProto[] array = AccessTools.FieldRefAccess<UIReplicatorWindow, RecipeProto[]>(componentInParent2, "recipeProtoArray");
					if (num < 0)
					{
						return 0;
					}
					RecipeProto val2 = array[num];
					if (val2 != null)
					{
						return val2.Results[0];
					}
					return 0;
				}
				UIStorageGrid componentInParent3 = ((RaycastResult)(ref current)).gameObject.GetComponentInParent<UIStorageGrid>();
				if ((Object)(object)componentInParent3 != (Object)null)
				{
					StorageComponent val3 = AccessTools.FieldRefAccess<UIStorageGrid, StorageComponent>(componentInParent3, "storage");
					int num2 = AccessTools.FieldRefAccess<UIStorageGrid, int>(componentInParent3, "mouseOnX");
					int num3 = AccessTools.FieldRefAccess<UIStorageGrid, int>(componentInParent3, "mouseOnY");
					if (num2 >= 0 && num3 >= 0 && val3 != null)
					{
						int num4 = num2 + num3 * componentInParent3.colCount;
						return val3.grids[num4].itemId;
					}
					return 0;
				}
				UIProductEntry componentInParent4 = ((RaycastResult)(ref current)).gameObject.GetComponentInParent<UIProductEntry>();
				if ((Object)(object)componentInParent4 != (Object)null)
				{
					if (componentInParent4.productionStatWindow.isProductionTab)
					{
						return componentInParent4.entryData?.itemId ?? 0;
					}
					return 0;
				}
			}
			return 0;
		}

		private void Update()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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)
			if (!GameMain.isRunning || GameMain.isPaused || GameMain.instance.isMenuDemo || VFInput.inputing)
			{
				return;
			}
			KeyboardShortcut value = mainWindowHotkey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				ToggleBalanceWindow();
				return;
			}
			value = logWindowHotkey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				if (enableTrafficLogInThisSession)
				{
					ToggleLogWindow();
				}
			}
			else if (reactClosePanelKeyE.Value && VFInput._closePanelE && ((ManualBehaviour)_win).active)
			{
				((ManualBehaviour)_win)._Close();
			}
		}

		private void FixedUpdate()
		{
			if (((Object)(object)_win != (Object)null && _win.isPointEnter) || ((Object)(object)_logWindow != (Object)null && _logWindow.isPointEnter))
			{
				VFInput.inScrollView = true;
			}
		}
	}
	public class LSTMNavi : NaviLineDelegate
	{
		public NaviLine naviLine;

		public GameObject naviPop;

		internal bool _initialized;

		public static GameObject MakeNaviPop(LSTMNavi navi)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			UIButton extractButton = UIRoot.instance.uiGame.functionPanel.extractButton;
			UIButton obj = Object.Instantiate<UIButton>(extractButton, ((Component)extractButton).transform.parent);
			((Object)((Component)obj).gameObject).name = "lstm-clear-navi-btn";
			Vector3 localPosition = ((Component)obj).transform.localPosition;
			localPosition.x -= 200f;
			((Component)obj).transform.localPosition = localPosition;
			((Component)obj).gameObject.SetActive(false);
			Util.RemovePersistentCalls(((Component)obj).gameObject);
			Button button = obj.button;
			if (button != null)
			{
				((UnityEvent)button.onClick).AddListener(new UnityAction(navi.NaviLineTipClicked));
			}
			Transform obj2 = ((Component)obj).transform.Find("text");
			Text val = ((obj2 != null) ? ((Component)obj2).GetComponent<Text>() : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				Object.Destroy((Object)(object)((Component)val).gameObject.GetComponent<Localizer>());
				val.fontSize += 2;
				val.text = Localization.Translate("Click here to clear navi");
			}
			Transform obj3 = ((Component)obj).transform.Find("icon");
			Image val2 = ((obj3 != null) ? ((Component)obj3).GetComponent<Image>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				val2.sprite = Util.astroIndicatorIcon;
			}
			return ((Component)obj).gameObject;
		}

		public static UIKeyTipNode MakeNaviTip(LSTMNavi navi)
		{
			//IL_0024: 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_0045: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0072: 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_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)
			//IL_0095: 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_00a6: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			UIKeyTipNode val = UIRoot.instance.uiGame.keyTips.RegisterTip("Navi", "Click here to erase");
			GameObject val2 = new GameObject("button");
			Image val3 = val2.AddComponent<Image>();
			((Graphic)val3).color = new Color(1f, 0.25f, 0f, 0.27f);
			Button obj = val2.AddComponent<Button>();
			((Selectable)obj).targetGraphic = (Graphic)(object)val3;
			((UnityEvent)obj.onClick).AddListener(new UnityAction(navi.NaviLineTipClicked));
			val2.transform.SetParent(((Component)val).transform, false);
			Vector2 sizeDelta = ((RectTransform)((Component)val).transform).sizeDelta;
			Util.NormalizeRectC(val2, sizeDelta.x, sizeDelta.y).anchoredPosition = Vector2.zero;
			return val;
		}

		public void NaviLineTipClicked()
		{
			naviLine.Disable(reset: true);
			GameObject obj = naviPop;
			if (obj != null)
			{
				obj.SetActive(false);
			}
		}

		public LSTMNavi()
		{
			naviLine = new NaviLine();
			naviLine.autoDisappear = true;
			naviLine._delegate = this;
		}

		public void NaviLineWillAppear(NaviLine naviLine)
		{
			if (!_initialized)
			{
				_initialized = true;
				naviPop = MakeNaviPop(this);
			}
			GameObject obj = naviPop;
			if (obj != null)
			{
				obj.SetActive(true);
			}
		}

		public void NaviLineWillDisappear(NaviLine naviLine)
		{
			GameObject obj = naviPop;
			if (obj != null)
			{
				obj.SetActive(false);
			}
		}

		public void NaviLineDidGameTick(NaviLine naviLine)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)naviPop == (Object)null)
			{
				return;
			}
			if ((int)UIGame.viewMode >= 3)
			{
				naviPop.SetActive(false);
				return;
			}
			if (LSTM.dropSorterKeyEracesNavi.Value && VFInput._cancelTemplateInserter.onDown && !VFInput.inputing)
			{
				Disable();
			}
			naviPop.SetActive((Object)(object)naviLine.lineGizmo != (Object)null);
		}

		public void SetStationNavi(StationComponent station, int planetId)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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)
			EntityData[] array = GameMain.galaxy.PlanetById(planetId)?.factory?.entityPool;
			if (array != null && array[station.entityId].stationId == station.id)
			{
				Vector3 pos = array[station.entityId].pos;
				naviLine.planetId = planetId;
				naviLine.entityId = station.entityId;
				naviLine.endPoint = pos + ((Vector3)(ref pos)).normalized * 8f;
			}
		}

		public void SetPointNavi(Vector3 pos, int planetId)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			naviLine.planetId = planetId;
			naviLine.entityId = 0;
			naviLine.endPoint = pos;
		}

		public void Disable()
		{
			naviLine.Disable(reset: true);
		}
	}
	public class MyCheckBox : MonoBehaviour
	{
		public UIButton uiButton;

		public Image checkImage;

		public RectTransform rectTrans;

		public Text labelText;

		public ConfigEntry<bool> config;

		public static RectTransform CreateCheckBox(ConfigEntry<bool> config, string label = "", int fontSize = 17)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(((Component)UIRoot.instance.uiGame.buildMenu.uxFacilityCheck).gameObject);
			((Object)val).name = "my-checkbox";
			MyCheckBox cb = val.AddComponent<MyCheckBox>();
			cb.config = config;
			Transform transform = val.transform;
			RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			cb.rectTrans = val2;
			ResetAnchor(val2);
			val2.anchoredPosition3D = new Vector3(0f, 0f, 0f);
			cb.uiButton = val.GetComponent<UIButton>();
			MyCheckBox myCheckBox = cb;
			Transform obj = val.transform.Find("checked");
			myCheckBox.checkImage = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
			Transform val3 = val.transform.Find("text");
			if ((Object)(object)val3 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)((Component)val3).GetComponent<Localizer>());
				cb.labelText = ((Component)val3).GetComponent<Text>();
				cb.labelText.fontSize = fontSize;
				cb.SetLabelText(label);
			}
			cb.uiButton.onClick += cb.OnClick;
			cb.SettingChanged();
			config.SettingChanged += delegate
			{
				cb.SettingChanged();
			};
			return cb.rectTrans;
			static void ResetAnchor(RectTransform rect_)
			{
				//IL_0001: 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)
				rect_.anchorMax = Vector2.zero;
				rect_.anchorMin = Vector2.zero;
			}
		}

		public void SetLabelText(string val)
		{
			if ((Object)(object)labelText != (Object)null)
			{
				labelText.text = val;
			}
		}

		public void SettingChanged()
		{
			if (config.Value != ((Behaviour)checkImage).enabled)
			{
				((Behaviour)checkImage).enabled = config.Value;
			}
		}

		public void OnClick(int obj)
		{
			config.Value = !config.Value;
		}
	}
	public class MyKeyBinder : MonoBehaviour
	{
		public ConfigEntry<KeyboardShortcut> config;

		[SerializeField]
		public Text functionText;

		[SerializeField]
		public Text keyText;

		[SerializeField]
		public InputField setTheKeyInput;

		[SerializeField]
		public Toggle setTheKeyToggle;

		[SerializeField]
		public RectTransform rectTrans;

		[SerializeField]
		public UIButton inputUIButton;

		[SerializeField]
		public Text conflictText;

		[SerializeField]
		public Text waitingText;

		[SerializeField]
		public UIButton setDefaultUIButton;

		[SerializeField]
		public UIButton setNoneKeyUIButton;

		private bool nextNotOn;

		private KeyCode _lastKey;

		private static KeyCode[] modKeys;

		public static RectTransform CreateKeyBinder(ConfigEntry<KeyboardShortcut> config, string label = "")
		{
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			UIKeyEntry val = Object.Instantiate<UIKeyEntry>(UIRoot.instance.optionWindow.entryPrefab);
			((Component)val).gameObject.SetActive(true);
			GameObject gameObject = ((Component)val).gameObject;
			((Object)gameObject).name = "my-keybinder";
			MyKeyBinder kb = gameObject.AddComponent<MyKeyBinder>();
			kb.config = config;
			kb.functionText = val.functionText;
			kb.keyText = val.keyText;
			kb.setTheKeyInput = val.setTheKeyInput;
			kb.setTheKeyToggle = val.setTheKeyToggle;
			kb.rectTrans = val.rectTrans;
			kb.inputUIButton = val.inputUIButton;
			kb.conflictText = val.conflictText;
			kb.waitingText = val.waitingText;
			kb.setDefaultUIButton = val.setDefaultUIButton;
			kb.setNoneKeyUIButton = val.setNoneKeyUIButton;
			kb.functionText.text = label;
			kb.functionText.fontSize = 17;
			Transform transform = ((Component)kb.keyText).transform;
			((RectTransform)((transform is RectTransform) ? transform : null)).anchoredPosition = new Vector2(20f, -22f);
			kb.keyText.fontSize = 17;
			Transform transform2 = ((Component)((Component)kb.inputUIButton).transform.parent).transform;
			((RectTransform)((transform2 is RectTransform) ? transform2 : null)).anchoredPosition = new Vector2(20f, -52f);
			Transform transform3 = ((Component)kb.setDefaultUIButton).transform;
			((RectTransform)((transform3 is RectTransform) ? transform3 : null)).anchoredPosition = new Vector2(160f, -52f);
			Transform transform4 = ((Component)kb.setNoneKeyUIButton).transform;
			((RectTransform)((transform4 is RectTransform) ? transform4 : null)).anchoredPosition = new Vector2(260f, -52f);
			Transform transform5 = gameObject.transform;
			Transform obj = ((transform5 is RectTransform) ? transform5 : null);
			ResetAnchor((RectTransform)(object)obj);
			Object.Destroy((Object)(object)val);
			((Component)kb.setNoneKeyUIButton).gameObject.SetActive(false);
			kb.SettingChanged();
			config.SettingChanged += delegate
			{
				kb.SettingChanged();
			};
			kb.inputUIButton.onClick += kb.OnInputUIButtonClick;
			kb.setDefaultUIButton.onClick += kb.OnSetDefaultKeyClick;
			return (RectTransform)(object)obj;
			static void ResetAnchor(RectTransform rect_)
			{
				//IL_0001: 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)
				rect_.anchorMax = Vector2.zero;
				rect_.anchorMin = Vector2.zero;
			}
		}

		private void Update()
		{
			if (!setTheKeyToggle.isOn && inputUIButton.highlighted)
			{
				setTheKeyToggle.isOn = true;
			}
			if (!setTheKeyToggle.isOn)
			{
				return;
			}
			if (!inputUIButton._isPointerEnter && Input.GetKeyDown((KeyCode)323))
			{
				inputUIButton.highlighted = false;
				setTheKeyToggle.isOn = false;
				Reset();
				return;
			}
			if (!inputUIButton.highlighted)
			{
				setTheKeyToggle.isOn = false;
				Reset();
				return;
			}
			((Component)waitingText).gameObject.SetActive(true);
			if (TrySetValue())
			{
				setTheKeyToggle.isOn = false;
				inputUIButton.highlighted = false;
				Reset();
			}
		}

		public bool TrySetValue()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKey((KeyCode)27))
			{
				VFInput.UseEscape();
				return true;
			}
			if (Input.GetKey((KeyCode)323) || Input.GetKey((KeyCode)324))
			{
				return true;
			}
			if (!GetIunptKeys() && (int)_lastKey != 0)
			{
				string pressedKey = GetPressedKey();
				if (string.IsNullOrEmpty(pressedKey))
				{
					return false;
				}
				_lastKey = (KeyCode)0;
				config.Value = KeyboardShortcut.Deserialize(pressedKey);
				return true;
			}
			return false;
		}

		public string GetPressedKey()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			string text = ((object)(KeyCode)(ref _lastKey)).ToString();
			if (string.IsNullOrEmpty(text))
			{
				return null;
			}
			string text2 = "";
			KeyCode[] array = modKeys;
			for (int i = 0; i < array.Length; i++)
			{
				KeyCode val = array[i];
				if (Input.GetKey(val))
				{
					text2 = text2 + "+" + ((object)(KeyCode)(ref val)).ToString();
				}
			}
			if (!string.IsNullOrEmpty(text2))
			{
				text += text2;
			}
			return text;
		}

		public bool GetIunptKeys()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			bool result = false;
			new List<KeyCode>();
			foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
			{
				if ((int)value != 0 && !modKeys.Contains(value) && Input.GetKey(value))
				{
					_lastKey = value;
					result = true;
				}
			}
			return result;
		}

		public void Reset()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			((Component)conflictText).gameObject.SetActive(false);
			((Component)waitingText).gameObject.SetActive(false);
			((Selectable)setDefaultUIButton.button).Select();
			_lastKey = (KeyCode)0;
		}

		public void OnInputUIButtonClick(int data)
		{
			inputUIButton.highlighted = true;
			if (nextNotOn)
			{
				nextNotOn = false;
				inputUIButton.highlighted = false;
				setTheKeyToggle.isOn = false;
				((Component)waitingText).gameObject.SetActive(false);
			}
		}

		public void OnSetDefaultKeyClick(int data)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			config.Value = (KeyboardShortcut)((ConfigEntryBase)config).DefaultValue;
			Text obj = keyText;
			KeyboardShortcut value = config.Value;
			obj.text = ((KeyboardShortcut)(ref value)).Serialize();
		}

		public void OnSetNoneKeyClick(int data)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			config.Value = (KeyboardShortcut)((ConfigEntryBase)config).DefaultValue;
			Text obj = keyText;
			KeyboardShortcut value = config.Value;
			obj.text = ((KeyboardShortcut)(ref value)).Serialize();
		}

		public void SettingChanged()
		{
			//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)
			Text obj = keyText;
			KeyboardShortcut value = config.Value;
			obj.text = ((KeyboardShortcut)(ref value)).Serialize();
		}

		static MyKeyBinder()
		{
			KeyCode[] array = new KeyCode[12];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			modKeys = (KeyCode[])(object)array;
		}
	}
	public class MyListView : MonoBehaviour
	{
		public RecyclingListView recyclingListView;

		public ScrollRect m_ScrollRect;

		public static MyListView CreateListView(MonoBehaviour preFab, RecyclingListView.ItemDelegate dlgt, string goName = "", Transform parent = null, float vsWidth = 16f)
		{
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(((Component)UIRoot.instance.uiGame.tutorialWindow.entryList).gameObject);
			if ((Object)(object)parent != (Object)null)
			{
				val.transform.SetParent(parent, false);
			}
			if (!string.IsNullOrEmpty(goName))
			{
				((Object)val).name = goName;
			}
			UIListView component = val.GetComponent<UIListView>();
			GameObject gameObject = ((Component)component.m_ContentPanel).gameObject;
			MyListView myListView = val.AddComponent<MyListView>();
			myListView.recyclingListView = gameObject.AddComponent<RecyclingListView>();
			Object.Destroy((Object)(object)gameObject.transform.GetChild(0));
			gameObject.transform.DetachChildren();
			myListView.recyclingListView.ChildPrefab = preFab;
			myListView.recyclingListView.ItemCallback = dlgt;
			myListView.m_ScrollRect = component.m_ScrollRect;
			myListView.recyclingListView.scrollRect = myListView.m_ScrollRect;
			((Component)myListView.recyclingListView.scrollRect.horizontalScrollbar).gameObject.SetActive(false);
			((Component)myListView.recyclingListView.scrollRect.verticalScrollbar).gameObject.SetActive(true);
			myListView.recyclingListView.scrollRect.vertical = true;
			myListView.recyclingListView.scrollRect.horizontal = false;
			myListView.recyclingListView.RowPadding = 4f;
			Image component2 = ((Component)myListView.recyclingListView.scrollRect.verticalScrollbar).GetComponent<Image>();
			if ((Object)(object)component2 != (Object)null)
			{
				((Graphic)component2).color = new Color(0f, 0f, 0f, 0.62f);
			}
			Transform transform = ((Component)myListView.recyclingListView.scrollRect.verticalScrollbar).transform;
			RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			val2.sizeDelta = new Vector2(vsWidth, val2.sizeDelta.y);
			Object.Destroy((Object)(object)component.m_ContentPanel);
			Object.Destroy((Object)(object)component);
			return myListView;
		}

		public void Clear()
		{
			recyclingListView.Clear();
		}

		public void SetItemCount(int num)
		{
			recyclingListView.RowCount = num;
		}
	}
	public class MySlider : MonoBehaviour
	{
		public Slider slider;

		public RectTransform rectTrans;

		public Text labelText;

		public string labelFormat;

		public ConfigEntry<float> config;

		private bool _sliderEventLock;

		public static RectTransform CreateSlider(ConfigEntry<float> config, float minValue, float maxValue, string format = "{0}", float width = 0f)
		{
			//IL_0075: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(((Component)UIRoot.instance.optionWindow.audioVolumeComp).gameObject);
			((Object)val).name = "my-slider";
			val.SetActive(true);
			MySlider sl = val.AddComponent<MySlider>();
			sl.config = config;
			Transform transform = val.transform;
			RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			sl.rectTrans = val2;
			ResetAnchor(val2);
			if (width > 0f)
			{
				val2.sizeDelta = new Vector2(width, val2.sizeDelta.y);
			}
			sl.slider = val.GetComponent<Slider>();
			sl.slider.minValue = minValue;
			sl.slider.maxValue = maxValue;
			((UnityEventBase)sl.slider.onValueChanged).RemoveAllListeners();
			((UnityEvent<float>)(object)sl.slider.onValueChanged).AddListener((UnityAction<float>)sl.SliderChanged);
			MySlider mySlider = sl;
			Slider obj = sl.slider;
			object obj2;
			if (obj == null)
			{
				obj2 = null;
			}
			else
			{
				RectTransform handleRect = obj.handleRect;
				if (handleRect == null)
				{
					obj2 = null;
				}
				else
				{
					Transform obj3 = ((Transform)handleRect).Find("Text");
					obj2 = ((obj3 != null) ? ((Component)obj3).GetComponent<Text>() : null);
				}
			}
			mySlider.labelText = (Text)obj2;
			if ((Object)(object)sl.labelText != (Object)null)
			{
				sl.labelText.fontSize = 14;
				Transform transform2 = ((Component)sl.labelText).transform;
				((RectTransform)((transform2 is RectTransform) ? transform2 : null)).sizeDelta = new Vector2(22f, 22f);
			}
			sl.labelFormat = format;
			Transform obj4 = ((Component)sl.slider).transform.Find("Background");
			Image val3 = ((obj4 != null) ? ((Component)obj4).GetComponent<Image>() : null);
			if ((Object)(object)val3 != (Object)null)
			{
				((Graphic)val3).color = new Color(0.5f, 0.5f, 0.5f, 0.5f);
			}
			Image component = ((Component)sl.slider.fillRect).GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				((Graphic)component).color = new Color(1f, 1f, 1f, 0.28f);
			}
			sl.SettingChanged();
			sl.UpdateLabel();
			config.SettingChanged += delegate
			{
				sl.SettingChanged();
			};
			return sl.rectTrans;
			static void ResetAnchor(RectTransform rect_)
			{
				//IL_0001: 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_0026: Unknown result type (might be due to invalid IL or missing references)
				rect_.anchorMax = Vector2.zero;
				rect_.anchorMin = Vector2.zero;
				rect_.anchoredPosition3D = new Vector3(0f, 0f, 0f);
			}
		}

		public void SettingChanged()
		{
			if (_sliderEventLock)
			{
				return;
			}
			_sliderEventLock = true;
			if (config.Value != slider.value)
			{
				float num = config.Value;
				if (num > slider.maxValue)
				{
					num = slider.maxValue;
				}
				else if (num < slider.minValue)
				{
					num = slider.minValue;
				}
				slider.value = num;
				UpdateLabel();
			}
			_sliderEventLock = false;
		}

		public void UpdateLabel()
		{
			if ((Object)(object)labelText != (Object)null)
			{
				labelText.text = config.Value.ToString(labelFormat);
			}
		}

		public void SliderChanged(float val)
		{
			if (!_sliderEventLock)
			{
				_sliderEventLock = true;
				float value = Mathf.Round(slider.value);
				config.Value = value;
				UpdateLabel();
				_sliderEventLock = false;
			}
		}
	}
	public interface MyWindow
	{
		void TryClose();

		bool isFunctionWindow();
	}
	public static class MyWindowCtl
	{
		public static class Patch
		{
			[HarmonyPostfix]
			[HarmonyPatch(typeof(UIGame), "_OnCreate")]
			public static void UIGame__OnCreate_Postfix()
			{
				_created = true;
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(UIGame), "_OnDestroy")]
			public static void UIGame__OnDestroy_Postfix()
			{
				foreach (ManualBehaviour window in _windows)
				{
					window._Destroy();
				}
				_windows.Clear();
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(UIGame), "_OnInit")]
			public static void UIGame__OnInit_Postfix(UIGame __instance)
			{
				foreach (ManualBehaviour window in _windows)
				{
					window._Init(window.data);
				}
				_inited = true;
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(UIGame), "_OnFree")]
			public static void UIGame__OnFree_Postfix()
			{
				foreach (ManualBehaviour window in _windows)
				{
					window._Free();
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(UIGame), "_OnUpdate")]
			public static void UIGame__OnUpdate_Postfix()
			{
				if (GameMain.isPaused || !GameMain.isRunning)
				{
					return;
				}
				foreach (ManualBehaviour window in _windows)
				{
					window._Update();
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(UIGame), "ShutAllFunctionWindow")]
			public static void UIGame_ShutAllFunctionWindow_Postfix()
			{
				foreach (ManualBehaviour window in _windows)
				{
					if (useMyWindowInterface)
					{
						if ((window as MyWindow).isFunctionWindow())
						{
							(window as MyWindow).TryClose();
						}
					}
					else
					{
						window._Close();
					}
				}
			}
		}

		public static bool useMyWindowInterface = false;

		public static List<ManualBehaviour> _windows = new List<ManualBehaviour>(4);

		internal static bool _created = false;

		internal static bool _inited = false;

		public static T CreateWindow<T>(string name, string title = "") where T : Component
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			UITankWindow tankWindow = UIRoot.instance.uiGame.tankWindow;
			GameObject val = Object.Instantiate<GameObject>(((Component)tankWindow).gameObject, ((Component)tankWindow).transform.parent);
			((Object)val).name = name;
			val.SetActive(false);
			Object.Destroy((Object)(object)val.GetComponent<UITankWindow>());
			object obj = val.AddComponent<T>();
			ManualBehaviour val2 = (ManualBehaviour)((obj is ManualBehaviour) ? obj : null);
			for (int i = 0; i < val.transform.childCount; i++)
			{
				GameObject gameObject = ((Component)val.transform.GetChild(i)).gameObject;
				if (((Object)gameObject).name == "panel-bg")
				{
					Button componentInChildren = gameObject.GetComponentInChildren<Button>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						((UnityEvent)componentInChildren.onClick).AddListener(new UnityAction(val2._Close));
					}
				}
				else if (((Object)gameObject).name != "shadow" && ((Object)gameObject).name != "panel-bg")
				{
					Object.Destroy((Object)(object)gameObject);
				}
			}
			SetTitle(val2, title);
			val2._Create();
			if (_inited)
			{
				val2._Init(val2.data);
			}
			_windows.Add(val2);
			return (T)(object)((val2 is T) ? val2 : null);
		}

		public static void SetTitle(ManualBehaviour win, string title)
		{
			Text titleText = GetTitleText(win);
			if (Object.op_Implicit((Object)(object)titleText))
			{
				titleText.text = title;
			}
		}

		public static Text GetTitleText(ManualBehaviour win)
		{
			Transform obj = ((Component)win).gameObject.transform.Find("panel-bg/title-text");
			if (obj == null)
			{
				return null;
			}
			return ((Component)obj).gameObject.GetComponent<Text>();
		}

		public static RectTransform GetRectTransform(ManualBehaviour win)
		{
			return ((Component)win).GetComponent<RectTransform>();
		}

		public static void SetRect(ManualBehaviour win, RectTransform rect)
		{
			((Component)win).GetComponent<RectTransform>();
		}

		public static void OpenWindow(ManualBehaviour win)
		{
			win._Open();
			((Component)win).transform.SetAsLastSibling();
		}

		public static void CloseWindow(ManualBehaviour win)
		{
			win._Close();
		}
	}
	public interface NaviLineDelegate
	{
		void NaviLineWillAppear(NaviLine naviLine);

		void NaviLineWillDisappear(NaviLine naviLine);

		void NaviLineDidGameTick(NaviLine naviLine);
	}
	public class NaviLine
	{
		public Vector3 endPoint;

		public int planetId;

		public int entityId;

		public bool autoDisappear;

		public float autoDisappearDistance = 500f;

		public NaviLineDelegate _delegate;

		public LineGizmo lineGizmo;

		public void GameTick()
		{
			if (planetId > 0)
			{
				Draw();
				_delegate?.NaviLineDidGameTick(this);
			}
		}

		public void Draw()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			if (GameMain.isPaused || planetId <= 0)
			{
				return;
			}
			if (GameMain.localPlanet != null && GameMain.localPlanet.id == planetId)
			{
				if ((Object)(object)lineGizmo == (Object)null)
				{
					Enable();
				}
				Vector3 position = GameMain.mainPlayer.position;
				Vector3 val = GameMain.mainPlayer.position;
				Vector3 val2 = position + ((Vector3)(ref val)).normalized * 4f;
				if (autoDisappear && Time.frameCount % 30 == 0)
				{
					val = val2 - endPoint;
					if (((Vector3)(ref val)).sqrMagnitude < autoDisappearDistance)
					{
						Disable(reset: true);
						return;
					}
				}
				lineGizmo.startPoint = val2;
				lineGizmo.endPoint = endPoint;
			}
			else if (Object.op_Implicit((Object)(object)lineGizmo))
			{
				Disable();
			}
		}

		public void Enable()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)lineGizmo == (Object)null)
			{
				_delegate?.NaviLineWillAppear(this);
				lineGizmo = LineGizmo.Create(1, Vector3.zero, Vector3.zero);
				lineGizmo.autoRefresh = true;
				lineGizmo.multiplier = 5f;
				lineGizmo.alphaMultiplier = 0.6f;
				lineGizmo.width = 3f;
				lineGizmo.color = Configs.builtin.gizmoColors[4];
				lineGizmo.spherical = true;
				((GizmoBase)lineGizmo).Open();
			}
		}

		public void Disable(bool reset = false)
		{
			if ((Object)(object)lineGizmo != (Object)null)
			{
				_delegate?.NaviLineWillDisappear(this);
				((GizmoBase)lineGizmo).Close();
				lineGizmo = null;
			}
			if (reset)
			{
				planetId = 0;
				entityId = 0;
			}
		}

		public void UpdatePoint(Vector3 startPoint, Vector3 endPoint)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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)
			if ((Object)(object)lineGizmo != (Object)null)
			{
				lineGizmo.startPoint = startPoint;
				lineGizmo.endPoint = endPoint;
			}
		}
	}
	public class RecyclingListView : MonoBehaviour
	{
		public delegate void ItemDelegate(MonoBehaviour item, int rowIndex);

		[Tooltip("Prefab for all the child view objects in the list")]
		public MonoBehaviour ChildPrefab;

		[Tooltip("The amount of vertical padding to add between items")]
		public float RowPadding = 4f;

		[Tooltip("Minimum height to pre-allocate list items for. Use to prevent allocations on resizing.")]
		public float PreAllocHeight = 100f;

		protected int rowCount;

		public ItemDelegate ItemCallback;

		public ScrollRect scrollRect;

		public MonoBehaviour[] childItems;

		protected int childBufferStart;

		protected int sourceDataRowStart;

		protected bool ignoreScrollChange;

		protected float previousBuildHeight;

		protected const int rowsAboveBelow = 1;

		public float VerticalNormalizedPosition
		{
			get
			{
				return scrollRect.verticalNormalizedPosition;
			}
			set
			{
				scrollRect.verticalNormalizedPosition = value;
			}
		}

		public int RowCount
		{
			get
			{
				return rowCount;
			}
			set
			{
				if (rowCount != value)
				{
					rowCount = value;
					ignoreScrollChange = true;
					UpdateContentHeight();
					ignoreScrollChange = false;
					ReorganiseContent(clearContents: true);
				}
			}
		}

		public virtual void Refresh()
		{
			ReorganiseContent(clearContents: true);
		}

		public virtual void Refresh(int rowStart, int count)
		{
			int num = sourceDataRowStart + childItems.Length;
			for (int i = 0; i < count; i++)
			{
				int num2 = rowStart + i;
				if (num2 >= sourceDataRowStart && num2 < num)
				{
					int num3 = WrapChildIndex(childBufferStart + num2 - sourceDataRowStart);
					if ((Object)(object)childItems[num3] != (Object)null)
					{
						UpdateChild(childItems[num3], num2);
					}
				}
			}
		}

		public virtual void Refresh(MonoBehaviour item)
		{
			for (int i = 0; i < childItems.Length; i++)
			{
				int num = WrapChildIndex(childBufferStart + i);
				if ((Object)(object)childItems[num] != (Object)null && (Object)(object)childItems[num] == (Object)(object)item)
				{
					UpdateChild(childItems[i], sourceDataRowStart + i);
					break;
				}
			}
		}

		public virtual void Clear()
		{
			RowCount = 0;
		}

		public virtual void ScrollToRow(int row)
		{
			scrollRect.verticalNormalizedPosition = GetRowScrollPosition(row);
		}

		public float GetRowScrollPosition(int row)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			float num = ((float)row + 0.5f) * RowHeight();
			float num2 = ViewportHeight();
			float num3 = num2 * 0.5f;
			float num4 = Mathf.Max(0f, num - num3);
			float num5 = num4 + num2;
			float y = scrollRect.content.sizeDelta.y;
			if (num5 > y)
			{
				num4 = Mathf.Max(0f, num4 - (num5 - y));
			}
			return Mathf.InverseLerp(y - num2, 0f, num4);
		}

		public MonoBehaviour GetRowItem(int row)
		{
			if (childItems != null && row >= sourceDataRowStart && row < sourceDataRowStart + childItems.Length && row < rowCount)
			{
				return childItems[WrapChildIndex(childBufferStart + row - sourceDataRowStart)];
			}
			return null;
		}

		protected virtual void Awake()
		{
		}

		protected virtual bool CheckChildItems()
		{
			float num = Mathf.Max(ViewportHeight(), PreAllocHeight);
			bool flag = childItems == null || num > previousBuildHeight;
			if (flag)
			{
				int num2 = Mathf.RoundToInt(0.5f + num / RowHeight());
				num2 += 2;
				if (childItems == null)
				{
					childItems = (MonoBehaviour[])(object)new MonoBehaviour[num2];
				}
				else if (num2 > childItems.Length)
				{
					Array.Resize(ref childItems, num2);
				}
				for (int i = 0; i < childItems.Length; i++)
				{
					if ((Object)(object)childItems[i] == (Object)null)
					{
						childItems[i] = Object.Instantiate<MonoBehaviour>(ChildPrefab);
					}
					((Transform)((Component)childItems[i]).GetComponent<RectTransform>()).SetParent((Transform)(object)scrollRect.content, false);
					((Component)childItems[i]).gameObject.SetActive(false);
				}
				previousBuildHeight = num;
			}
			return flag;
		}

		protected virtual void OnEnable()
		{
			ScrollRect obj = scrollRect;
			if (obj != null)
			{
				((UnityEvent<Vector2>)(object)obj.onValueChanged).AddListener((UnityAction<Vector2>)OnScrollChanged);
			}
			ignoreScrollChange = false;
		}

		protected virtual void OnDisable()
		{
			ScrollRect obj = scrollRect;
			if (obj != null)
			{
				((UnityEvent<Vector2>)(object)obj.onValueChanged).RemoveListener((UnityAction<Vector2>)OnScrollChanged);
			}
		}

		protected virtual void OnScrollChanged(Vector2 normalisedPos)
		{
			if (!ignoreScrollChange)
			{
				ReorganiseContent(clearContents: false);
			}
		}

		protected virtual void ReorganiseContent(bool clearContents)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (clearContents)
			{
				scrollRect.StopMovement();
				scrollRect.verticalNormalizedPosition = 1f;
			}
			bool num = CheckChildItems() || clearContents;
			float y = ((Transform)scrollRect.content).localPosition.y;
			Transform transform = ((Component)scrollRect).transform;
			Rect rect = ((RectTransform)((transform is RectTransform) ? transform : null)).rect;
			int num2 = (int)((y - ((Rect)(ref rect)).height / 2f) / RowHeight()) - 1;
			int num3 = num2 - sourceDataRowStart;
			if (num || Mathf.Abs(num3) >= childItems.Length)
			{
				sourceDataRowStart = num2;
				childBufferStart = 0;
				int num4 = num2;
				MonoBehaviour[] array = childItems;
				foreach (MonoBehaviour child in array)
				{
					UpdateChild(child, num4++);
				}
			}
			else
			{
				if (num3 == 0)
				{
					return;
				}
				int num5 = (childBufferStart + num3) % childItems.Length;
				if (num3 < 0)
				{
					for (int j = 1; j <= -num3; j++)
					{
						int num6 = WrapChildIndex(childBufferStart - j);
						int rowIdx = sourceDataRowStart - j;
						UpdateChild(childItems[num6], rowIdx);
					}
				}
				else
				{
					int num7 = childBufferStart + childItems.Length - 1;
					int num8 = sourceDataRowStart + childItems.Length - 1;
					for (int k = 1; k <= num3; k++)
					{
						int num9 = WrapChildIndex(num7 + k);
						int rowIdx2 = num8 + k;
						UpdateChild(childItems[num9], rowIdx2);
					}
				}
				sourceDataRowStart = num2;
				childBufferStart = num5;
			}
		}

		private int WrapChildIndex(int idx)
		{
			while (idx < 0)
			{
				idx += childItems.Length;
			}
			return idx % childItems.Length;
		}

		private float RowHeight()
		{
			//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)
			float rowPadding = RowPadding;
			Rect rect = ((Component)ChildPrefab).GetComponent<RectTransform>().rect;
			return rowPadding + ((Rect)(ref rect)).height;
		}

		private float ViewportHeight()
		{
			//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)
			Transform transform = ((Component)scrollRect).transform;
			Rect rect = ((RectTransform)((transform is RectTransform) ? transform : null)).rect;
			return ((Rect)(ref rect)).height * 1.5f;
		}

		protected virtual void UpdateChild(MonoBehaviour child, int rowIdx)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			if (rowIdx < 0 || rowIdx >= rowCount)
			{
				((Component)child).gameObject.SetActive(false);
			}
			else if (ItemCallback != null)
			{
				Rect rect = ((Component)ChildPrefab).GetComponent<RectTransform>().rect;
				Vector2 pivot = ((Component)ChildPrefab).GetComponent<RectTransform>().pivot;
				float num = RowHeight() * (float)rowIdx + (1f - pivot.y) * ((Rect)(ref rect)).height;
				float num2 = 0f + pivot.x * ((Rect)(ref rect)).width;
				((Component)child).GetComponent<RectTransform>().anchoredPosition = new Vector2(num2, 0f - num);
				ItemCallback(child, rowIdx);
				((Component)child).gameObject.SetActive(true);
			}
		}

		protected virtual void UpdateContentHeight()
		{
			//IL_000b: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = ((Component)ChildPrefab).GetComponent<RectTransform>().rect;
			float num = ((Rect)(ref rect)).height * (float)rowCount + (float)(rowCount - 1) * RowPadding;
			Vector2 sizeDelta = scrollRect.content.sizeDelta;
			scrollRect.content.sizeDelta = new Vector2(sizeDelta.x, num);
		}

		protected virtual void DisableAllChildren()
		{
			if (childItems != null)
			{
				for (int i = 0; i < childItems.Length; i++)
				{
					((Component)childItems[i]).gameObject.SetActive(false);
				}
			}
		}
	}
	public class LSTMStarDistance
	{
		public static class Patch
		{
			[HarmonyPrefix]
			[HarmonyPatch(typeof(GameMain), "Begin")]
			public static void GameMain_Begin_Prefix()
			{
				if (_distances != null)
				{
					_distances.Clear();
				}
				_distances = new Dictionary<int, Dictionary<int, float>>(GameMain.galaxy.starCount);
				InitDistances();
			}
		}

		public static Dictionary<int, Dictionary<int, float>> _distances;

		public static float StarDistanceFromHere(int star)
		{
			if (GameMain.localPlanet != null)
			{
				int id = GameMain.localPlanet.star.id;
				return StarDistance(star, id);
			}
			return -1f;
		}

		public static float StarDistance(int star, int star2)
		{
			if (star == star2)
			{
				return 0f;
			}
			int key;
			int key2;
			if (star > star2)
			{
				key = star2;
				key2 = star;
			}
			else
			{
				key = star;
				key2 = star2;
			}
			_distances.TryGetValue(key, out var value);
			if (value != null)
			{
				value.TryGetValue(key2, out var value2);
				return value2;
			}
			return -1f;
		}

		public static void InitDistances()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			_distances.Clear();
			if (GameMain.instance.isMenuDemo)
			{
				return;
			}
			GalaxyData galaxy = GameMain.galaxy;
			for (int i = 0; i < galaxy.starCount; i++)
			{
				StarData val = galaxy.stars[i];
				Dictionary<int, float> dictionary = new Dictionary<int, float>(galaxy.starCount - i);
				for (int j = i + 1; j < galaxy.starCount; j++)
				{
					StarData val2 = galaxy.stars[j];
					VectorLF3 val3 = val.uPosition - val2.uPosition;
					double magnitude = ((VectorLF3)(ref val3)).magnitude;
					dictionary.Add(value: (!(magnitude < 2400000.0)) ? ((float)(magnitude / 2400000.0)) : 1f, key: val2.id);
				}
				_distances.Add(val.id, dictionary);
			}
		}
	}
	public class StationSignRenderer
	{
		public PlanetFactory factory;

		public bool showStationInfo;

		private int itemId;

		private Material entitySignMat;

		public SignData[] entitySignPool;

		private int entitySignBufferLen;

		private int bufferLen;

		private static int defaultBufferLenSize = 300;

		private static int maxBufferLenSize = 4000;

		private float lastZoom;

		private int lastFrame;

		private bool needMoreBuffer;

		public ComputeBuffer entitySignBuffer { get; private set; }

		public void Init()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			entitySignMat = new Material(Configs.builtin.entitySignMat);
			SetBufferSize(defaultBufferLenSize);
		}

		private void SetBufferSize(int newSize)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (entitySignPool != null)
			{
				entitySignPool = null;
			}
			entitySignPool = (SignData[])(object)new SignData[newSize];
			FreeEntitySignBuffer();
			entitySignBuffer = new ComputeBuffer(newSize, 56, (ComputeBufferType)0);
			entitySignBufferLen = newSize;
			bufferLen = newSize;
		}

		private void CheckBufferSize()
		{
			if (needMoreBuffer)
			{
				if (bufferLen < maxBufferLenSize)
				{
					SetBufferSize(bufferLen + defaultBufferLenSize);
				}
				needMoreBuffer = false;
			}
		}

		public void Free()
		{
			entitySignPool = null;
			FreeEntitySignBuffer();
		}

		public void FreeEntitySignBuffer()
		{
			if (entitySignBuffer != null)
			{
				entitySignBufferLen = 0;
				entitySignBuffer.Release();
				entitySignBuffer = null;
			}
		}

		public void Refresh(PlanetFactory currentFactory)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: 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_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: 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_0302: Unknown result type (might be due to invalid IL or missing references)
			if (Time.frameCount < lastFrame + 2)
			{
				return;
			}
			float num = 1f;
			if ((int)UIGame.viewMode == 3)
			{
				PlanetPoser planetPoser = GameCamera.instance.planetPoser;
				float num2 = planetPoser.dist / (planetPoser.planetRadius * 1.15f);
				if (num2 > 1f)
				{
					num = num2;
				}
			}
			if (!needMoreBuffer && lastZoom == num && currentFactory == factory && Time.frameCount < lastFrame + 60 && showStationInfo == LSTM.showStationInfo.Value)
			{
				return;
			}
			CheckBufferSize();
			lastFrame = Time.frameCount;
			showStationInfo = LSTM.showStationInfo.Value;
			itemId = 0;
			lastZoom = num;
			factory = currentFactory;
			if (factory == null)
			{
				return;
			}
			int i = 1;
			if (showStationInfo || itemId > 0)
			{
				_ = itemId;
				for (int j = 1; j < factory.transport.stationCursor; j++)
				{
					StationComponent val = factory.transport.stationPool[j];
					if (val == null || val.id != j || val.isVeinCollector)
					{
						continue;
					}
					_ = ref factory.entityPool[val.entityId];
					float num3 = 1f + (num - 1f) / 4f;
					int num4 = val.storage.Length;
					bool flag = false;
					int num5 = 0;
					if (val.storage.Length == 1)
					{
						num3 = 0f;
					}
					else
					{
						for (int k = 0; k < val.storage.Length; k++)
						{
							if (showStationInfo && val.storage[k].itemId <= 0)
							{
								num4--;
								flag = true;
							}
						}
						if (flag)
						{
							num4++;
						}
					}
					int num6 = -1;
					for (int l = 0; l < val.storage.Length; l++)
					{
						if (showStationInfo && val.storage[l].itemId <= 0)
						{
							num5++;
							if (num6 > 0 || val.isCollector)
							{
								continue;
							}
							num6 = i;
						}
						else if (!showStationInfo && val.storage[l].itemId != itemId)
						{
							continue;
						}
						int num7 = l;
						if (num6 > 0)
						{
							num7 -= num5 - 1;
						}
						Vector3 val2 = Quaternion.Euler(0f, 360f / (float)num4 * (float)num7, 0f) * new Vector3(0f, 0f, val.isStellar ? 10f : 4.5f);
						val2 = factory.entityPool[val.entityId].pos + val.shipDockRot * val2;
						float value = LSTM.stationInfoIconSize.Value;
						float num8 = (val.isStellar ? 36f : 27.5f);
						float num9 = (val.isStellar ? (value * num3) : (value * 0.68f * num3));
						((SignData)(ref entitySignPool[i])).Reset(val2, val.shipDockRot, num8, num9);
						entitySignPool[i].iconId0 = (uint)val.storage[l].itemId;
						entitySignPool[i].iconType = 1u;
						entitySignPool[i].count0 = ((val.storage[l].count >= 1) ? ((float)val.storage[l].count) : 0.4f);
						i++;
						if (i >= bufferLen)
						{
							needMoreBuffer = true;
							break;
						}
					}
					if (showStationInfo && num6 > 0 && !val.isCollector)
					{
						if (num5 > 9)
						{
							num5 = 9;
						}
						entitySignPool[num6].iconId0 = (uint)(num5 + 600);
						entitySignPool[num6].iconType = 4u;
						entitySignPool[num6].count0 = 0f;
					}
					if (i >= bufferLen)
					{
						needMoreBuffer = true;
						break;
					}
				}
			}
			if (i >= bufferLen)
			{
				needMoreBuffer = true;
			}
			else
			{
				for (; i < bufferLen && entitySignPool[i].iconId0 != 0; i++)
				{
					((SignData)(ref entitySignPool[i])).SetEmpty();
				}
			}
			entitySignBuffer.SetData((Array)entitySignPool);
		}

		public void Draw(PlanetFactory currentFactory)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			if (EntitySignRenderer.showIcon && LSTM.showStationInfo.Value && ((int)UIGame.viewMode == 3 || !LSTM.showStationInfoOnlyInPlanetView.Value))
			{
				Refresh(currentFactory);
				if (entitySignBufferLen > 1)
				{
					Shader.SetGlobalFloat("_Global_ShowEntitySign", EntitySignRenderer.showSign ? 1f : 0f);
					Shader.SetGlobalFloat("_Global_ShowEntityIcon", 1f);
					Shader.SetGlobalInt("_EntitySignMask", EntitySignRenderer.buildingWarningMask);
					entitySignMat.SetBuffer("_SignBuffer", entitySignBuffer);
					entitySignMat.SetPass(0);
					Graphics.DrawProcedural((MeshTopology)2, 8 * entitySignBufferLen, 1);
				}
			}
		}

		private void Cleanup()
		{
		}
	}
	public class TLCluster
	{
		public static bool IsSameRemoteCluster(StationComponent s1, StationComponent s2)
		{
			return IsSameCluster(s1, s2, "C");
		}

		public static bool IsSameLocalCluster(StationComponent s1, StationComponent s2)
		{
			return IsSameCluster(s1, s2, "c");
		}

		public static bool IsSameCluster(StationComponent s1, StationComponent s2, string cmd)
		{
			string text = Util.GetCommandValue(Util.GetStationName(s1), cmd).ToLower();
			string text2 = Util.GetCommandValue(Util.GetStationName(s2), cmd).ToLower();
			if (text == "any" || text2 == "any")
			{
				return true;
			}
			return text == text2;
		}
	}
	public interface TrafficLogDelegate
	{
		void TrafficLogReseted();
	}
	public class TrafficLogData
	{
		public int fromPlanet;

		public int fromStationGid;

		public int fromIndex;

		public int toPlanet;

		public int toStationGid;

		public int toIndex;

		public int itemId;

		public float realtimeSinceStartup;

		public bool isFromDemand;

		public string fetchedTime;

		public PlanetData fromPlanetData => GameMain.galaxy.PlanetById(fromPlanet);

		public PlanetData toPlanetData => GameMain.galaxy.PlanetById(toPlanet);

		public string fromPlanetName => GameMain.galaxy.PlanetById(fromPlanet).displayName;

		public string toPlanetName => GameMain.galaxy.PlanetById(toPlanet).displayName;

		public string distanceString
		{
			get
			{
				float num = LSTMStarDistance.StarDistance(fromPlanet / 100, toPlanet / 100);
				if (num <= 0f)
				{
					return " ";
				}
				return num.ToString("F1") + "ly";
			}
		}

		public string time
		{
			get
			{
				float num = Time.realtimeSinceStartup - realtimeSinceStartup;
				if ((double)num < 60.0)
				{
					return num.ToString("F0") + "s";
				}
				if ((double)num < 3600.0)
				{
					return ((double)num / 60.0).ToString("F0") + "m";
				}
				return ((double)num / 3600.0).ToString("F1") + "h";
			}
		}

		public string Info()
		{
			return "[" + time + "]" + fromPlanet + "/" + fromIndex + "->" + toPlanet + "/" + toIndex + ":" + itemId;
		}
	}
	public class TrafficLog
	{
		public static class Patch
		{
			[HarmonyPrefix]
			[HarmonyPatch(typeof(GameMain), "Begin")]
			public static void GameMain_Begin_Prefix()
			{
				ResetLog();
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(StationComponent), "IdleShipGetToWork")]
			[HarmonyAfter(new string[] { "dsp.nebula-multiplayer" })]
			public static void StationComponent_IdleShipGetToWork_Prefix(StationComponent __instance)
			{
				int workShipCount = __instance.workShipCount;
				if (workShipCount > 0)
				{
					TakeLog(__instance, workShipCount - 1);
				}
			}
		}

		public static TrafficLogDelegate trafficLogDelegate;

		public static TrafficLogData[] trafficLogs = null;

		public static int trafficLogsCursor = 0;

		public static bool keepLog = true;

		public static int trafficLogsSize = 10001;

		public static void ResetLog()
		{
			trafficLogs = new TrafficLogData[trafficLogsSize];
			trafficLogsCursor = 0;
			trafficLogDelegate?.TrafficLogReseted();
		}

		public static void AddLog(TrafficLogData logData)
		{
			lock (trafficLogs)
			{
				if (trafficLogs == null)
				{
					ResetLog();
				}
				if (keepLog)
				{
					trafficLogs[trafficLogsCursor] = logData;
					trafficLogsCursor++;
					if (trafficLogsCursor >= trafficLogsSize)
					{
						trafficLogsCursor = 0;
					}
				}
			}
		}

		public static void Test()
		{
			LSTM.Log("LogTest:Cursor==" + trafficLogsCursor);
			foreach (TrafficLogData item in AllTrafficLogData())
			{
				LSTM.Log(item.Info());
			}
		}

		public static IEnumerable<TrafficLogData> AllTrafficLogData()
		{
			if (trafficLogs == null || !keepLog)
			{
				yield break;
			}
			lock (trafficLogs)
			{
				int i = trafficLogsCursor;
				while (true)
				{
					i--;
					if (i < 0)
					{
						i = trafficLogsSize - 1;
					}
					if (i == trafficLogsCursor || trafficLogs[i] == null)
					{
						break;
					}
					yield return trafficLogs[i];
				}
			}
		}

		public static IEnumerable<TrafficLogData> GetTrafficLogData(int starId, int planetId, int itemId, int filterStationGid)
		{
			if (trafficLogs == null || !keepLog)
			{
				yield break;
			}
			lock (trafficLogs)
			{
				int i = trafficLogsCursor;
				while (true)
				{
					i--;
					if (i < 0)
					{
						i = trafficLogsSize - 1;
					}
					if (i == trafficLogsCursor || trafficLogs[i] == null)
					{
						break;
					}
					TrafficLogData trafficLogData = trafficLogs[i];
					if ((starId == 0 || trafficLogData.fromPlanet / 100 == starId || trafficLogData.toPlanet / 100 == starId) && (planetId == 0 || trafficLogData.fromPlanet == planetId || trafficLogData.toPlanet == planetId) && (itemId == 0 || trafficLogData.itemId == itemId) && (filterStationGid == 0 || trafficLogData.toStationGid == filterStationGid || trafficLogData.fromStationGid == filterStationGid))
					{
						yield return trafficLogData;
					}
				}
			}
		}

		public static void TakeLog(StationComponent sc, int index)
		{
			if (index >= 0)
			{
				AddLog(new TrafficLogData
				{
					fromPlanet = sc.workShipDatas[index].planetA,
					toPlanet = sc.workShipDatas[index].planetB,
					fromStationGid = sc.gid,
					fromIndex = sc.workShipOrders[index].thisIndex,
					toIndex = sc.workShipOrders[index].otherIndex,
					toStationGid = sc.workShipDatas[index].otherGId,
					itemId = sc.workShipDatas[index].itemId,
					realtimeSinceStartup = Time.realtimeSinceStartup,
					isFromDemand = (sc.workShipOrders[index].thisOrdered != 0)
				});
			}
		}
	}
	public class UIBalanceListEntry : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler
	{
		public StationComponent station;

		public int index;

		public int itemId;

		public int planetId;

		public bool nameDirty;

		public UIBalanceWindow window;

		public int stationMaxItemCount;

		public bool isLocal;

		public EStoreType storeType;

		[SerializeField]
		public Image leftBarLocal;

		[SerializeField]
		public Image leftBarRemote;

		[SerializeField]
		public Text countValueText;

		[SerializeField]
		public Text orderValueText;

		[SerializeField]
		public Text maxValueText;

		[SerializeField]
		public Image countBar;

		[SerializeField]
		public Image orderBar;

		[SerializeField]
		public Image locateImage;

		[Header("Colors & Settings")]
		[SerializeField]
		public Color supplyColor;

		[SerializeField]
		public Color demandColor;

		[SerializeField]
		public Color noneSpColor;

		[SerializeField]
		public Color orderInColor;

		[SerializeField]
		public Color orderOutColor;

		[SerializeField]
		public Color orderInTextColor;

		[SerializeField]
		public Color orderOutTextColor;

		[SerializeField]
		public Color orderNoneTextColor;

		[SerializeField]
		public Color locateImageColor;

		[SerializeField]
		public Color locateImageColorLocal;

		[SerializeField]
		public Image itemImage;

		[SerializeField]
		public Slider maxSlider;

		[SerializeField]
		public Text nameText;

		[SerializeField]
		public Text shipCountText;

		[SerializeField]
		public UIButton itemButton;

		[SerializeField]
		public UIButton locateBtn;

		[SerializeField]
		public UIButton filterBtn;

		[SerializeField]
		public Image itemIncs1;

		[SerializeField]
		public Image itemIncs2;

		[SerializeField]
		public Image itemIncs3;

		public string StationName
		{
			get
			{
				string text = Util.GetStationName(station, planetId);
				if (string.IsNullOrEmpty(text))
				{
					text = (station.isStellar ? (Localization.Translate("星际站点号") + station.gid) : (Localization.Translate("本地站点号") + station.id));
				}
				return text;
			}
		}

		public static UIBalanceListEntry CreatePrefab()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: 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_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0674: Unknown result type (might be due to invalid IL or missing references)
			//IL_0753: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_070d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0785: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
			UIStationStorage val = Object.Instantiate<UIStationStorage>(UIRoot.instance.uiGame.stationWindow.storageUIPrefab);
			UIBalanceListEntry uIBalanceListEntry = ((Component)val).gameObject.AddComponent<UIBalanceListEntry>();
			uIBalanceListEntry.leftBarLocal = val.leftBar;
			uIBalanceListEntry.countValueText = val.countValueText;
			uIBalanceListEntry.countValueText.supportRichText = true;
			uIBalanceListEntry.orderValueText = val.orderValueText;
			uIBalanceListEntry.maxValueText = val.maxValueText;
			uIBalanceListEntry.countBar = val.countBar;
			uIBalanceListEntry.orderBar = val.orderBar;
			uIBalanceListEntry.supplyColor = val.supplyColor;
			uIBalanceListEntry.demandColor = val.demandColor;
			uIBalanceListEntry.noneSpColor = val.noneSpColor;
			uIBalanceListEntry.orderInColor = val.orderInColor;
			uIBalanceListEntry.orderOutColor = val.orderOutColor;
			uIBalanceListEntry.orderInTextColor = val.orderInTextColor;
			uIBalanceListEntry.orderOutTextColor = val.orderOutTextColor;
			uIBalanceListEntry.orderNoneTextColor = val.orderNoneTextColor;
			uIBalanceListEntry.itemImage = val.itemImage;
			uIBalanceListEntry.maxSlider = val.maxSlider;
			uIBalanceListEntry.itemButton = val.itemButton;
			if (val.itemIncs.Length >= 3)
			{
				uIBalanceListEntry.itemIncs1 = val.itemIncs[0];
				uIBalanceListEntry.itemIncs2 = val.itemIncs[1];
				uIBalanceListEntry.itemIncs3 = val.itemIncs[2];
			}
			Object.Destroy((Object)(object)val);
			GameObject gameObject = ((Component)uIBalanceListEntry).gameObject;
			RectTransform val2 = Util.NormalizeRect(gameObject);
			val2.sizeDelta = new Vector2(val2.sizeDelta.x, val2.sizeDelta.y + 14f);
			Transform obj = gameObject.transform.Find("bg/empty-tip");
			if (obj != null)
			{
				((Component)obj).gameObject.SetActive(false);
			}
			Transform obj2 = gameObject.transform.Find("storage-icon/take-button");
			if (obj2 != null)
			{
				((Component)obj2).gameObject.SetActive(false);
			}
			Transform obj3 = gameObject.transform.Find("current-count-label/current-count-text");
			GameObject val3 = ((obj3 != null) ? ((Component)obj3).gameObject : null);
			if ((Object)(object)val3 != (Object)null)
			{
				GameObject val4 = Object.Instantiate<GameObject>(val3);
				((Object)val4).name = "lstm-name-lbl";
				uIBalanceListEntry.nameText = val4.GetComponent<Text>();
				uIBalanceListEntry.nameText.alignment = (TextAnchor)3;
				RectTransform obj4 = Util.NormalizeRectB(val4);
				val4.transform.SetParent(gameObject.transform, false);
				obj4.offsetMax = Vector2.zero;
				obj4.offsetMin = new Vector2(14f, 54f);
				GameObject val5 = Object.Instantiate<GameObject>(val4);
				((Object)val5).name = "lstm-ship-count";
				uIBalanceListEntry.shipCountText = val5.GetComponent<Text>();
				uIBalanceListEntry.shipCountText.alignment = (TextAnchor)5;
				RectTransform val6 = (RectTransform)val5.transform;
				val5.transform.SetParent(gameObject.transform, false);
				val6.pivot = new Vector2(1f, 0.5f);
				((Transform)val6).localPosition = Vector2.op_Implicit(new Vector2(300f, 68f));
			}
			UIButton val7 = Util.MakeIconButtonB(Util.astroIndicatorIcon, 22f);
			if ((Object)(object)val7 != (Object)null)
			{
				((Object)((Component)val7).gameObject).name = "lstm-locate-btn";
				val2 = Util.NormalizeRectD(((Component)val7).gameObject);
				((Transform)val2).SetParent(gameObject.transform, false);
				val2.anchoredPosition = new Vector2(240f, -6f);
				val7.tips.tipTitle = Localization.Translate("Locate Station");
				val7.tips.tipText = Localization.Translate("Show the star to which the station belongs or navigation to this station");
				val7.tips.corner = 3;
				val7.tips.offset = new Vector2(18f, -20f);
				((Component)val7).gameObject.SetActive(false);
				uIBalanceListEntry.locateBtn = val7;
				Transform obj5 = ((Component)val7).gameObject.transform.Find("icon");
				uIBalanceListEntry.locateImage = ((obj5 != null) ? ((Component)obj5).GetComponent<Image>() : null);
				uIBalanceListEntry.locateImageColor = new Color(0.8f, 0.8f, 0.8f, 0.55f);
				uIBalanceListEntry.locateImageColorLocal = new Color(0.3821f, 0.8455f, 1f, 0.55f);
			}
			val7 = Util.MakeIconButtonB(Util.LoadSpriteResource("ui/textures/sprites/icons/filter-icon"), 22f);
			if ((Object)(object)val7 != (Object)null)
			{
				((Object)((Component)val7).gameObject).name = "lstm-filter-btn";
				val2 = Util.NormalizeRectD(((Component)val7).gameObject);
				((Transform)val2).SetParent(gameObject.transform, false);
				val2.anchoredPosition = new Vector2(38f, -56f);
				val7.tips.tipTitle = Localization.Translate("Item Filter");
				val7.tips.tipText = Localization.Translate("Filter list with this item");
				val7.tips.corner = 3;
				val7.tips.offset = new Vector2(18f, -20f);
				Transform obj6 = ((Component)val7).transform.Find("bg");
				Image val8 = ((obj6 != null) ? ((Component)obj6).GetComponent<Image>() : null);
				if (Object.op_Implicit((Object)(object)val8))
				{
					((Graphic)val8).color = new Color(0.216f, 0.216f, 0.216f, 0.8f);
				}
				((Component)val7).gameObject.SetActive(false);
				uIBalanceListEntry.filterBtn = val7;
			}
			uIBalanceListEntry.leftBarRemote = Object.Instantiate<Image>(uIBalanceListEntry.leftBarLocal, ((Component)uIBalanceListEntry.leftBarLocal).transform.parent);
			val2 = ((Graphic)uIBalanceListEntry.leftBarRemote).rectTransform;
			val2.offsetMax = new Vector2(3f, 0f);
			val2.offsetMin = new Vector2(0f, 0f);
			((Object)((Component)uIBalanceListEntry.leftBarRemote).gameObject).name = "bar-remote";
			val2 = ((Graphic)uIBalanceListEntry.leftBarLocal).rectTransform;
			val2.offsetMax = new Vector2(8f, -28f);
			val2.offsetMin = new Vector2(4f, 0f);
			gameObject = ((Component)uIBalanceListEntry).gameObject;
			for (int num = gameObject.transform.childCount - 1; num >= 0; num--)
			{
				GameObject gameObject2 = ((Component)gameObject.transform.GetChild(num)).gameObject;
				if (((Object)gameObject2).name.Contains("button") || ((Object)gameObject2).name.Contains("popup") || ((Object)gameObject2).name.Contains("empty") || ((Object)gameObject2).name.Contains("keep-mode-lock"))
				{
					gameObject2.SetActive(false);
					Object.Destroy((Object)(object)gameObject2);
				}
				else
				{
					if ((Object)(object)gameObject2.GetComponent<EventTrigger>() != (Object)null)
					{
						Object.Destroy((Object)(object)gameObject2.GetComponent<EventTrigger>());
					}
					Vector3 localPosition = gameObject2.transform.localPosition;
					gameObject2.SetActive(true);
					if (((Object)gameObject2).name == "slider-bg")
					{
						Image component = gameObject2.GetComponent<Image>();
						if (Object.op_Implicit((Object)(object)component))
						{
							((Graphic)component).color = new Color(1f, 1f, 1f, 0.1f);
						}
						gameObject2.transform.localScale = new Vector3(0.66f, 1f, 1f);
						localPosition.x -= 32f;
						localPosition.y -= 10f;
						gameObject2.transform.localPosition = localPosition;
					}
					else if (((Object)gameObject2).name.Contains("label"))
					{
						localPosition.x -= 30f;
						localPosition.y -= 12f;
						gameObject2.transform.localPosition = localPosition;
					}
					else if (((Object)gameObject2).name.Contains("icon"))
					{
						gameObject2.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f);
						localPosition.x = 36f;
						localPosition.y = 30f;
						gameObject2.transform.localPosition = localPosition;
					}
				}
			}
			return uIBalanceListEntry;
		}

		private void Start()
		{
			((Behaviour)maxSlider).enabled = false;
			filterBtn.onClick += OnFilterButtonClick;
			locateBtn.onClick += OnLocateButtonClick;
			locateBtn.onRightClick += OnLocateButtonRightClick;
			((Component)locateBtn).gameObject.SetActive(false);
			((Component)filterBtn).gameObject.SetActive(false);
		}

		public void SetUpValues(bool useStationName)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			nameDirty = false;
			if (storeType == EStoreType.GasStubStorage || storeType == EStoreType.GasStubSupply)
			{
				if (window.balanceData.starId != 0)
				{
					Image obj = itemImage;
					ItemProto obj2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(itemId);
					obj.sprite = ((obj2 != null) ? obj2.iconSprite : null);
				}
				else
				{
					itemImage.sprite = UIBalanceWindow.gasGiantSprite;
				}
				((Graphic)itemImage).color = new Color(0.5f, 0.5f, 0.5f, 0.6f);
				((RectTransform)((Component)locateBtn).transform).anchoredPosition = new Vector2(200f, -6f);
			}
			else
			{
				ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(itemId);
				if (val != null)
				{
					itemImage.sprite = val.iconSprite;
				}
				if (((GameMain.localPlanet != null) ? GameMain.localPlanet.id : 0) == planetId)
				{
					((Graphic)locateImage).color = locateImageColorLocal;
				}
				else
				{
					((Graphic)locateImage).color = locateImageColor;
				}
			}
			if (stationMaxItemCount == 0)
			{
				stationMaxItemCount = LSTM.RemoteStationMaxItemCount();
			}
			else if (stationMaxItemCount < LSTM.RemoteStationMaxItemCount())
			{
				RectTransform val2 = (RectTransform)((Component)maxSlider).gameObject.transform;
				val2.sizeDelta = new Vector2(val2.sizeDelta.x / ((float)LSTM.RemoteStationMaxItemCount() / (float)stationMaxItemCount), val2.sizeDelta.y);
			}
			SetUpNameText(useStationName);
		}

		public void SetUpNameText(bool useStationName)
		{
			string text;
			if (((GameMain.localPlanet != null) ? GameMain.localPlanet.id : 0) == planetId)
			{
				text = "";
			}
			else
			{
				float num = LSTMStarDistance.StarDistanceFromHere(planetId / 100);
				text = ((!(num > 0f)) ? "   (near)" : $"   ({num:F1}ly)");
			}
			if (useStationName && station != null)
			{
				nameText.text = StationName + text;
				return;
			}
			PlanetData val = GameMain.galaxy.PlanetById(planetId);
			if (val != null)
			{
				nameText.text = val.displayName + text;
			}
			else
			{
				nameText.text = text;
			}
		}

		public bool RefreshValues(bool shown, bool onlyNewlyEmerged = false)
		{
			//IL_0071: Unk