Decompiled source of PlanetFinder v1.3.1
PlanetFinder.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; 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("PlanetFinder")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PlanetFinder")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("43cacced-1c08-475c-80c9-8a77158a4bd9")] [assembly: AssemblyFileVersion("1.3.1.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PlanetFinder { public static class PluginInfo { public const string PLUGIN_GUID = "PlanetFinder"; public const string PLUGIN_NAME = "PlanetFinder"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace PlanetFinderMod { public class CruiseAssistIntg { public MethodInfo _selectPlanetOrStar; public MethodInfo _selectPlanetOrStar_CAAP_N; public readonly bool canSelectPlanet; public CruiseAssistIntg() { canSelectPlanet = false; _selectPlanetOrStar = null; _selectPlanetOrStar_CAAP_N = null; try { Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos; if (pluginInfos.TryGetValue("tanu.CruiseAssist", out var value) && (Object)(object)value.Instance != (Object)null) { Type type = ((object)value.Instance).GetType().Assembly.GetType("tanu.CruiseAssist.CruiseAssistStarListUI"); _selectPlanetOrStar = type.GetMethod("SelectStar", new Type[2] { typeof(StarData), typeof(PlanetData) }); canSelectPlanet = _selectPlanetOrStar != null; } else if (pluginInfos.TryGetValue("nord.CruiseAssist", out value) && (Object)(object)value.Instance != (Object)null) { Type type2 = ((object)value.Instance).GetType().Assembly.GetType("tanu.CruiseAssist.CruiseAssistStarListUI"); _selectPlanetOrStar_CAAP_N = type2.GetMethod("SelectStar", new Type[3] { typeof(StarData), typeof(PlanetData), typeof(bool) }); canSelectPlanet = _selectPlanetOrStar_CAAP_N != null; } } catch (Exception) { } } public void SelectPlanetOrStar(PlanetData planet, StarData star = null) { if (!(_selectPlanetOrStar == null) || !(_selectPlanetOrStar_CAAP_N == null)) { if (planet != null && star == null) { star = planet.star; } if (_selectPlanetOrStar != null && (planet != null || star != null)) { object[] parameters = new object[2] { star, planet }; _selectPlanetOrStar.Invoke(null, parameters); } else if (_selectPlanetOrStar_CAAP_N != null && (planet != null || star != null)) { object[] parameters2 = new object[3] { star, planet, true }; _selectPlanetOrStar_CAAP_N.Invoke(null, parameters2); } } } } public class DSPStarMapMemoIntg { public readonly bool canGetSignalIconId; public readonly bool canGetDesc; private FieldInfo _memoPool; private FieldInfo _signalIconIdField; private FieldInfo _descField; public DSPStarMapMemoIntg() { canGetSignalIconId = false; canGetDesc = false; try { if (Chainloader.PluginInfos.TryGetValue("Appun.DSP.plugin.StarMapMemo", out var value) && (Object)(object)value.Instance != (Object)null) { Type type = ((object)value.Instance).GetType().Assembly.GetType("DSPStarMapMemo.MemoPool"); Type type2 = ((object)value.Instance).GetType().Assembly.GetType("DSPStarMapMemo.MemoPool+Memo"); if (type != null && type2 != null) { _signalIconIdField = type2.GetField("signalIconId"); _descField = type2.GetField("desc"); _memoPool = type.GetField("memoPool", BindingFlags.Static | BindingFlags.Public); } canGetSignalIconId = _memoPool != null && _signalIconIdField != null; canGetDesc = _memoPool != null && _descField != null; } } catch (Exception) { } } public int GetSignalIconId(int planetId) { if (_memoPool != null && _signalIconIdField != null) { object value = _memoPool.GetValue(null); if (value == null) { return 0; } object[] array = new object[2] { planetId, null }; if ((bool)value.GetType().InvokeMember("TryGetValue", BindingFlags.InvokeMethod, null, value, array) && array.Length == 2 && array[1] != null) { object value2 = _signalIconIdField.GetValue(array[1]); if (value2 != null) { int[] array2 = value2 as int[]; for (int i = 0; i < array2.Length; i++) { if (array2[i] != 0) { return array2[i]; } } } } } return 0; } public string GetDesc(int planetId) { if (_memoPool != null && _descField != null) { object value = _memoPool.GetValue(null); if (value == null) { return null; } object[] array = new object[2] { planetId, null }; if ((bool)value.GetType().InvokeMember("TryGetValue", BindingFlags.InvokeMethod, null, value, array) && array.Length == 2 && array[1] != null) { object value2 = _descField.GetValue(array[1]); if (value2 != null) { return value2 as string; } } } return null; } } public class LSTMIntg { public MethodInfo _openPlanetId; public readonly bool canOpenPlanetId; public LSTMIntg() { canOpenPlanetId = false; _openPlanetId = null; try { if (Chainloader.PluginInfos.TryGetValue("com.hetima.dsp.LSTM", out var value) && (Object)(object)value.Instance != (Object)null) { _openPlanetId = ((object)value.Instance).GetType().GetMethod("IntegrationOpenPlanetId", new Type[1] { typeof(int) }); canOpenPlanetId = _openPlanetId != null; } } catch (Exception) { } } public void OpenPlanetId(int planetId) { if (_openPlanetId != null) { object[] parameters = new object[1] { planetId }; _openPlanetId.Invoke(null, parameters); } } } public class MyCheckBox : MonoBehaviour { public UIButton uiButton; public Image checkImage; public RectTransform rectTrans; public Text labelText; public ConfigEntry<bool> config; public bool interactable = true; private Color labelNormalColor = Color.white; 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) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) 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.labelNormalColor = ((Graphic)cb.labelText).color; 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 SetInteractable(bool on) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) interactable = on; if ((Object)(object)uiButton != (Object)null && (Object)(object)uiButton.button != (Object)null) { ((Behaviour)uiButton.button).enabled = on; } if ((Object)(object)checkImage != (Object)null) { ((Graphic)checkImage).color = (Color)(on ? Color.white : new Color(1f, 1f, 1f, 0.3f)); } if ((Object)(object)labelText != (Object)null) { ((Graphic)labelText).color = (Color)(on ? labelNormalColor : new Color(labelNormalColor.r, labelNormalColor.g, labelNormalColor.b, labelNormalColor.a * 0.35f)); } } public void SettingChanged() { if (config.Value != ((Behaviour)checkImage).enabled) { ((Behaviour)checkImage).enabled = config.Value; } } public void OnClick(int obj) { if (interactable) { 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 unsafe 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)Unsafe.As<KeyCode, KeyCode>(ref _lastKey)/*cast due to .constrained prefix*/).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*)(&val))/*cast due to .constrained prefix*/).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_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_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; Transform obj = ((transform is RectTransform) ? transform : null); ((RectTransform)obj).anchorMin = new Vector2(1f, 0f); ((RectTransform)obj).anchorMax = new Vector2(1f, 1f); ((RectTransform)obj).sizeDelta = new Vector2(16f, 0f); Object.Destroy((Object)(object)component.m_ContentPanel); Object.Destroy((Object)(object)component); myListView.m_ScrollRect.content.sizeDelta = new Vector2(750f, 0f); 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 = true; 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 UIInserterWindow inserterWindow = UIRoot.instance.uiGame.inserterWindow; GameObject val = Object.Instantiate<GameObject>(((Component)inserterWindow).gameObject, ((Component)inserterWindow).transform.parent); ((Object)val).name = name; val.SetActive(false); Object.Destroy((Object)(object)val.GetComponent<UIInserterWindow>()); 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(); } } [BepInPlugin("com.hetima.dsp.PlanetFinder", "PlanetFinder", "1.3.1")] public class PLFN : BaseUnityPlugin { private static class Patch { internal static bool _initialized; [HarmonyPrefix] [HarmonyPatch(typeof(GameMain), "Begin")] public static void GameMain_Begin_Prefix() { if (!_initialized) { _initialized = true; aLSTMIntg = new LSTMIntg(); aDSPStarMapMemoIntg = new DSPStarMapMemoIntg(); aCruiseAssistIntg = new CruiseAssistIntg(); planetFinder = UIPlanetFinderWindow.CreateInstance(); _configWin = UIConfigWindow.CreateWindow(); recentPlanets = new List<PlanetData>(100); CreateUI(); } planetFinder?.BeginGame(); } [HarmonyPrefix] [HarmonyPatch(typeof(DSPGame), "EndGame")] public static void DSPGame_EndGame_Prefix() { planetFinder?.EndGame(); } [HarmonyPostfix] [HarmonyPatch(typeof(GameData), "ArrivePlanet")] public static void GameData_ArrivePlanet(PlanetData planet) { AddRecentPlanet(planet); } [HarmonyPostfix] [HarmonyPatch(typeof(UIPlanetDetail), "RefreshDynamicProperties")] public static void UIPlanetDetail_RefreshDynamicProperties(UIPlanetDetail __instance) { if (showFavButtonInStarmap.Value && favBtnGO.activeSelf) { favBtnGO.GetComponent<UIButton>().highlighted = IsFavPlanet(__instance.planet); } } } public const string __NAME__ = "PlanetFinder"; public const string __GUID__ = "com.hetima.dsp.PlanetFinder"; internal static ManualLogSource Logger; public const float LIST_ITEM_WIDTH = 750f; public const float WINDOW_WIDTH = 790f; public static UIPlanetFinderWindow planetFinder; public static UIConfigWindow _configWin; public static List<PlanetData> recentPlanets; public static ConfigEntry<KeyboardShortcut> mainWindowHotkey; public static ConfigEntry<bool> showButtonInMainPanel; public static ConfigEntry<bool> showButtonInStarmap; public static ConfigEntry<bool> showFavButtonInStarmap; public static ConfigEntry<bool> showPowerState; public static ConfigEntry<bool> showPrefix; public static ConfigEntry<bool> showLocateButtonInList; public static ConfigEntry<bool> distanceTextSmallFont; public static ConfigEntry<bool> showVeinCellCount; public static ConfigEntry<bool> showVeinGroupCount; public static ConfigEntry<bool> countReusedVeinGroups; public static ConfigEntry<bool> highlightHighDeuteriumRate; public static ConfigEntry<bool> showPlanetThumbnail; public static ConfigEntry<bool> showRowTooltip; public static ConfigEntry<string> gasGiantPrefix; public static ConfigEntry<string> tidalLockedPrefix; public static ConfigEntry<float> mainWindowSize; public static ConfigEntry<bool> integrationWithDSPStarMapMemo; public static ConfigEntry<bool> integrationWithLSTM; public static ConfigEntry<bool> integrationWithCruiseAssist; public static GameObject panelButtonGO; public static GameObject starmapButtonGO; public static GameObject favBtnGO; public static LSTMIntg aLSTMIntg; public static DSPStarMapMemoIntg aDSPStarMapMemoIntg; public static CruiseAssistIntg aCruiseAssistIntg; private void Awake() { //IL_0010: 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_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("com.hetima.dsp.PlanetFinder"); mainWindowHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keyboard Shortcuts", "mainWindowHotkey", KeyboardShortcut.Deserialize("F + LeftControl"), "hotkey to open/close window / 打开/关闭窗口的快捷键"); showButtonInMainPanel = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "showButtonInMainPanel", true, "show open/close button in main panel / 在主面板显示打开按钮"); showButtonInStarmap = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "showButtonInStarmap", true, "show open/close button in starmap / 在星图显示打开按钮"); showFavButtonInStarmap = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "showFavButtonInStarmap", false, "show toggle favorited button in starmap planet detail panel / 在星图行星详情面板显示收藏按钮"); showPowerState = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "showPowerState", true, "show power consumption / 显示用电情况"); showPrefix = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "showPrefix", true, "show prefix [GAS] and [TL] / 显示 [GAS] 与 [TL] 标记"); showLocateButtonInList = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "showLocateButtonInList", true, "show the locate planet button on each list row / 在每行显示定位按钮"); distanceTextSmallFont = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "distanceTextSmallFont", false, "use the same font size for the distance text as for the vein amount / 距离文本使用与矿脉储量相同的字号"); showVeinCellCount = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "showVeinCellCount", true, "show the mined/total vein cell count as (mined/total) / 显示矿片(矿脉格)开采数量,格式 (已开采/总数)"); showVeinGroupCount = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "showVeinGroupCount", true, "show the mined/total vein group count as [mined/total] / 显示矿点(矿脉区块)开采数量,格式 [已开采/总数]"); countReusedVeinGroups = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "countReusedVeinGroups", false, "count a vein group once per mining machine, so a reused group makes the mined count exceed the total / 按矿机重复计算矿点,被多台矿机覆盖的矿点会重复计数(已开采数可能大于总数)"); highlightHighDeuteriumRate = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "highlightHighDeuteriumRate", true, "highlight a high-yield deuterium extraction speed above 0.100/s in light green / 重氢高产:开采速率超过 0.100/s 时以淡绿色显示"); showPlanetThumbnail = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "showPlanetThumbnail", true, "show a planet thumbnail instead of the colour dot in front of the planet name / 在星球名前显示行星缩略图(关闭则恢复类型色点)"); showRowTooltip = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "showRowTooltip", true, "show 显示每行星球类型: a tooltip with the star/planet type when hovering a row icon or name / 显示每行星球类型:悬停行内图标或名称时显示恒星/行星类型"); gasGiantPrefix = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "gasGiantPrefix", "[GAS]", "gas giant prefix default is [GAS]"); tidalLockedPrefix = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "tidalLockedPrefix", "[TL]", "tidal locked prefix default is [TL] / 潮汐锁定标记,默认为 [TL]"); mainWindowSize = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "mainWindowSize", 8f, "main window row size (4-40) / 主窗口显示行数(4-40)"); integrationWithDSPStarMapMemo = ((BaseUnityPlugin)this).Config.Bind<bool>("Integration", "integrationWithDSPStarMapMemo", false, "display icons set by DSPStarMapMemo / 显示 DSPStarMapMemo 设置的图标"); integrationWithLSTM = ((BaseUnityPlugin)this).Config.Bind<bool>("Integration", "integrationWithLSTM", false, "open LSTM from context menu / 从右键菜单打开 LSTM"); integrationWithCruiseAssist = ((BaseUnityPlugin)this).Config.Bind<bool>("Integration", "integrationWithCruiseAssist", false, "set CruiseAssist from context menu / 从右键菜单设置 CruiseAssist"); val.PatchAll(typeof(Patch)); val.PatchAll(typeof(MyWindowCtl.Patch)); val.PatchAll(typeof(StarDistance.Patch)); } public static bool IsChineseUi() { return Localization.CurrentLanguage.lcId == 2052; } public static void Log(string str) { Logger.LogInfo((object)str); } public static void LogWarning(string str) { Logger.LogWarning((object)str); } public static void UniverseExplorationRequired() { UIMessageBox.Show(Localization.Translate("Upgrades Required"), Localization.Translate("To use this feature, Universe Exploration 4 is required."), "OK", 0); } public static void ViewPlanet(PlanetData planet = null, StarData star = null) { if (planet == null && star == null) { return; } UIRoot.instance.uiGame.ShutPlayerInventory(); UIRoot.instance.uiGame.ShutAllFunctionWindow(); UIRoot.instance.uiGame.OpenStarmap(); int num = ((planet != null) ? (planet.id / 100) : star.id); int num2 = ((planet != null) ? (planet.id % 100) : 0); UIStarmap starmap = UIRoot.instance.uiGame.starmap; if (starmap.starUIs != null) { starmap.focusPlanet = null; starmap.focusStar = starmap.starUIs[num - 1]; starmap.OnCursorFunction2Click(0); if (num2 > 0 && (Object)(object)starmap.focusStar == (Object)null && starmap.planetUIs != null) { starmap.focusPlanet = starmap.planetUIs[num2 - 1]; starmap.OnCursorFunction2Click(0); starmap.focusPlanet = starmap.planetUIs[num2 - 1]; starmap.focusStar = null; } } } public static void LocatePlanet(PlanetData planet = null, StarData star = null) { if (planet != null) { GameMain.mainPlayer.navigation.indicatorAstroId = planet.id; } else if (star != null) { GameMain.mainPlayer.navigation.indicatorAstroId = star.id * 100; } else { GameMain.mainPlayer.navigation.indicatorAstroId = 0; } } public static void TogglePlanetFinderWindow() { if (((ManualBehaviour)planetFinder).active) { ((ManualBehaviour)planetFinder)._Close(); } else { planetFinder.SetUpAndOpen(); } } public static void AddRecentPlanet(PlanetData planetData) { if (recentPlanets.Contains(planetData)) { recentPlanets.Remove(planetData); } recentPlanets.Insert(0, planetData); if (recentPlanets.Count > 99) { recentPlanets.RemoveAt(recentPlanets.Count - 1); } } public static bool IsFavPlanet(PlanetData planetData) { string overrideName = planetData.overrideName; if (string.IsNullOrEmpty(overrideName)) { return false; } if (overrideName.Contains("★")) { return true; } return false; } public static void SetFavPlanet(PlanetData planetData, bool flag) { if (flag) { if (!IsFavPlanet(planetData)) { string displayName = planetData.displayName; displayName += "★"; planetData.overrideName = displayName; GameScenarioLogic gameScenario = GameMain.gameScenario; if (gameScenario != null) { gameScenario.NotifyOnPlanetNameChange(); } GameMain.galaxy.NotifyAstroNameChange(planetData.astroId); } } else { if (!IsFavPlanet(planetData)) { return; } string overrideName = planetData.overrideName; overrideName = overrideName.Replace("★", "").Trim(); if (!string.Equals(overrideName, planetData.overrideName)) { if (string.Equals(overrideName, planetData.name)) { planetData.overrideName = ""; } else { planetData.overrideName = overrideName; } GameScenarioLogic gameScenario2 = GameMain.gameScenario; if (gameScenario2 != null) { gameScenario2.NotifyOnPlanetNameChange(); } GameMain.galaxy.NotifyAstroNameChange(planetData.astroId); } } } 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) if (GameMain.isRunning && !GameMain.isPaused && !GameMain.instance.isMenuDemo && !VFInput.inputing) { KeyboardShortcut value = mainWindowHotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { TogglePlanetFinderWindow(); } else if (VFInput._closePanelE && ((ManualBehaviour)planetFinder).active && !UIPlanetFinderWindow.pinned) { ((ManualBehaviour)planetFinder)._Close(); } } } private void FixedUpdate() { if ((Object)(object)planetFinder != (Object)null && planetFinder.isPointEnter) { VFInput.inScrollView = true; } } public static void CreateUI() { //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) Button button = UIRoot.instance.uiGame.planetGlobe.button2; UIButton dfIconButton = UIRoot.instance.uiGame.gameMenu.dfIconButton; object obj; if (dfIconButton == null) { obj = null; } else { Transform obj2 = ((Component)dfIconButton).transform.Find("icon"); if (obj2 == null) { obj = null; } else { Image component = ((Component)obj2).GetComponent<Image>(); obj = ((component != null) ? component.sprite : null); } } Sprite sprite = (Sprite)obj; Button val = Object.Instantiate<Button>(button, ((Component)button).transform.parent); panelButtonGO = ((val != null) ? ((Component)val).gameObject : null); Transform transform = panelButtonGO.transform; RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null); UIButton component2 = panelButtonGO.GetComponent<UIButton>(); Transform obj3 = panelButtonGO.transform.Find("button-2/icon"); Image val3 = ((obj3 != null) ? ((Component)obj3).GetComponent<Image>() : null); if ((Object)(object)val3 != (Object)null) { val3.sprite = sprite; } if ((Object)(object)panelButtonGO != (Object)null && (Object)(object)component2 != (Object)null) { ((Object)panelButtonGO).name = "open-planet-finder"; ((Transform)val2).localScale = new Vector3(0.6f, 0.6f, 0.6f); val2.anchoredPosition3D = new Vector3(133f, -88f, 0f); ((UnityEventBase)val.onClick).RemoveAllListeners(); component2.onClick += OnShowWindowButtonClick; component2.tips.tipTitle = "Planet Finder"; component2.tips.tipText = "open/close Planet Finder Window"; component2.tips.corner = 9; component2.tips.offset = new Vector2(-20f, -20f); Transform transform2 = panelButtonGO.transform; val2 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null); panelButtonGO.SetActive(showButtonInMainPanel.Value); showButtonInMainPanel.SettingChanged += delegate { panelButtonGO.SetActive(showButtonInMainPanel.Value); }; } UIButton northButton = UIRoot.instance.uiGame.starmap.northButton; Transform val4 = ((northButton != null) ? ((Component)northButton).transform.parent : null); if ((Object)(object)val4 != (Object)null) { starmapButtonGO = Object.Instantiate<GameObject>(panelButtonGO, val4); starmapButtonGO.SetActive(showButtonInStarmap.Value); component2 = starmapButtonGO.GetComponent<UIButton>(); component2.onClick += OnShowWindowButtonClick; component2.tips.corner = 7; component2.tips.offset = new Vector2(25f, -8f); Transform transform3 = starmapButtonGO.transform; val2 = (RectTransform)(object)((transform3 is RectTransform) ? transform3 : null); val2.anchorMin = new Vector2(1f, 0f); val2.anchorMax = new Vector2(1f, 0f); val2.pivot = new Vector2(1f, 0f); val2.anchoredPosition = new Vector2(-16f, 48f); showButtonInStarmap.SettingChanged += delegate { starmapButtonGO.SetActive(showButtonInStarmap.Value); }; } UIPlanetDetail planetDetail = UIRoot.instance.uiGame.planetDetail; val4 = ((planetDetail != null) ? ((Component)planetDetail).transform : null); if ((Object)(object)val4 != (Object)null) { UIButton obj4 = Util.MakeHiliteTextButton("★", 18f, 18f); obj4.onClick += OnStarmapFavButtonClick; Util.NormalizeRectWithTopLeft((Component)(object)obj4, 218f, 38f, val4); favBtnGO = ((Component)obj4).gameObject; ((Object)favBtnGO).name = "planetfinder-fav"; favBtnGO.SetActive(showFavButtonInStarmap.Value); showFavButtonInStarmap.SettingChanged += delegate { favBtnGO.SetActive(showFavButtonInStarmap.Value); }; } } public static void OnStarmapFavButtonClick(int obj) { UIPlanetDetail planetDetail = UIRoot.instance.uiGame.planetDetail; PlanetData planet = planetDetail.planet; SetFavPlanet(planet, !IsFavPlanet(planet)); favBtnGO.GetComponent<UIButton>().highlighted = IsFavPlanet(planet); if (!planetDetail.nameInput.isFocused) { planetDetail.nameInput.text = planetDetail.planet.displayName; } } public static void OnShowWindowButtonClick(int obj) { TogglePlanetFinderWindow(); } } public static class PlanetThumbnail { private static readonly Dictionary<long, Sprite> planetCache = new Dictionary<long, Sprite>(); private static readonly Dictionary<string, Sprite> starCache = new Dictionary<string, Sprite>(); private static bool loggedFailure; private static bool loggedSummary; private static Sprite outline; public static Sprite OutlineSprite { get { if ((Object)(object)outline == (Object)null) { outline = MakeOutline(); } return outline; } } public static Sprite Get(PlanetData pd) { if (pd == null || pd.theme <= 0) { return null; } int num = pd.style; long key = ((long)pd.theme << 8) | (num & 0xFF); if (planetCache.TryGetValue(key, out var value)) { return value; } Sprite val = null; try { Sprite[] array = ((ProtoSet<ThemeProto>)(object)LDB.themes).Select(pd.theme)?.uiIconSprite; if (array != null && array.Length != 0) { if (num < 0 || num >= array.Length) { num = 0; } val = (((Object)(object)array[num] != (Object)null) ? array[num] : array[0]); } if ((Object)(object)val == (Object)null) { LogOnce("planet icon is not available for theme " + pd.theme + " style " + pd.style + " (uiIconSprite=" + ((array == null) ? "null" : array.Length.ToString()) + "), using colour dots"); } } catch (Exception ex) { LogOnce("planet icon failed: " + ex.Message); } planetCache[key] = val; return val; } public static Sprite GetStar(StarData sd) { if (sd == null) { return null; } string text = StarSpriteName(sd); if (starCache.TryGetValue(text, out var value)) { return value; } Sprite val = null; try { val = Resources.Load<Sprite>(text); if ((Object)(object)val == (Object)null) { Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>(); foreach (Sprite val2 in array) { if ((Object)(object)val2 != (Object)null && ((Object)val2).name == text) { val = val2; break; } } } if ((Object)(object)val != (Object)null) { Sprite val3 = MakeAlphaSprite(val); if ((Object)(object)val3 != (Object)null) { val = val3; } } } catch (Exception ex) { LogOnce("star icon failed: " + ex.Message); } if ((Object)(object)val == (Object)null) { LogOnce("star icon is not available (" + text + "), using colour dots"); } starCache[text] = val; return val; } private static Sprite MakeAlphaSprite(Sprite source) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) Texture val = (Texture)(object)(((Object)(object)source != (Object)null) ? source.texture : null); if ((Object)(object)val == (Object)null) { return null; } RenderTexture temporary = RenderTexture.GetTemporary(64, 64, 0, (RenderTextureFormat)0); RenderTexture active = RenderTexture.active; Graphics.Blit(val, temporary); RenderTexture.active = temporary; Texture2D val2 = new Texture2D(64, 64, (TextureFormat)4, false); val2.ReadPixels(new Rect(0f, 0f, 64f, 64f), 0, 0); val2.Apply(false, false); Color[] pixels = val2.GetPixels(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Object.Destroy((Object)val2); float num = 0f; for (int i = 0; i < pixels.Length; i++) { float num2 = Mathf.Max(pixels[i].r, Mathf.Max(pixels[i].g, pixels[i].b)) * pixels[i].a; if (num2 > num) { num = num2; } } if (num <= 0.01f) { return null; } Texture2D val3 = new Texture2D(64, 64, (TextureFormat)4, false); Color[] array = (Color[])(object)new Color[pixels.Length]; float num3 = 1.15f / num; for (int j = 0; j < pixels.Length; j++) { float num4 = Mathf.Max(pixels[j].r, Mathf.Max(pixels[j].g, pixels[j].b)) * pixels[j].a; array[j] = new Color(1f, 1f, 1f, Mathf.Clamp01(num4 * num3)); } val3.SetPixels(array); val3.Apply(false, false); return Sprite.Create(val3, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); } public static string StarSpriteName(StarData sd) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected I4, but got Unknown EStarType type = sd.type; return (type - 1) switch { 0 => "round-star-giant", 1 => "round-star-whitedwarf", 2 => "round-star-neutron", 3 => "round-star-blackhole", _ => "round-star-mainseq", }; } private static Sprite MakeOutline() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(48, 48, (TextureFormat)4, false); Color[] array = (Color[])(object)new Color[2304]; for (int i = 0; i < 48; i++) { for (int j = 0; j < 48; j++) { float num = ((float)j + 0.5f) / 48f * 2f - 1f; float num2 = ((float)i + 0.5f) / 48f * 2f - 1f; float num3 = Mathf.Exp(0f - Mathf.Pow((Mathf.Sqrt(num * num + num2 * num2) - 0.72f) / 0.055f, 2f)); array[i * 48 + j] = new Color(1f, 1f, 1f, Mathf.Clamp01(num3 * 0.75f)); } } val.SetPixels(array); val.Apply(false, false); return Sprite.Create(val, new Rect(0f, 0f, 48f, 48f), new Vector2(0.5f, 0.5f), 48f, 0u, (SpriteMeshType)0); } private static void LogOnce(string message) { if (!loggedFailure) { loggedFailure = true; PLFN.LogWarning(message); } } } 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 RowHoverForward : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler { public UIPlanetFinderListItem item; public void OnPointerEnter(PointerEventData eventData) { if (!((Object)(object)item == (Object)null)) { item.ShowRowButtons(show: true); RowTip.Show(item, item.ObjectTypeText()); } } public void OnPointerExit(PointerEventData eventData) { RowTip.Hide(); if ((Object)(object)item != (Object)null) { item.ShowRowButtons(show: false); } } public void OnPointerClick(PointerEventData eventData) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if (!((Object)(object)item == (Object)null) && (int)eventData.button == 1) { RowTip.Hide(); item.window.ShowMenu(item); } } } public class RowTip : MonoBehaviour { private static RowTip instance; private static bool warnedPrefab; private static bool hookedConfig; private UISimpleGeneralTip tip; public static void Show(UIPlanetFinderListItem item, string titleText) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00b6: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(titleText) || !PLFN.showRowTooltip.Value) { Hide(); return; } titleText = titleText.Replace(" 型", "型").Replace(" 巨", "巨").Replace(" 恒", "恒"); Ensure(item); if ((Object)(object)instance == (Object)null) { return; } TipSettings val = new TipSettings { topLevel = true, corner = 0, width = 0, offset = Vector2.zero, tipTitle = titleText, tipText = "", tipSprite = null }; RectTransform val2 = (RectTransform)((Component)instance).transform; ((Component)instance.tip).gameObject.SetActive(true); instance.tip.SetTip(ref val, val2, titleText, ""); if ((Object)(object)instance.tip.subTextComp != (Object)null) { ((Component)instance.tip.subTextComp).gameObject.SetActive(false); } if ((Object)(object)instance.tip.titleComp != (Object)null) { Text titleComp = instance.tip.titleComp; titleComp.text = titleText; titleComp.horizontalOverflow = (HorizontalWrapMode)1; titleComp.verticalOverflow = (VerticalWrapMode)1; } Transform transform = ((Component)item).transform; RectTransform val3 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if (!((Object)(object)val3 != (Object)null)) { return; } Vector3[] array = (Vector3[])(object)new Vector3[4]; val3.GetWorldCorners(array); Canvas componentInParent = ((Component)val3).GetComponentInParent<Canvas>(); Camera val4 = null; if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) { val4 = componentInParent.worldCamera; } Vector2 val5 = RectTransformUtility.WorldToScreenPoint(val4, array[0]); Vector2 val6 = RectTransformUtility.WorldToScreenPoint(val4, array[1]); if (val5.x <= 1f && val5.y <= 1f) { val5 = Vector2.op_Implicit(Input.mousePosition); val6 = val5 + new Vector2(0f, 24f); } Vector2 val7 = default(Vector2); ((Vector2)(ref val7))..ctor(val5.x + 18f, val6.y + 4f); RectTransform val8 = (RectTransform)(((Object)(object)instance.tip.trans != (Object)null) ? ((object)instance.tip.trans) : ((object)/*isinst with value type is only supported in some contexts*/)); if ((Object)(object)val8 != (Object)null) { val8.pivot = new Vector2(0f, 0f); Transform parent = ((Transform)val8).parent; RectTransform val9 = (RectTransform)(object)((parent is RectTransform) ? parent : null); Canvas componentInParent2 = ((Component)val8).GetComponentInParent<Canvas>(); Camera val10 = (((Object)(object)componentInParent2 != (Object)null && (int)componentInParent2.renderMode != 0) ? componentInParent2.worldCamera : null); Vector3 position = default(Vector3); if ((Object)(object)val9 != (Object)null && RectTransformUtility.ScreenPointToWorldPointInRectangle(val9, val7, val10, ref position)) { ((Transform)val8).position = position; } else { ((Transform)val8).position = new Vector3(val7.x, val7.y, 0f); } } } public static void Hide() { if ((Object)(object)instance != (Object)null && (Object)(object)instance.tip != (Object)null) { ((Component)instance.tip).gameObject.SetActive(false); } } private static void Ensure(UIPlanetFinderListItem item) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a6: 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_00b2: Expected O, but got Unknown if ((Object)(object)instance != (Object)null) { return; } UIRoot val = UIRoot.instance; if ((Object)(object)val == (Object)null) { return; } if (!hookedConfig) { hookedConfig = true; PLFN.showRowTooltip.SettingChanged += delegate { Hide(); }; } UISimpleGeneralTip val2 = FindTipPrefab(); if ((Object)(object)val2 == (Object)null) { if (!warnedPrefab) { warnedPrefab = true; PLFN.LogWarning("[tip] native tip prefab not found"); } return; } GameObject val3 = new GameObject("PlanetFinder-RowTip", new Type[1] { typeof(RectTransform) }) { layer = 5 }; RowTip rowTip = val3.AddComponent<RowTip>(); RectTransform val4 = (RectTransform)val3.transform; ((Transform)val4).SetParent(((Component)val).transform, false); Canvas obj = val3.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 32000; obj.pixelPerfect = false; UISimpleGeneralTip val5 = Object.Instantiate<UISimpleGeneralTip>(val2, (Transform)(object)val4); ((Object)((Component)val5).gameObject).name = "native-tip"; ((Component)val5).gameObject.layer = 5; ((Component)val5).gameObject.SetActive(false); rowTip.tip = val5; instance = rowTip; } private static UISimpleGeneralTip FindTipPrefab() { try { UIGalaxySelect val = (((Object)(object)UIRoot.instance != (Object)null) ? UIRoot.instance.galaxySelect : null); Transform val2 = (((Object)(object)val != (Object)null && (Object)(object)val.sandboxToggle != (Object)null) ? ((Component)val.sandboxToggle).transform : null); Transform val3 = (((Object)(object)val2 != (Object)null && (Object)(object)val2.parent != (Object)null) ? val2.parent.Find("tip-button") : null); UIButton val4 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<UIButton>() : null); if ((Object)(object)val4 != (Object)null && (Object)(object)val4.tips.simpleGeneralTipPrefab != (Object)null) { return val4.tips.simpleGeneralTipPrefab; } } catch (Exception) { } try { UIButton[] array = Resources.FindObjectsOfTypeAll<UIButton>(); foreach (UIButton val5 in array) { if ((Object)(object)val5 != (Object)null && (Object)(object)val5.tips.simpleGeneralTipPrefab != (Object)null) { return val5.tips.simpleGeneralTipPrefab; } } } catch (Exception) { } return null; } } public class StarDistance { 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 DistanceFromHere(int star, int nearStar = 0) { int num = ((GameMain.localPlanet == null) ? nearStar : GameMain.localPlanet.star.id); if (num != 0) { return Distance(star, num); } return -1f; } public static float Distance(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; } internal 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 UIConfigWindow : ManualBehaviour, MyWindow { public RectTransform windowTrans; public RectTransform tab1; public UIButton tabBtn1; private readonly List<(Text text, string en, string zh)> languageEntries = new List<(Text, string, string)>(); public static UIConfigWindow CreateWindow() { return MyWindowCtl.CreateWindow<UIConfigWindow>("PLFDConfigWindow", "PlanetFinder Config"); } public void TryClose() { ((ManualBehaviour)this)._Close(); } public bool isFunctionWindow() { return true; } private void ApplyLanguage() { bool flag = PLFN.IsChineseUi(); foreach (var languageEntry in languageEntries) { if ((Object)(object)languageEntry.text != (Object)null) { languageEntry.text.text = (flag ? languageEntry.zh : languageEntry.en); } } } private static string L(string en, string zh) { if (!PLFN.IsChineseUi()) { return en; } return zh; } public void OpenWindow() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) ApplyLanguage(); MyWindowCtl.OpenWindow((ManualBehaviour)(object)this); if ((Object)(object)windowTrans != (Object)null) { windowTrans.sizeDelta = new Vector2(640f, 516f); } } public override void _OnCreate() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) windowTrans = MyWindowCtl.GetRectTransform((ManualBehaviour)(object)this); windowTrans.sizeDelta = new Vector2(640f, 516f); CreateUI(); } internal void CreateUI() { RectTransform base_ = windowTrans; float y_ = 54f; float x_ = 36f; float tabx_ = 36f; int tabIndex_ = 1; tab1 = AddTab(L("General", "通用"), out tabBtn1); ((Component)tabBtn1).gameObject.SetActive(false); base_ = tab1; y_ = 0f; x_ = 0f; RectTransform val = MyKeyBinder.CreateKeyBinder(PLFN.mainWindowHotkey, "Main Hotkey"); Text val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponentInChildren<Text>() : null); if ((Object)(object)val2 != (Object)null) { languageEntries.Add((val2, "Main Hotkey", "主快捷键")); } AddElement(val, 90f); val = MakeCheckBox(PLFN.showButtonInMainPanel, "Show Button In Main Panel", "主面板显示按钮"); AddElement(val, 26f); val = MakeCheckBox(PLFN.showButtonInStarmap, "Show Button In Starmap", "星图显示按钮"); AddElement(val, 26f); Text val3 = MakeLabel("Window Size", "窗口行数"); Transform transform = ((Component)val3).transform; AddElement((RectTransform)(object)((transform is RectTransform) ? transform : null), 32f); val = MySlider.CreateSlider(PLFN.mainWindowSize, 4f, 40f, "0", 200f); AddElement(val, 26f); val = MakeCheckBox(PLFN.showPowerState, "Show Power State In List", "列表显示用电状态"); AddElement(val, 26f); val = MakeCheckBox(PLFN.showPrefix, "Show [GAS] [TL] Prefix", "显示 [GAS] [TL] 前缀"); AddElement(val, 26f); val = MakeCheckBox(PLFN.showLocateButtonInList, "Show Locate Button In List", "列表显示定位按钮"); AddElement(val, 26f); val = MakeCheckBox(PLFN.showVeinCellCount, "Show Vein Cell Count", "显示矿片数 (A/B)"); AddElement(val, 26f); val = MakeCheckBox(PLFN.showVeinGroupCount, "Show Vein Group Count", "显示矿点数 [A/B]"); AddElement(val, 26f); RectTransform val4 = MakeCheckBox(PLFN.countReusedVeinGroups, "Count Reused Vein Groups", "矿点按矿机重复计数"); AddElement(val4, 26f); MyCheckBox reusedBox = ((Component)val4).GetComponent<MyCheckBox>(); PLFN.showVeinGroupCount.SettingChanged += delegate { SyncReusedBox(); }; SyncReusedBox(); val = MakeCheckBox(PLFN.highlightHighDeuteriumRate, "Highlight High Deuterium Rate", "重氢高产高亮"); AddElement(val, 26f); val = MakeCheckBox(PLFN.showPlanetThumbnail, "Show Planet Thumbnail", "显示行星图标"); AddElement(val, 26f); val = MakeCheckBox(PLFN.showRowTooltip, "Show Planet Type Per Row", "显示每行星球类型"); AddElement(val, 26f); x_ = 290f; y_ = 0f; val = MakeCheckBox(PLFN.showFavButtonInStarmap, "Show Fav Button In Starmap", "星图显示收藏按钮"); AddElement(val, 26f); val = MakeCheckBox(PLFN.distanceTextSmallFont, "Small Font For Distance", "距离使用小字号"); AddElement(val, 26f); if (PLFN.aDSPStarMapMemoIntg.canGetSignalIconId) { val = MakeCheckBox(PLFN.integrationWithDSPStarMapMemo, "Integration With DSPStarMapMemo", "联动 DSPStarMapMemo"); AddElement(val, 22f); x_ += 32f; val3 = MakeLabel("Display Icons / Search Memo", "显示图标 / 搜索便签"); val3.fontSize = 14; AddElement(((Graphic)val3).rectTransform, 24f); x_ -= 32f; } if (PLFN.aLSTMIntg.canOpenPlanetId) { val = MakeCheckBox(PLFN.integrationWithLSTM, "Integration With LSTM", "联动 LSTM"); AddElement(val, 22f); x_ += 32f; val3 = MakeLabel("Open LSTM From Context Panel", "右键菜单打开 LSTM"); val3.fontSize = 14; AddElement(((Graphic)val3).rectTransform, 24f); x_ -= 32f; } if (PLFN.aCruiseAssistIntg.canSelectPlanet) { val = MakeCheckBox(PLFN.integrationWithCruiseAssist, "Integration With CruiseAssist", "联动 CruiseAssist"); AddElement(val, 22f); x_ += 32f; val3 = MakeLabel("Set CruiseAssist From Context Panel", "右键菜单设置 CruiseAssist"); val3.fontSize = 14; AddElement(((Graphic)val3).rectTransform, 24f); x_ -= 32f; } y_ = 0f; x_ = 0f; void AddElement(RectTransform rect_, float height) { if ((Object)(object)rect_ != (Object)null) { Util.NormalizeRectWithTopLeft((Component)(object)rect_, x_, y_, (Transform)(object)base_); } y_ += height; } RectTransform AddTab(string label, out UIButton outBtn) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) GameObject val5 = new GameObject(); RectTransform val6 = val5.AddComponent<RectTransform>(); Util.NormalizeRectWithMargin((Component)(object)val6, 48f, 36f, 0f, 0f, (Transform)(object)windowTrans); ((Object)val5).name = "tab-" + tabIndex_; UIButton val7 = Object.Instantiate<UIButton>(UIRoot.instance.uiGame.dysonEditor.controlPanel.hierarchy.swarmPanel.orbitButtons[0]); Util.NormalizeRectWithTopLeft((Component)(object)val7, tabx_, 44f, (Transform)(object)windowTrans).sizeDelta = new Vector2(100f, 24f); ((Component)((Component)val7).transform.Find("frame")).gameObject.SetActive(false); if (val7.transitions.Length >= 3) { val7.transitions[0].normalColor = new Color(0.1f, 0.1f, 0.1f, 0.68f); val7.transitions[0].highlightColorOverride = new Color(0.9906f, 0.5897f, 0.3691f, 0.4f); val7.transitions[1].normalColor = new Color(1f, 1f, 1f, 0.6f); val7.transitions[1].highlightColorOverride = new Color(0.2f, 0.1f, 0.1f, 0.9f); } Text component = ((Component)((Component)val7).transform.Find("Text")).GetComponent<Text>(); component.text = label; component.fontSize = 16; val7.data = tabIndex_; tabIndex_++; tabx_ += 100f; outBtn = val7; return val6; } Text CreateText(string label_) { //IL_003d: 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) Text val5 = Object.Instantiate<Text>(MyWindowCtl.GetTitleText((ManualBehaviour)(object)this)); ((Object)((Component)val5).gameObject).name = "label"; val5.text = label_; ((Graphic)val5).color = new Color(1f, 1f, 1f, 0.38f); Transform transform2 = ((Component)val5).transform; ((RectTransform)((transform2 is RectTransform) ? transform2 : null)).sizeDelta = new Vector2(val5.preferredWidth + 40f, 30f); return val5; } RectTransform MakeCheckBox(ConfigEntry<bool> config, string en, string zh) { RectTransform val5 = MyCheckBox.CreateCheckBox(config, en); MyCheckBox myCheckBox = (((Object)(object)val5 != (Object)null) ? ((Component)val5).GetComponent<MyCheckBox>() : null); if ((Object)(object)myCheckBox != (Object)null && (Object)(object)myCheckBox.labelText != (Object)null) { languageEntries.Add((myCheckBox.labelText, en, zh)); } return val5; } Text MakeLabel(string en, string zh) { Text val5 = CreateText(en); languageEntries.Add((val5, en, zh)); return val5; } void SyncReusedBox() { if ((Object)(object)reusedBox != (Object)null) { reusedBox.SetInteractable(PLFN.showVeinGroupCount.Value); } } } public override void _OnDestroy() { } public override bool _OnInit() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) windowTrans.anchoredPosition = new Vector2(0f, 0f); return true; } public override void _OnFree() { } public override void _OnRegEvent() { } public override void _OnUnregEvent() { } public override void _OnOpen() { } public override void _OnClose() { } public override void _OnUpdate() { if (VFInput.escape && !VFInput.inputing) { VFInput.UseEscape(); ((ManualBehaviour)this)._Close(); } } } public class UIItemSelection : MonoBehaviour { public static UIButton buttonPrefab; public static Sprite emptyImage; public UIPlanetFinderWindow planetFinderWindow; public RectTransform rectTrans; public List<UIButton> buttons; public List<string> buttonNames; public static int[] additionalMaterials = new int[6] { 1000, 1116, 0, 1120, 1121, 1011 }; public HashSet<int> items; public int lastSelectedItemId; public static UIButton CreatePrefab() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) UIButton val = null; UIButton[] buildingWarnButtons = UIRoot.instance.optionWindow.buildingWarnButtons; if (buildingWarnButtons != null && buildingWarnButtons.Length != 0) { val = Object.Instantiate<UIButton>(buildingWarnButtons[0]); val.onClick += null; ((Object)((Component)val).gameObject).name = "item-button"; val.tips.tipText = ""; val.tips.tipTitle = ""; val.tips.delay = 0.6f; val.tips.corner = 8; Transform transform = ((Component)val).transform; Transform obj = ((transform is RectTransform) ? transform : null); ((RectTransform)obj).sizeDelta = new Vector2(28f, 28f); foreach (Transform item in obj) { Transform val2 = item; ((RectTransform)((val2 is RectTransform) ? val2 : null)).sizeDelta = new Vector2(28f, 28f); if (((Object)((Component)val2).gameObject).name == "image") { ((Graphic)((Component)val2).GetComponent<Image>()).color = Color.white; } } if (val.transitions.Length > 1) { val.transitions[1].mouseoverColor = Color.white; val.transitions[1].normalColor = Color.white; } } return val; } public static UIButton CreateSelectButton(UIItemSelection owner) { if ((Object)(object)buttonPrefab == (Object)null) { Image iconTagImage = UIRoot.instance.uiGame.beltWindow.iconTagImage; emptyImage = ((iconTagImage != null) ? iconTagImage.sprite : null); buttonPrefab = CreatePrefab(); } UIButton obj = Object.Instantiate<UIButton>(buttonPrefab); obj.onClick += owner.OnSelectButtonClick; obj.onRightClick += owner.OnSelectButtonRightClick; return obj; } public static void SetButtonIcon(UIButton btn, Sprite sprite, string name, int obj) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) Transform obj2 = ((Component)btn).transform.Find("image"); Image val = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null); if ((Object)(object)val != (Object)null) { val.sprite = sprite; } btn.data = obj; if (name != null) { btn.tips.tipTitle = name; btn.tips.corner = 9; btn.tips.offset = new Vector2(-26f, 4f); } } public Sprite GetIconForItemId(int itemId) { if (itemId == 0) { return null; } foreach (UIButton button in buttons) { if (button.data == itemId) { Transform obj = ((Component)button).transform.Find("image"); Image val = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null); if ((Object)(object)val != (Object)null) { return val.sprite; } } } return null; } public string MouseOverButtonName() { for (int i = 0; i < buttons.Count; i++) { if (buttons[i]._isPointerEnter) { return buttonNames[i]; } } return null; } public static UIItemSelection CreateInstance() { UIItemSelection uIItemSelection = Util.CreateGameObject<UIItemSelection>("item-selection", 500f, 30f); uIItemSelection.Init(); return uIItemSelection; } private void Init() { items = new HashSet<int>(); ref RectTransform reference = ref rectTrans; Transform transform = ((Component)this).transform; reference = (RectTransform)(object)((transform is RectTransform) ? transform : null); float top = 4f; float num = 0f; buttons = new List<UIButton>(40); buttonNames = new List<string>(40); for (int i = 1; i < 15; i++) { VeinProto val = ((ProtoSet<VeinProto>)(object)LDB.veins).Select(i); ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(val.MiningItem); if (val != null && val2 != null) { UIButton val3 = CreateSelectButton(this); Util.NormalizeRectWithTopLeft((Component)(object)val3, num, top, (Transform)(object)rectTrans); ((Selectable)val3.button).interactable = true; SetButtonIcon(val3, val.iconSprite, ((Proto)val).name, ((Proto)val).ID); buttons.Add(val3); buttonNames.Add(((Proto)val).name); num += 30f; } } num += 6f; int[] array = additionalMaterials; foreach (int num2 in array) { if (num2 == 0) { num += 6f; continue; } ItemProto val4 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(num2); if (val4 != null) { UIButton val5 = CreateSelectButton(this); Util.NormalizeRectWithTopLeft((Component)(object)val5, num, top, (Transform)(object)rectTrans); ((Selectable)val5.button).interactable = true; SetButtonIcon(val5, val4.iconSprite, ((Proto)val4).name, num2); buttons.Add(val5); buttonNames.Add(((Proto)val4).name); num += 30f; } } } public void RefreshButtons() { foreach (UIButton button in buttons) { button.highlighted = items.Contains(button.data); } } public void ToggleItemSelected(int itemId, bool multiple = false) { if (items.Contains(itemId)) { if (!multiple) { items.Clear(); lastSelectedItemId = 0; } else { items.Remove(itemId); if (lastSelectedItemId == itemId) { if (items.Count > 0) { foreach (int item in items) { lastSelectedItemId = item; } } else { lastSelectedItemId = 0; } } } } else { if (!multiple) { items.Clear(); } items.Add(itemId); lastSelectedItemId = itemId; } RefreshButtons(); planetFinderWindow.SetUpData(); } public void OnSelectButtonClick(int obj) { if (obj != 0) { ToggleItemSelected(obj, VFInput.shift); } } public void OnSelectButtonRightClick(int obj) { } public int NextTargetItemId(int targetItemId, bool includesEmpty = false) { if (items.Count == 0) { return targetItemId; } int num = int.MaxValue; int num2 = int.MaxValue; foreach (int item in items) { if (targetItemId >= item && num > item) { num = item; } if (targetItemId < item && num2 > item) { num2 = item; } } if (num2 != int.MaxValue) { return num2; } if (includesEmpty) { return 0; } if (num != int.MaxValue) { return num; } return targetItemId; } } public class UIPlanetFinderListItem : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler { public static Sprite circleSprite; public static Color valueTextNormalColor; public static Color valueTextMiningColor; public static Color gasRateHighlightColor; private const int DeuteriumItemId = 1121; private const float HighGasSpeedThreshold = 0.1f; private const short OrbitalCollectorProtoId = 2105; public UIPlanetFinderWindow window; public bool firstRefleshed; public PlanetListData listData; public PlanetData planetData; public StarData starData; public string distanceStr; public Color planetColor; private int _itemId; [SerializeField] public Text nameText; [SerializeField] public Text distanceText; [SerializeField] public Text prefixLabel; [SerializeField] public Text valueText; [SerializeField] public Text gasRateText; [SerializeField] public Text valueSketchText; [SerializeField] public Text groupText; [SerializeField] public Image labelIcon; [SerializeField] public Image iconHalo; [SerializeField] public Sprite iconHide; [SerializeField] public UIButton iconButton; [SerializeField] public UIButton viewBtn; [SerializeField] public UIButton locateBtn; [SerializeField] public GameObject baseObj; public StringBuilder sb; private static bool loggedThemeName; public static int veinCount = 15; public bool disableUIAction; public string planetName { get { return nameText.text; } set { nameText.text = value; } } public int itemId { get { return _itemId; } set { if (_itemId != value) { _itemId = value; sb = ((_itemId == 7) ? window.sbOil : window.sb); } } } public static UIPlanetFinderListItem CreateListViewPrefab() { //IL_006e: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0278: 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_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05ff: 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_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_0737: Unknown result type (might be due to invalid IL or missing references) //IL_081d: Unknown result type (might be due to invalid IL or missing references) //IL_0832: Unknown result type (might be due to invalid IL or missing references) //IL_0847: Unknown result type (might be due to invalid IL or missing references) //IL_0852: Unknown result type (might be due to invalid IL or missing references) //IL_0867: Unknown result type (might be due to invalid IL or missing references) //IL_0871: Unknown result type (might be due to invalid IL or missing references) //IL_0895: Unknown result type (might be due to invalid IL or missing references) //IL_0907: Unknown result type (might be due to invalid IL or missing references) UIPlanetFinderListItem uIPlanetFinderListItem = Util.CreateGameObject<UIPlanetFinderListItem>("list-item", 750f, 24f); Image val = Util.CreateGameObject<Image>("list-item", 750f, 24f); ((Component)val).gameObject.SetActive(true); RectTransform val2 = Util.NormalizeRectWithTopLeft((Component)(object)val, 0f, 0f, ((Component)uIPlanetFinderListItem).transform); uIPlanetFinderListItem.baseObj = ((Component)val).gameObject; ((Graphic)val).color = new Color(0.2f, 0.2f, 0.2f, 0.1f); Transform transform = ((Component)uIPlanetFinderListItem).transform; ((RectTransform)((transform is RectTransform) ? transform : null)).sizeDelta = new Vector2(750f, 24f); val2.sizeDelta = new Vector2(750f, 24f); ((Transform)val2).localScale = Vector3.one; UIPlanetDetail planetDetail = UIRoot.instance.uiGame.planetDetail; UIResAmountEntry val3 = Object.Instantiate<UIResAmountEntry>(planetDetail.entryPrafab, (Transform)(object)val2); ((Component)val3).gameObject.SetActive(true); UIButton val4 = Util.MakeIconButtonB(Util.viewPlanetIcon, 22f); if ((Object)(object)val4 != (Object)null) { ((Object)((Component)val4).gameObject).name = "view-btn"; Util.NormalizeRectWithTopLeft((Component)(object)val4, 668f, 3f, (Transform)(object)val2); val4.tips.tipTitle = Localization.Translate("View Planet"); val4.tips.tipText = Localization.Translate("Show the planet on the starmap."); val4.tips.corner = 3; val4.tips.offset = new Vector2(18f, -20f); uIPlanetFinderListItem.viewBtn = val4; } UIButton val5 = Util.MakeIconButtonB(Util.astroIndicatorIcon, 22f); if ((Object)(object)val5 != (Object)null) { ((Object)((Component)val5).gameObject).name = "locate-btn"; Util.NormalizeRectWithTopLeft((Component)(object)val5, 694f, 3f, (Transform)(object)val2); val5.tips.tipTitle = Localization.Translate("Locate Planet"); val5.tips.tipText = Localization.Translate("Locate the planet."); val5.tips.corner = 3; val5.tips.offset = new Vector2(18f, -20f); uIPlanetFinderListItem.locateBtn = val5; } uIPlanetFinderListItem.nameText = val3.labelText; uIPlanetFinderListItem.nameText.text = ""; uIPlanetFinderListItem.nameText.iconMapping = planetDetail.nameInput.textComponent.iconMapping; uIPlanetFinderListItem.nameText.fontSize = 16; ((Graphic)uIPlanetFinderListItem.nameText).rectTransform.anchoredPosition = new Vector2(30f, 0f); uIPlanetFinderListItem.valueText = val3.valueText; uIPlanetFinderListItem.valueText.text = ""; ((Graphic)uIPlanetFinderListItem.valueText).color = ((Graphic)uIPlanetFinderListItem.nameText).color; uIPlanetFinderListItem.valueText.supportRichText = true; Util.SetFixedSizeAtTopLeft((Component)(object)uIPlanetFinderListItem.valueText, 417f, 2f, 70f, 24f); uIPlanetFinderListItem.valueText.alignment = (TextAnchor)5; uIPlanetFinderListItem.valueText.horizontalOverflow = (HorizontalWrapMode)1; uIPlanetFinderListItem.valueText.verticalOverflow = (VerticalWrapMode)1; valueTextNormalColor = ((Graphic)uIPlanetFinderL