Decompiled source of StarSystemProduction v0.2.0
StarSystemProduction.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Bootstrap; using HarmonyLib; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: InternalsVisibleTo("StarSystemProduction.Tests")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: CompilationRelaxations(8)] [assembly: AssemblyTitle("Star System Production")] [assembly: AssemblyCompany("Loki Moon Labs")] [assembly: AssemblyVersion("0.2.0.0")] namespace LokiMoonLabs.StarSystemProduction; internal static class Branding { internal static byte[] ReadIcon() { using Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream("LokiMoonLabs.StarSystemProduction.icon.png"); if (stream == null) { throw new InvalidOperationException("Embedded Loki Moon Labs icon is missing."); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } internal static Texture2D LoadIcon() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2); if (!ImageConversion.LoadImage(val, ReadIcon())) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Cannot load the embedded Loki Moon Labs icon."); } return val; } } internal static class DisplayNames { private static Func<string, bool, bool, string> translator; internal static void Bind() { if (Chainloader.PluginInfos.TryGetValue("com.lokimoonlabs.chinesetoenglishmodtranslator", out var value)) { Type type = ((object)value.Instance).GetType().Assembly.GetType("ChineseToEnglishModTranslator.TranslationRuntime"); MethodInfo methodInfo = ((type == null) ? null : type.GetMethod("Render", BindingFlags.Static | BindingFlags.Public, null, new Type[3] { typeof(string), typeof(bool), typeof(bool) }, null)); if (methodInfo != null) { translator = (Func<string, bool, bool, string>)Delegate.CreateDelegate(typeof(Func<string, bool, bool, string>), methodInfo); } } } internal static string Translate(string value, bool english, Func<string, bool, bool, string> render) { if (value == null || !english || render == null) { return value; } foreach (char c in value) { if (c >= '㐀' && c <= '鿿') { return render(value, arg2: true, arg3: false); } } return value; } internal static string Name(Proto proto) { if (proto == null) { return ""; } string name = proto.name; try { return Translate(name, Localization.isENUS, translator); } catch { return name; } } } internal sealed class Launcher { private readonly Action toggle; private UIGameMenu owner; private readonly Action<string> report; private GameObject root; private RectTransform rect; private Texture2D texture; private Sprite sprite; private Texture2D fillTexture; private Sprite fillSprite; private int lastClickFrame = -1; internal bool Blocking { get { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root != (Object)null && root.activeInHierarchy) { return RectTransformUtility.RectangleContainsScreenPoint(rect, Vector2.op_Implicit(Input.mousePosition), (Camera)null); } return false; } } internal Launcher(Action toggle, Action<string> report) { this.toggle = toggle; this.report = report; } internal static Vector2 Position(Vector2 center, float mechHeight, float buttonHeight, float gap) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) return new Vector2(center.x, center.y + (mechHeight + buttonHeight) * 0.5f + gap); } internal void Update(UIGameMenu menu, RectTransform parent) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)owner != (Object)(object)menu || ((Object)(object)owner != (Object)null && (Object)(object)root == (Object)null)) { Dispose(); owner = menu; } if (!((Object)(object)menu == (Object)null) && !((Object)(object)menu.button5 == (Object)null) && !((Object)(object)menu.button2 == (Object)null) && !((Object)(object)parent == (Object)null)) { RectTransform val = (RectTransform)((Component)menu.button5).transform; bool flag = (Object)(object)root == (Object)null; if (flag) { Create(menu.button2, parent); } Vector3 lossyScale = ((Component)menu.button2).transform.lossyScale; Vector3 lossyScale2 = ((Transform)parent).lossyScale; ((Transform)rect).localScale = new Vector3(lossyScale.x / lossyScale2.x * 0.86f, lossyScale.y / lossyScale2.y * 0.86f, 1f); Rect val2 = val.rect; Vector2 val3 = Vector2.op_Implicit(((Transform)parent).InverseTransformPoint(((Transform)val).TransformPoint(Vector2.op_Implicit(((Rect)(ref val2)).center)))); Rect val4 = val.rect; Vector2 center = ((Rect)(ref val4)).center; Vector2 up = Vector2.up; Rect val5 = val.rect; float mechHeight = Math.Abs(Vector2.op_Implicit(((Transform)parent).InverseTransformPoint(((Transform)val).TransformPoint(Vector2.op_Implicit(center + up * ((Rect)(ref val5)).height * 0.5f)))).y - val3.y) * 2f; Vector2 center2 = val3; Rect val6 = rect.rect; Vector2 val7 = Position(center2, mechHeight, ((Rect)(ref val6)).height * ((Transform)rect).localScale.y, 6f); ((Transform)rect).position = ((Transform)parent).TransformPoint(Vector2.op_Implicit(val7)); root.SetActive(((Component)menu.button5).gameObject.activeInHierarchy); if (flag) { Action<string> action = report; object[] array = new object[9] { "Created Star System Production button above Production: active=", root.activeInHierarchy, ", position=", ((Transform)rect).position, ", size=", null, null, null, null }; Rect val8 = rect.rect; array[5] = ((Rect)(ref val8)).size; array[6] = ", parent="; array[7] = ((Object)parent).name; array[8] = ", gap=6 UI units."; action(string.Concat(array)); } } } private void Create(Button template, RectTransform parent) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Expected O, but got Unknown //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Expected O, but got Unknown //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) root = Object.Instantiate<GameObject>(((Component)template).gameObject, (Transform)(object)parent, false); ((Object)root).name = "Star System Production Icarus-menu button"; rect = root.GetComponent<RectTransform>(); rect.pivot = new Vector2(0.5f, 0.5f); root.transform.SetAsLastSibling(); Button component = root.GetComponent<Button>(); ((Behaviour)component).enabled = true; ((Selectable)component).interactable = true; component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener(new UnityAction(Click)); GameObject val = new GameObject("Opaque button face", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(root.transform, false); val.transform.SetAsFirstSibling(); fillTexture = new Texture2D(64, 64, (TextureFormat)4, false); Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { double num = ((double)j + 0.5) / 32.0 - 1.0; double num2 = ((double)i + 0.5) / 32.0 - 1.0; ref Color32 reference = ref array[i * 64 + j]; reference = new Color32((byte)8, (byte)20, (byte)28, (byte)((num * num + num2 * num2 <= 1.0) ? 230u : 0u)); } } fillTexture.SetPixels32(array); fillTexture.Apply(false, true); fillSprite = Sprite.Create(fillTexture, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f); Image component2 = val.GetComponent<Image>(); component2.sprite = fillSprite; ((Graphic)component2).color = Color.white; ((Graphic)component2).raycastTarget = true; RectTransform rectTransform = ((Graphic)component2).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = new Vector2(2f, 2f); rectTransform.offsetMax = new Vector2(-2f, -2f); Graphic[] componentsInChildren = root.GetComponentsInChildren<Graphic>(true); foreach (Graphic val2 in componentsInChildren) { if (((Object)val2).name != "Opaque button face") { Color color = val2.color; color.a *= 0.65f; val2.color = color; } if ((Object)(object)((Component)val2).transform != (Object)(object)root.transform && ((Object)val2).name.IndexOf("icon", StringComparison.OrdinalIgnoreCase) >= 0) { ((Behaviour)val2).enabled = false; } } UIButton val3 = root.GetComponent<UIButton>() ?? root.AddComponent<UIButton>(); TipSettings tips = val3.tips; ((Behaviour)val3).enabled = true; val3.button = component; val3.eventReceiver = null; val3.onClick += NativeClick; val3.tips = new TipSettings { tipTitle = "Star System Production", tipText = "Browse planetary products, recipes and machines.\nClick to open or close.", width = 280, delay = 0.35f, corner = 7, offset = new Vector2(0f, 8f), topLevel = tips.topLevel, level = tips.level, simpleGeneralTipPrefab = tips.simpleGeneralTipPrefab, type = (ItemTipType)(-1) }; val3.tipTitleFormatString = val3.tips.tipTitle; val3.tipTextFormatString = val3.tips.tipText; GameObject val4 = new GameObject("Gear and output icon", new Type[2] { typeof(RectTransform), typeof(Image) }); val4.transform.SetParent(root.transform, false); Image component3 = val4.GetComponent<Image>(); texture = MakeTexture(); sprite = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f), 100f); component3.sprite = sprite; component3.preserveAspect = true; ((Graphic)component3).color = Color.white; ((Graphic)component3).raycastTarget = true; RectTransform rectTransform2 = ((Graphic)component3).rectTransform; Vector2 val5 = (rectTransform2.pivot = new Vector2(0.5f, 0.5f)); Vector2 anchorMin = (rectTransform2.anchorMax = val5); rectTransform2.anchorMin = anchorMin; Rect val8 = rect.rect; float width = ((Rect)(ref val8)).width; Rect val9 = rect.rect; float num3 = Mathf.Min(width, ((Rect)(ref val9)).height) * 0.72f; rectTransform2.sizeDelta = new Vector2(num3, num3); GameObject val10 = new GameObject("Explorer launcher hit surface", new Type[2] { typeof(RectTransform), typeof(Image) }); val10.transform.SetParent(root.transform, false); Image component4 = val10.GetComponent<Image>(); ((Graphic)component4).color = Color.clear; ((Graphic)component4).raycastTarget = true; RectTransform rectTransform3 = ((Graphic)component4).rectTransform; rectTransform3.anchorMin = Vector2.zero; rectTransform3.anchorMax = Vector2.one; Vector2 offsetMin = (rectTransform3.offsetMax = Vector2.zero); rectTransform3.offsetMin = offsetMin; root.SetActive(true); } internal static bool Ink(double x, double y) { double num = Math.Sqrt(x * x + y * y); double num2 = Math.Atan2(y, x); double num3 = ((Math.Cos(num2 * 10.0) > 0.15) ? 0.87 : 0.72); if (num >= 0.49 && num <= num3) { return true; } if (y < -0.28) { return false; } if ((!(x >= -0.3) || !(x <= -0.17) || !(y <= -0.02)) && (!(x >= -0.065) || !(x <= 0.065) || !(y <= 0.17))) { if (x >= 0.17 && x <= 0.3) { return y <= 0.36; } return false; } return true; } private static Texture2D MakeTexture() { //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[16384]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { int num = 0; for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { if (Ink(((double)j + ((double)l + 0.5) / 4.0) / 128.0 * 2.0 - 1.0, ((double)i + ((double)k + 0.5) / 4.0) / 128.0 * 2.0 - 1.0)) { num++; } } } ref Color32 reference = ref array[i * 128 + j]; reference = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num * 255 / 16)); } } Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false); ((Object)val).name = "Explorer star orbit glyph"; ((Texture)val).filterMode = (FilterMode)1; ((Texture)val).wrapMode = (TextureWrapMode)1; val.SetPixels32(array); val.Apply(false, true); return val; } private void NativeClick(int data) { Click(); } private void Click() { if (lastClickFrame != Time.frameCount) { lastClickFrame = Time.frameCount; toggle(); } } internal void Dispose() { if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)root); } if ((Object)(object)sprite != (Object)null) { Object.Destroy((Object)(object)sprite); } if ((Object)(object)texture != (Object)null) { Object.Destroy((Object)(object)texture); } if ((Object)(object)fillSprite != (Object)null) { Object.Destroy((Object)(object)fillSprite); } if ((Object)(object)fillTexture != (Object)null) { Object.Destroy((Object)(object)fillTexture); } fillSprite = null; fillTexture = null; root = null; rect = null; sprite = null; texture = null; owner = null; } } internal sealed class NativeStyle { internal int fontSize = 16; internal TextAnchor alignment = (TextAnchor)3; internal Color color = Color.white; } internal sealed class NativePanel : IDisposable { private sealed class Node { internal GameObject Object; internal string Key; internal RectTransform Rect; internal Text Text; internal RawImage Raw; internal Image Image; internal Button Button; internal InputField Input; internal ScrollRect Scroll; internal UIComboBox Combo; internal int Choice = -1; internal Color SurfaceColor; internal Color FocusColor; internal bool Clicked; } private sealed class Scope { internal string Key; internal RectTransform Parent; internal int Index; internal int Order; } private readonly Dictionary<string, Node> nodes = new Dictionary<string, Node>(); private readonly HashSet<string> used = new HashSet<string>(); private readonly Stack<Scope> scopes = new Stack<Scope>(); private GameObject root; private RectTransform panel; private Canvas canvas; private Font font; private string hover = ""; internal bool Dragging; internal bool Editing { get { foreach (Node value in nodes.Values) { if ((Object)(object)value.Input != (Object)null && value.Object.activeInHierarchy && value.Input.isFocused) { return true; } } return false; } } internal string Tooltip => hover; internal void Active(bool value) { if ((Object)(object)root != (Object)null) { root.SetActive(value); } if (!value) { hover = ""; } } internal void Begin(Rect bounds, float scale, Action<Vector2> move) { //IL_0177: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { root = new GameObject("Star System Production native window", new Type[3] { typeof(RectTransform), typeof(Canvas), typeof(GraphicRaycaster) }); Object.DontDestroyOnLoad((Object)(object)root); canvas = root.GetComponent<Canvas>(); canvas.renderMode = (RenderMode)0; canvas.sortingOrder = 32761; canvas.pixelPerfect = true; GameObject val = new GameObject("Window", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(root.transform, false); panel = val.GetComponent<RectTransform>(); ((Graphic)val.GetComponent<Image>()).color = Color.clear; UIControlPanelWindow controlPanelWindow = UIRoot.instance.uiGame.controlPanelWindow; font = (((Object)(object)controlPanelWindow.FONT_SAIRASB != (Object)null) ? controlPanelWindow.FONT_SAIRASB : controlPanelWindow.leftEmptyTip.font); } root.SetActive(true); canvas.scaleFactor = scale; Place(panel, bounds); used.Clear(); scopes.Clear(); scopes.Push(new Scope { Key = "window", Parent = panel }); Node node = Get("drag", new Rect(0f, 0f, ((Rect)(ref bounds)).width - 190f, 54f)); if ((Object)(object)node.Image == (Object)null) { node.Image = node.Object.AddComponent<Image>(); ((Graphic)node.Image).color = Color.clear; } ProductionDrag productionDrag = node.Object.GetComponent<ProductionDrag>() ?? node.Object.AddComponent<ProductionDrag>(); productionDrag.Move = delegate(Vector2 delta) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) move(delta / scale); }; productionDrag.State = delegate(bool value) { Dragging = value; }; } internal void End() { foreach (KeyValuePair<string, Node> node in nodes) { if (!used.Contains(node.Key)) { node.Value.Object.SetActive(false); } } foreach (KeyValuePair<string, Node> node2 in nodes) { if (used.Contains(node2.Key) && (Object)(object)node2.Value.Combo != (Object)null && node2.Value.Combo.isDroppedDown) { node2.Value.Object.transform.SetAsLastSibling(); } } } private static void Place(RectTransform rt, Rect r) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); if (rt.anchorMin != val) { rt.anchorMin = val; } if (rt.anchorMax != val) { rt.anchorMax = val; } if (rt.pivot != val) { rt.pivot = val; } Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(((Rect)(ref r)).x, 0f - ((Rect)(ref r)).y); if (rt.anchoredPosition != val2) { rt.anchoredPosition = val2; } if (rt.sizeDelta != ((Rect)(ref r)).size) { rt.sizeDelta = ((Rect)(ref r)).size; } } private Node Get(string kind, Rect rect, string identity = null) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) Scope scope = scopes.Peek(); string text = scope.Key + "/" + (identity ?? scope.Index.ToString()) + "-" + kind; scope.Index++; if (!nodes.TryGetValue(text, out var value)) { GameObject val = new GameObject(kind, new Type[1] { typeof(RectTransform) }); val.transform.SetParent((Transform)(object)scope.Parent, false); Node node = new Node(); node.Object = val; node.Key = text; node.Rect = val.GetComponent<RectTransform>(); value = node; nodes.Add(text, value); } used.Add(text); if (!value.Object.activeSelf) { value.Object.SetActive(true); } Place(value.Rect, rect); if (((Transform)value.Rect).GetSiblingIndex() != scope.Order) { ((Transform)value.Rect).SetSiblingIndex(scope.Order); } scope.Order++; return value; } internal void BeginGroup(string identity, Rect rect) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Node node = Get("group", rect, identity); scopes.Push(new Scope { Key = node.Key, Parent = node.Rect }); } internal void EndGroup() { scopes.Pop(); } private Text TextFor(Node node) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)node.Text == (Object)null) { GameObject val = new GameObject("Text", new Type[2] { typeof(RectTransform), typeof(Text) }); val.transform.SetParent(node.Object.transform, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = new Vector2(5f, 0f); component.offsetMax = new Vector2(-5f, 0f); node.Text = val.GetComponent<Text>(); node.Text.font = font; ((Graphic)node.Text).raycastTarget = false; node.Text.horizontalOverflow = (HorizontalWrapMode)0; node.Text.verticalOverflow = (VerticalWrapMode)1; node.Text.supportRichText = false; } return node.Text; } private void SetText(Node node, string value, NativeStyle style) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Text val = TextFor(node); if (val.text != value) { val.text = value; } val.fontSize = style.fontSize; val.alignment = style.alignment; ((Graphic)val).color = style.color; } private void Tip(Node node, string tooltip) { ProductionHover productionHover = node.Object.GetComponent<ProductionHover>(); if ((Object)(object)productionHover == (Object)null) { productionHover = node.Object.AddComponent<ProductionHover>(); } productionHover.Value = tooltip ?? ""; productionHover.Changed = delegate(string value) { hover = value; }; } internal void Label(Rect rect, string value, NativeStyle style) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown Label(rect, new GUIContent(value), style); } internal void Label(Rect rect, GUIContent content, NativeStyle style) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Node node = Get("label", rect); SetText(node, content.text, style); if ((Object)(object)node.Image == (Object)null) { node.Image = node.Object.AddComponent<Image>(); ((Graphic)node.Image).color = Color.clear; } ((Graphic)node.Image).raycastTarget = !string.IsNullOrEmpty(content.tooltip); Tip(node, content.tooltip); } internal bool Button(Rect rect, string value, NativeStyle style) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown return Button(rect, new GUIContent(value), style); } internal bool Button(Rect rect, GUIContent content, NativeStyle style) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown UnityAction val = null; Node node = Get("button", rect); if ((Object)(object)node.Button == (Object)null) { node.Image = node.Object.AddComponent<Image>(); ((Graphic)node.Image).color = new Color(0.28f, 0.44f, 0.5f, 1f); node.Button = node.Object.AddComponent<Button>(); ((Selectable)node.Button).targetGraphic = (Graphic)(object)node.Image; ColorBlock colors = ((Selectable)node.Button).colors; ((ColorBlock)(ref colors)).highlightedColor = new Color(0.65f, 0.94f, 1f, 1f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.35f, 0.65f, 0.72f, 1f); ((Selectable)node.Button).colors = colors; ButtonClickedEvent onClick = node.Button.onClick; if (val == null) { val = (UnityAction)delegate { node.Clicked = true; }; } ((UnityEvent)onClick).AddListener(val); } SetText(node, content.text, style); Tip(node, content.tooltip); bool clicked = node.Clicked; node.Clicked = false; return clicked; } internal string TextField(Rect rect, string value, NativeStyle style) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) Node node = Get("search", rect); if ((Object)(object)node.Input == (Object)null) { node.Image = node.Object.AddComponent<Image>(); ((Graphic)node.Image).color = new Color(0.13f, 0.2f, 0.25f, 1f); Text textComponent = TextFor(node); node.Input = node.Object.AddComponent<InputField>(); node.Input.textComponent = textComponent; ((Selectable)node.Input).targetGraphic = (Graphic)(object)node.Image; node.Input.lineType = (LineType)0; node.Input.text = value; } node.Text.fontSize = style.fontSize; ((Graphic)node.Text).color = Color.white; node.Text.alignment = (TextAnchor)3; return node.Input.text; } internal int Dropdown(Rect rect, string[] options, int selected) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown UnityAction val = null; Node node = Get("dropdown", rect); if ((Object)(object)node.Combo == (Object)null) { node.Combo = CreateDropdown(node.Rect, options, selected); ChangeEvent onItemIndexChange = node.Combo.onItemIndexChange; if (val == null) { val = (UnityAction)delegate { node.Choice = node.Combo.itemIndex; }; } ((UnityEvent)onItemIndexChange).AddListener(val); ((Component)node.Combo).gameObject.SetActive(true); } int choice = node.Choice; node.Choice = -1; if (choice < 0 || choice >= options.Length) { return selected; } return choice; } internal void DrawTexture(Rect rect, Texture texture) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) DrawTextureWithTexCoords(rect, texture, new Rect(0f, 0f, 1f, 1f), alpha: true); } internal void PaneBackground(Rect rect) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Node node = Get("pane-background", rect); if ((Object)(object)node.Image == (Object)null) { node.Image = node.Object.AddComponent<Image>(); ((Graphic)node.Image).color = new Color(0.035f, 0.065f, 0.08f, 0.48f); ((Graphic)node.Image).raycastTarget = false; } } internal void PaneDivider(Rect rect) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Node node = Get("pane-divider", rect); if ((Object)(object)node.Image == (Object)null) { node.Image = node.Object.AddComponent<Image>(); ((Graphic)node.Image).color = new Color(0.52f, 0.72f, 0.76f, 0.35f); ((Graphic)node.Image).raycastTarget = false; } } private static RectTransform Child(Transform parent, string name) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; Vector2 offsetMin = (component.offsetMax = Vector2.zero); component.offsetMin = offsetMin; return component; } private Text Caption(Transform parent, string name) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Child(parent, name); val.offsetMin = new Vector2(7f, 0f); val.offsetMax = new Vector2(-22f, 0f); Text val2 = ((Component)val).gameObject.AddComponent<Text>(); val2.font = font; val2.fontSize = UIRoot.instance.uiGame.controlPanelWindow.filterPanel.sortFilterLabel.fontSize; ((Graphic)val2).color = Color.white; val2.alignment = (TextAnchor)3; val2.horizontalOverflow = (HorizontalWrapMode)0; val2.verticalOverflow = (VerticalWrapMode)0; ((Graphic)val2).raycastTarget = false; val2.supportRichText = false; return val2; } private static Image Skin(RectTransform target, Image source, Color fallback) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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) Image val = ((Component)target).gameObject.AddComponent<Image>(); if ((Object)(object)source != (Object)null) { val.sprite = source.sprite; val.type = source.type; ((Graphic)val).material = ((Graphic)source).material; ((Graphic)val).color = ((Graphic)source).color; } else { ((Graphic)val).color = fallback; } return val; } private UIComboBox CreateDropdown(RectTransform parent, string[] options, int selected) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05ae: Unknown result type (might be due to invalid IL or missing references) //IL_05d8: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_0664: Unknown result type (might be due to invalid IL or missing references) //IL_066e: Expected O, but got Unknown //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0679: Expected O, but got Unknown UIComboBox sortFilterBox = UIRoot.instance.uiGame.controlPanelWindow.filterPanel.sortFilterBox; RectTransform val = Child((Transform)(object)parent, "Production selector"); ((Component)val).gameObject.SetActive(false); UIComboBox val2 = ((Component)val).gameObject.AddComponent<UIComboBox>(); Image component = ((Component)sortFilterBox).GetComponent<Image>(); Image targetGraphic = Skin(val, component, new Color(0.17f, 0.24f, 0.28f, 0.9f)); Button val3 = ((Component)val).gameObject.AddComponent<Button>(); ((Selectable)val3).targetGraphic = (Graphic)(object)targetGraphic; ((UnityEvent)val3.onClick).AddListener(new UnityAction(val2.OnPopButtonClick)); val2.m_Text = Caption((Transform)(object)val, "Selected value"); RectTransform val4 = Child((Transform)(object)val, "Internal value"); val2.m_Input = ((Component)val4).gameObject.AddComponent<InputField>(); val2.m_Input.textComponent = Caption((Transform)(object)val4, "Value text"); val2.m_Input.lineType = (LineType)0; RectTransform val5 = Child((Transform)(object)val, "Arrow"); Vector2 anchorMin = (val5.anchorMax = new Vector2(1f, 0.5f)); val5.anchorMin = anchorMin; val5.pivot = new Vector2(1f, 0.5f); val5.anchoredPosition = new Vector2(-7f, 0f); val5.sizeDelta = new Vector2(12f, 14f); Image val7 = null; Image[] componentsInChildren = ((Component)sortFilterBox).GetComponentsInChildren<Image>(true); foreach (Image val8 in componentsInChildren) { string text = ((Object)val8).name.ToLowerInvariant(); if (!((Component)val8).transform.IsChildOf((Transform)(object)sortFilterBox.m_DropDownList) && (text.Contains("arrow") || text.Contains("triangle"))) { val7 = val8; break; } } if ((Object)(object)val7 != (Object)null) { Image val9 = Skin(val5, val7, Color.white); ((Graphic)val9).raycastTarget = false; } else { Text val10 = ((Component)val5).gameObject.AddComponent<Text>(); val10.font = font; val10.fontSize = 12; val10.text = "▾"; val10.alignment = (TextAnchor)4; ((Graphic)val10).raycastTarget = false; } RectTransform val11 = Child((Transform)(object)val, "Options"); val11.anchorMin = new Vector2(0f, 0f); val11.anchorMax = new Vector2(1f, 0f); val11.pivot = new Vector2(0f, 1f); val11.anchoredPosition = new Vector2(0f, -2f); val11.sizeDelta = new Vector2(0f, 160f); Skin(val11, ((Component)sortFilterBox.m_DropDownList).GetComponent<Image>(), new Color(0.12f, 0.19f, 0.23f, 1f)); ScrollRect val12 = ((Component)val11).gameObject.AddComponent<ScrollRect>(); val12.horizontal = false; val12.movementType = (MovementType)2; val12.inertia = false; val12.scrollSensitivity = 24f; RectTransform val13 = Child((Transform)(object)val11, "Viewport"); val13.offsetMax = new Vector2(-10f, 0f); ((Component)val13).gameObject.AddComponent<Image>(); ((Component)val13).gameObject.AddComponent<Mask>().showMaskGraphic = false; RectTransform val14 = Child((Transform)(object)val13, "Items"); val14.anchorMin = new Vector2(0f, 1f); val14.anchorMax = Vector2.one; val14.pivot = new Vector2(0f, 1f); val14.sizeDelta = new Vector2(0f, 160f); val12.viewport = val13; val12.content = val14; val2.m_DropDownList = val11; val2.m_DropDownContent = val14; RectTransform val15 = Child((Transform)(object)val14, "Selection"); val15.anchorMin = new Vector2(0f, 1f); val15.anchorMax = Vector2.one; val15.pivot = new Vector2(0f, 1f); val15.sizeDelta = new Vector2(0f, 24f); val2.m_SelectionBG = Skin(val15, sortFilterBox.m_SelectionBG, new Color(0.3f, 0.55f, 0.62f, 0.6f)); ((Graphic)val2.m_SelectionBG).raycastTarget = false; val2.m_EmptyItemRes = Caption((Transform)(object)val14, "No items"); val2.m_EmptyItemRes.text = "No items"; RectTransform val16 = Child((Transform)(object)val14, "Item template"); val16.anchorMin = new Vector2(0f, 1f); val16.anchorMax = Vector2.one; val16.pivot = new Vector2(0f, 1f); val16.sizeDelta = new Vector2(0f, 24f); Image targetGraphic2 = Skin(val16, ((Component)sortFilterBox.m_ListItemRes).GetComponent<Image>(), new Color(0.2f, 0.32f, 0.38f, 0.85f)); Button val17 = ((Component)val16).gameObject.AddComponent<Button>(); ((Selectable)val17).targetGraphic = (Graphic)(object)targetGraphic2; Caption((Transform)(object)val16, "Item caption"); ((Component)val16).gameObject.AddComponent<UIData>(); ((Component)val16).gameObject.AddComponent<ProductionChoice>().Combo = val2; ((Component)val16).gameObject.SetActive(false); val2.m_ListItemRes = val17; RectTransform val18 = Child((Transform)(object)val11, "Scrollbar"); val18.anchorMin = new Vector2(1f, 0f); val18.anchorMax = Vector2.one; val18.pivot = new Vector2(1f, 0.5f); val18.sizeDelta = new Vector2(8f, 0f); ((Graphic)((Component)val18).gameObject.AddComponent<Image>()).color = new Color(0.12f, 0.21f, 0.25f, 1f); RectTransform val19 = Child((Transform)(object)val18, "Handle"); Image val20 = ((Component)val19).gameObject.AddComponent<Image>(); ((Graphic)val20).color = new Color(0.44f, 0.76f, 0.83f, 1f); val2.m_Scrollbar = ((Component)val18).gameObject.AddComponent<Scrollbar>(); val2.m_Scrollbar.handleRect = val19; ((Selectable)val2.m_Scrollbar).targetGraphic = (Graphic)(object)val20; val2.m_Scrollbar.direction = (Direction)2; val12.verticalScrollbar = val2.m_Scrollbar; val2.onItemIndexChange = new ChangeEvent(); val2.onSubmit = new SubmitEvent(); val2.Items = new List<string>(options); val2.ItemsData = new List<int>(); val2.translated = true; val2.InitItemIndexSelf = false; val2.CanInput = false; val2.DoubleClickChange = false; val2.parentSibling = true; val2.autoWidth = false; val2.mouseWheelScroll = false; val2.ItemHeight = 24; val2.ItemPadding = 3; val2.DropDownCount = Math.Min(8, options.Length); val2.isDroppedDown = false; val2.itemIndex = selected; return val2; } internal void DrawTexture(Rect rect, Texture texture, ScaleMode mode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) DrawTexture(rect, texture); } internal void Surface(Rect rect, string kind, bool selected) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: 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) //IL_015f: Unknown result type (might be due to invalid IL or missing references) Node node = Get("surface-" + kind, rect); if ((Object)(object)node.Image == (Object)null) { node.Image = node.Object.AddComponent<Image>(); ((Graphic)node.Image).raycastTarget = false; UIControlPanelWindow controlPanelWindow = UIRoot.instance.uiGame.controlPanelWindow; Image val = null; if (kind == "frame") { Transform transform = ((Component)controlPanelWindow).transform; CopyBackdrop((RectTransform)(object)((transform is RectTransform) ? transform : null), node.Rect); ((Graphic)node.Image).color = Color.clear; return; } if (kind == "row" && controlPanelWindow.objectEntryPrefabs != null) { UIControlPanelObjectEntry[] objectEntryPrefabs = controlPanelWindow.objectEntryPrefabs; foreach (UIControlPanelObjectEntry val2 in objectEntryPrefabs) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2.selectButton != (Object)null) { val = ((Component)val2.selectButton).GetComponent<Image>(); if ((Object)(object)val != (Object)null) { break; } } } } if ((Object)(object)val == (Object)null && kind != "row") { float num = 0f; Transform val3 = ((kind == "header" && (Object)(object)controlPanelWindow.filterPanel != (Object)null) ? ((Component)controlPanelWindow.filterPanel).transform : ((Component)controlPanelWindow).transform); Image[] componentsInChildren = ((Component)val3).GetComponentsInChildren<Image>(true); foreach (Image val4 in componentsInChildren) { Rect rect2 = ((Graphic)val4).rectTransform.rect; float num2 = ((Rect)(ref rect2)).width * ((Rect)(ref rect2)).height; if (num2 > num) { val = val4; num = num2; } } } if ((Object)(object)val != (Object)null) { node.Image.sprite = val.sprite; node.Image.type = val.type; ((Graphic)node.Image).material = ((Graphic)val).material; ((Graphic)node.Image).color = ((Graphic)val).color; } else { ((Graphic)node.Image).color = ((kind == "row") ? new Color(0.29f, 0.43f, 0.49f, 1f) : new Color(0.2f, 0.27f, 0.31f, 1f)); } node.SurfaceColor = ((Graphic)node.Image).color; node.FocusColor = controlPanelWindow.focusColor; } if (kind == "row") { ((Graphic)node.Image).color = (selected ? node.FocusColor : node.SurfaceColor); } } private static void CopyBackdrop(RectTransform source, RectTransform target) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Expected O, but got Unknown //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0303: 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_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0340: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: 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_01de: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) int num = 0; Vector3[] array = (Vector3[])(object)new Vector3[4]; Rect rect = source.rect; Graphic[] componentsInChildren = ((Component)source).GetComponentsInChildren<Graphic>(true); foreach (Graphic val in componentsInChildren) { if (!((Behaviour)val).enabled || (!(val is Image) && !(val is RawImage))) { continue; } RectTransform rectTransform = val.rectTransform; rectTransform.GetWorldCorners(array); Vector3 val2 = ((Transform)source).InverseTransformPoint(array[0]); Vector3 val3 = ((Transform)source).InverseTransformPoint(array[2]); if (Math.Abs(val3.x - val2.x) < ((Rect)(ref rect)).width * 0.9f || Math.Abs(val3.y - val2.y) < ((Rect)(ref rect)).height * 0.8f) { continue; } bool flag = false; Transform val4 = (Transform)(object)rectTransform; while ((Object)(object)val4 != (Object)null) { if ((Object)(object)val4 != (Object)(object)source && !((Component)val4).gameObject.activeSelf) { flag = true; break; } if ((Object)(object)val4 == (Object)(object)source) { break; } val4 = val4.parent; } if (!flag) { GameObject val5 = new GameObject("Native backing: " + ((Object)val).name, new Type[1] { typeof(RectTransform) }); val5.transform.SetParent((Transform)(object)target, false); RectTransform component = val5.GetComponent<RectTransform>(); component.anchorMin = new Vector2((val2.x - ((Rect)(ref rect)).xMin) / ((Rect)(ref rect)).width, (val2.y - ((Rect)(ref rect)).yMin) / ((Rect)(ref rect)).height); component.anchorMax = new Vector2((val3.x - ((Rect)(ref rect)).xMin) / ((Rect)(ref rect)).width, (val3.y - ((Rect)(ref rect)).yMin) / ((Rect)(ref rect)).height); Vector2 offsetMin = (component.offsetMax = Vector2.zero); component.offsetMin = offsetMin; Image val6 = (Image)(object)((val is Image) ? val : null); Graphic val8; if ((Object)(object)val6 != (Object)null) { Image val7 = val5.AddComponent<Image>(); val7.sprite = val6.sprite; val7.type = val6.type; val7.fillCenter = val6.fillCenter; val7.pixelsPerUnitMultiplier = val6.pixelsPerUnitMultiplier; val8 = (Graphic)(object)val7; } else { RawImage val9 = (RawImage)val; RawImage val10 = val5.AddComponent<RawImage>(); val10.texture = val9.texture; val10.uvRect = val9.uvRect; val8 = (Graphic)(object)val10; } val8.material = val.material; val8.color = val.color; val8.raycastTarget = false; num++; } } if (num == 0) { GameObject val11 = new GameObject("Fallback backing", new Type[2] { typeof(RectTransform), typeof(Image) }); val11.transform.SetParent((Transform)(object)target, false); RectTransform component2 = val11.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; Vector2 offsetMin2 = (component2.offsetMax = Vector2.zero); component2.offsetMin = offsetMin2; ((Graphic)val11.GetComponent<Image>()).color = new Color(0.24f, 0.33f, 0.38f, 0.94f); ((Graphic)val11.GetComponent<Image>()).raycastTarget = false; } } internal void DrawTextureWithTexCoords(Rect rect, Texture texture, Rect uv, bool alpha) { //IL_0006: 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) Node node = Get("image", rect); if ((Object)(object)node.Raw == (Object)null) { node.Raw = node.Object.AddComponent<RawImage>(); ((Graphic)node.Raw).raycastTarget = false; } node.Raw.texture = texture; node.Raw.uvRect = uv; } internal Vector2 BeginScrollView(string identity, Rect rect, Vector2 position, Rect content) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Expected O, but got Unknown //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) Node node = Get("scroll", rect, identity); if ((Object)(object)node.Scroll == (Object)null) { node.Image = node.Object.AddComponent<Image>(); ((Graphic)node.Image).color = Color.clear; GameObject val = new GameObject("Viewport", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }); val.transform.SetParent(node.Object.transform, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = new Vector2(-14f, 0f); GameObject val2 = new GameObject("Content", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(val.transform, false); node.Scroll = node.Object.AddComponent<ScrollRect>(); node.Scroll.viewport = component; node.Scroll.content = val2.GetComponent<RectTransform>(); node.Scroll.horizontal = false; node.Scroll.movementType = (MovementType)2; node.Scroll.inertia = false; node.Scroll.scrollSensitivity = 30f; GameObject val3 = new GameObject("Scrollbar", new Type[3] { typeof(RectTransform), typeof(Image), typeof(Scrollbar) }); val3.transform.SetParent(node.Object.transform, false); RectTransform component2 = val3.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(1f, 0f); component2.anchorMax = new Vector2(1f, 1f); component2.pivot = new Vector2(1f, 0.5f); component2.sizeDelta = new Vector2(10f, 0f); component2.anchoredPosition = Vector2.zero; ((Graphic)val3.GetComponent<Image>()).color = new Color(0.12f, 0.21f, 0.25f, 1f); GameObject val4 = new GameObject("Handle", new Type[2] { typeof(RectTransform), typeof(Image) }); val4.transform.SetParent(val3.transform, false); RectTransform component3 = val4.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; Vector2 offsetMin = (component3.offsetMax = Vector2.zero); component3.offsetMin = offsetMin; ((Graphic)val4.GetComponent<Image>()).color = new Color(0.44f, 0.76f, 0.83f, 1f); Scrollbar component4 = val3.GetComponent<Scrollbar>(); component4.handleRect = component3; ((Selectable)component4).targetGraphic = (Graphic)(object)val4.GetComponent<Image>(); component4.direction = (Direction)2; node.Scroll.verticalScrollbar = component4; RectTransform content2 = node.Scroll.content; Vector2 val5 = (content2.pivot = new Vector2(0f, 1f)); Vector2 anchorMin = (content2.anchorMax = val5); content2.anchorMin = anchorMin; content2.sizeDelta = new Vector2(((Rect)(ref content)).width, Math.Max(((Rect)(ref rect)).height, ((Rect)(ref content)).height)); content2.anchoredPosition = new Vector2(0f, position.y); } RectTransform content3 = node.Scroll.content; Vector2 val8 = default(Vector2); ((Vector2)(ref val8))..ctor(((Rect)(ref content)).width, Math.Max(((Rect)(ref rect)).height, ((Rect)(ref content)).height)); if (content3.sizeDelta != val8) { content3.sizeDelta = val8; } scopes.Push(new Scope { Key = node.Key + "/content", Parent = content3 }); return new Vector2(0f, Math.Max(0f, content3.anchoredPosition.y)); } internal void EndScrollView() { scopes.Pop(); } internal void ResetScroll(string identity) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) foreach (Node value in nodes.Values) { if ((Object)(object)value.Scroll != (Object)null && value.Key.EndsWith("/" + identity + "-scroll", StringComparison.Ordinal)) { value.Scroll.content.anchoredPosition = Vector2.zero; } } } internal void Box(Rect rect, string text, NativeStyle style) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Node node = Get("tooltip", rect); if ((Object)(object)node.Image == (Object)null) { node.Image = node.Object.AddComponent<Image>(); ((Graphic)node.Image).color = new Color(0.06f, 0.12f, 0.16f, 1f); } SetText(node, text, style); node.Object.transform.SetAsLastSibling(); } public void Dispose() { if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)root); } root = null; nodes.Clear(); } } public sealed class ProductionHover : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IEventSystemHandler { internal string Value; internal Action<string> Changed; public void OnPointerEnter(PointerEventData e) { if (Changed != null) { Changed(Value); } } public void OnPointerExit(PointerEventData e) { if (Changed != null) { Changed(""); } } private void OnDisable() { if (Changed != null) { Changed(""); } } } public sealed class ProductionChoice : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { [SerializeField] internal UIComboBox Combo; public void OnPointerClick(PointerEventData e) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Combo != (Object)null && (int)e.button == 0) { Combo.OnSelect(((Component)this).GetComponent<UIData>()); Combo.isDroppedDown = false; } } } public sealed class ProductionDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IEventSystemHandler { internal Action<Vector2> Move; internal Action<bool> State; public void OnBeginDrag(PointerEventData e) { if (State != null) { State(obj: true); } } public void OnDrag(PointerEventData e) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (Move != null) { Move(new Vector2(e.delta.x, 0f - e.delta.y)); } } public void OnEndDrag(PointerEventData e) { if (State != null) { State(obj: false); } } private void OnDisable() { if (State != null) { State(obj: false); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("LokiMoonLabs.StarSystemProduction", "Star System Production", "0.2.0")] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(VFInput), "UpdateGameStates")] private static class InputGuard { [HarmonyPriority(0)] [HarmonyPostfix] private static void Postfix() { if (!((Object)(object)instance == (Object)null) && instance.Window != null && (instance.Window.Blocking || (instance.launcher != null && instance.launcher.Blocking))) { VFInput.onGUI = true; VFInput.onGUIOperate = true; VFInput.inScrollView = true; if (instance.Window.KeyboardBlocking) { VFInput.inputing = true; } } } } private static Plugin instance; private Harmony harmony; private Launcher launcher; internal ProductionModel Model; internal ProductionWindow Window; internal string Status = "Select a producing planet."; private bool failed; private void Awake() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown instance = this; DisplayNames.Bind(); Model = new ProductionModel(); Window = new ProductionWindow(this); launcher = new Launcher(Toggle, Report); harmony = new Harmony("LokiMoonLabs.StarSystemProduction"); harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Star System Production 0.2.0 ready. Localized names; persistent production planets; native statistics."); } private void Report(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } private void Toggle() { Window.Toggle(); if (Window.Visible) { Model.Refresh(); } } private void Update() { try { if ((Object)(object)GameMain.instance == (Object)null || GameMain.instance.isMenuDemo || GameMain.data == null) { Window.Close(); Model.Reset(); launcher.Dispose(); return; } UIRoot val = UIRoot.instance; UIGame val2 = (((Object)(object)val == (Object)null) ? null : val.uiGame); launcher.Update(((Object)(object)val2 == (Object)null) ? null : val2.gameMenu, ((Object)(object)val2 == (Object)null) ? null : val2.lowGroup); if (Window.Visible && Input.GetKeyDown((KeyCode)27)) { Window.Close(); } Window.UpdateShield(); if (Window.Visible) { Model.Tick(GameMain.data); } Window.Draw(); } catch (Exception ex) { if (!failed) { failed = true; ((BaseUnityPlugin)this).Logger.LogError((object)("Production browser update failed: " + ex)); Status = "Browser error; see BepInEx log."; } } } internal void Locate(PlanetData planet) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (planet == null || (Object)(object)UIRoot.instance == (Object)null || (Object)(object)UIRoot.instance.uiGame == (Object)null) { return; } try { Window.Close(); UIGame uiGame = UIRoot.instance.uiGame; UIStarmap starmap = uiGame.starmap; if (!((ManualBehaviour)starmap).active) { uiGame.On_V_Switch(); } if (!((ManualBehaviour)starmap).active) { throw new InvalidOperationException("The star map cannot open in the current game mode."); } starmap.SetViewStar(planet.star, false); starmap.screenCameraController.SetViewTarget(planet, (StarData)null, (EnemyDFHiveSystem)null, (Player)null, VectorLF3.zero, (double)planet.realRadius * 0.00025 * 3.0, (double)planet.realRadius * 0.00025 * 6.0, true, false); Status = "Focused " + planet.displayName; } catch (Exception ex) { Status = "Locate failed: " + ex.Message; ((BaseUnityPlugin)this).Logger.LogWarning((object)ex); } } internal void Warp(PlanetData planet) { if (planet == null || GameMain.mainPlayer == null) { return; } try { GameMain.mainPlayer.navigation.indicatorAstroId = planet.id; Window.Close(); Status = "Navigation target: " + planet.displayName; } catch (Exception ex) { Status = "Warp failed: " + ex.Message; ((BaseUnityPlugin)this).Logger.LogWarning((object)ex); } } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); } if (launcher != null) { launcher.Dispose(); } if (Window != null) { Window.Dispose(); } if ((Object)(object)instance == (Object)(object)this) { instance = null; } } } internal static class Rates { internal static readonly double[] Minutes = new double[5] { 1.0, 10.0, 60.0, 600.0, 6000.0 }; internal static readonly string[] Labels = new string[6] { "1 minute", "10 minutes", "1 hour", "10 hours", "100 hours", "Total" }; internal static double PerMinute(long[] totals, int level) { if (totals == null || level < 0 || level >= Labels.Length || totals.Length <= level + 1) { return 0.0; } double num = Math.Abs((double)totals[level + 1]); if (level != 5) { return num / Minutes[level]; } return num; } internal static bool HasProduction(ProductStat stat) { if (stat == null) { return false; } if (stat.total != null) { for (int i = 0; i < Math.Min(7, stat.total.Length); i++) { if (stat.total[i] != 0) { return true; } } } if (stat.productionCount <= 0) { return stat.refProductSpeed > 0f; } return true; } } internal sealed class Producer { internal int Machine; internal int Recipe; internal int Count; internal string Kind; internal string Tooltip; } internal sealed class ProductRow { internal int Item; internal double Rate; internal readonly List<Producer> Sources = new List<Producer>(); internal int Count { get { int num = 0; foreach (Producer source in Sources) { num += source.Count; } return num; } } internal int Lines => Math.Max(1, Sources.Count); } internal sealed class PlanetInfo { internal PlanetData Planet; internal PlanetFactory Factory; internal readonly List<ProductRow> Products = new List<ProductRow>(); internal readonly Dictionary<int, ProductRow> ProductCache = new Dictionary<int, ProductRow>(); internal string Name { get { if (Planet != null) { return Planet.displayName; } return "Unknown planet"; } } internal string System { get { if (Planet != null && Planet.star != null) { return Planet.star.displayName; } return ""; } } } internal sealed class ProductionModel { internal readonly List<PlanetInfo> Planets = new List<PlanetInfo>(); internal int SelectedId; internal int Level; private GameData bound; private IEnumerator scan; private double refreshAt; private double sourceAt; private Dictionary<int, List<Producer>> sources = new Dictionary<int, List<Producer>>(); private readonly Dictionary<int, PlanetInfo> planetCache = new Dictionary<int, PlanetInfo>(); private readonly HashSet<int> seenPlanets = new HashSet<int>(); private readonly Stopwatch budget = new Stopwatch(); internal bool Scanning => scan != null; internal bool HasScannedSelection { get; private set; } internal PlanetInfo Selected { get { foreach (PlanetInfo planet in Planets) { if (planet.Planet.id == SelectedId) { return planet; } } return null; } } internal void Select(int id) { if (SelectedId != id) { SelectedId = id; sources.Clear(); scan = null; sourceAt = 0.0; HasScannedSelection = false; } } internal void Refresh() { refreshAt = 0.0; sourceAt = 0.0; } internal void Reset() { if (bound != null || Planets.Count != 0) { bound = null; scan = null; Planets.Clear(); planetCache.Clear(); sources.Clear(); SelectedId = 0; refreshAt = (sourceAt = 0.0); HasScannedSelection = false; } } internal void Tick(GameData data) { if (bound != data) { Reset(); bound = data; } double realtimeSinceStartupAsDouble = Time.realtimeSinceStartupAsDouble; if (realtimeSinceStartupAsDouble >= refreshAt) { refreshAt = realtimeSinceStartupAsDouble + 1.0; ReadPlanets(data); } PlanetInfo selected = Selected; if (selected == null) { return; } if (scan == null && realtimeSinceStartupAsDouble >= sourceAt) { sourceAt = realtimeSinceStartupAsDouble + 5.0; scan = Scan(selected); } budget.Restart(); int num = 0; while (scan != null && num++ < 512 && budget.Elapsed.TotalMilliseconds < 0.75) { if (!scan.MoveNext()) { scan = null; } } } internal void ReadPlanets(GameData data) { Planets.Clear(); seenPlanets.Clear(); if (data == null || data.factories == null || data.statistics == null || data.statistics.production == null) { return; } FactoryProductionStat[] factoryStatPool = data.statistics.production.factoryStatPool; if (factoryStatPool == null) { return; } int num = data.factories.Length; for (int i = 0; i < num; i++) { PlanetFactory val = data.factories[i]; if (val == null || val.planet == null || !seenPlanets.Add(val.planet.id)) { continue; } int num2 = val.planet.factoryIndex; if (num2 < 0 || num2 >= factoryStatPool.Length) { num2 = val.index; } if (num2 < 0 || num2 >= factoryStatPool.Length) { continue; } FactoryProductionStat val2 = factoryStatPool[num2]; if (val2 == null || val2.productPool == null) { continue; } if (!planetCache.TryGetValue(val.planet.id, out var value) || value.Factory != val) { PlanetInfo planetInfo = new PlanetInfo(); planetInfo.Planet = val.planet; planetInfo.Factory = val; value = planetInfo; planetCache[val.planet.id] = value; } value.Products.Clear(); int num3 = Math.Min(val2.productCursor, val2.productPool.Length); for (int j = 1; j < num3; j++) { ProductStat val3 = val2.productPool[j]; if (val3 != null && val3.itemId > 0 && Rates.HasProduction(val3)) { double rate = Rates.PerMinute(val3.total, Level); if (!value.ProductCache.TryGetValue(val3.itemId, out var value2)) { ProductRow productRow = new ProductRow(); productRow.Item = val3.itemId; value2 = productRow; value.ProductCache.Add(value2.Item, value2); } value2.Rate = rate; value2.Sources.Clear(); if (val.planet.id == SelectedId && sources.TryGetValue(value2.Item, out var value3)) { value2.Sources.AddRange(value3); } value.Products.Add(value2); } } if (value.Products.Count > 0) { value.Products.Sort((ProductRow a, ProductRow b) => a.Item.CompareTo(b.Item)); Planets.Add(value); } } Planets.Sort((PlanetInfo a, PlanetInfo b) => StringComparer.OrdinalIgnoreCase.Compare(a.Name, b.Name)); if (Selected == null && Planets.Count > 0) { Select(Planets[0].Planet.id); } } private IEnumerator Scan(PlanetInfo planet) { int selection = planet.Planet.id; PlanetFactory factory = planet.Factory; Dictionary<int, List<Producer>> result = new Dictionary<int, List<Producer>>(); int end = ((factory.entityPool != null) ? Math.Min(factory.entityCursor, factory.entityPool.Length) : 0); int i = 1; while (true) { if (i < end) { if (selection != SelectedId || bound == null) { break; } if (factory.entityPool != null && i < factory.entityPool.Length) { EntityData entity = factory.entityPool[i]; if (entity.id == i) { ReadEntity(factory, entity, result); } } yield return null; i++; continue; } if (selection != SelectedId) { break; } foreach (KeyValuePair<int, List<Producer>> item in result) { if (!sources.TryGetValue(item.Key, out var value)) { continue; } for (int j = 0; j < item.Value.Count; j++) { foreach (Producer item2 in value) { if (item2.Machine == item.Value[j].Machine && item2.Recipe == item.Value[j].Recipe && item2.Kind == item.Value[j].Kind) { item2.Count = item.Value[j].Count; item.Value[j] = item2; break; } } } } sources = result; HasScannedSelection = true; PlanetInfo current3 = Selected; if (current3 == null) { break; } foreach (ProductRow product in current3.Products) { product.Sources.Clear(); if (result.TryGetValue(product.Item, out var value2)) { product.Sources.AddRange(value2); } } break; } } internal static void Add(Dictionary<int, List<Producer>> target, int product, int machine, int recipe, string kind) { if (product <= 0 || machine <= 0) { return; } if (!target.TryGetValue(product, out var value)) { value = new List<Producer>(); target.Add(product, value); } Producer producer = null; foreach (Producer item in value) { if (item.Machine == machine && item.Recipe == recipe && item.Kind == kind) { producer = item; break; } } if (producer == null) { value.Add(new Producer { Machine = machine, Recipe = recipe, Kind = kind, Count = 1 }); } else { producer.Count++; } } private static bool Has<T>(T[] array, int index) { if (array != null && index > 0) { return index < array.Length; } return false; } private static void AddRecipe(Dictionary<int, List<Producer>> result, int machine, int recipe, RecipeExecuteData execute) { RecipeProto val = (((Object)(object)LDB.recipes == (Object)null) ? null : ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(recipe)); int[] array = execute?.products; if ((array == null || array.Length == 0) && val != null) { array = val.Results; } if (array == null) { return; } for (int i = 0; i < array.Length; i++) { bool flag = false; for (int j = 0; j < i; j++) { if (array[j] == array[i]) { flag = true; } } if (!flag) { Add(result, array[i], machine, recipe, "Recipe"); } } } internal static void ReadEntity(PlanetFactory factory, EntityData entity, Dictionary<int, List<Producer>> result) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) FactorySystem factorySystem = factory.factorySystem; if (factorySystem != null && Has(factorySystem.assemblerPool, entity.assemblerId)) { AssemblerComponent val = factorySystem.assemblerPool[entity.assemblerId]; if (val.id == entity.assemblerId && val.entityId == entity.id && val.recipeId > 0) { AddRecipe(result, entity.protoId, val.recipeId, val.recipeExecuteData); } } if (factorySystem != null && Has(factorySystem.labPool, entity.labId)) { LabComponent val2 = factorySystem.labPool[entity.labId]; if (val2.id == entity.labId && val2.entityId == entity.id && !val2.researchMode && val2.recipeId > 0) { AddRecipe(result, entity.protoId, val2.recipeId, val2.recipeExecuteData); } } if (factorySystem != null && Has(factorySystem.fractionatorPool, entity.fractionatorId)) { FractionatorComponent val3 = factorySystem.fractionatorPool[entity.fractionatorId]; if (val3.id == entity.fractionatorId && val3.entityId == entity.id && val3.productId > 0) { int recipe = 0; if (RecipeProto.fractionatorRecipes != null) { RecipeProto[] fractionatorRecipes = RecipeProto.fractionatorRecipes; foreach (RecipeProto val4 in fractionatorRecipes) { if (val4 != null && val4.Items != null && val4.Items.Length > 0 && val4.Items[0] == val3.fluidId && val4.Results != null && val4.Results.Length > 0 && val4.Results[0] == val3.productId) { recipe = ((Proto)val4).ID; break; } } } Add(result, val3.productId, entity.protoId, recipe, "Fractionation"); } } if (factorySystem != null && Has(factorySystem.minerPool, entity.minerId)) { MinerComponent val5 = factorySystem.minerPool[entity.minerId]; if (val5.id == entity.minerId && val5.entityId == entity.id) { Add(result, val5.productId, entity.protoId, 0, "Extraction"); } } PowerSystem powerSystem = factory.powerSystem; if (powerSystem != null && Has(powerSystem.genPool, entity.powerGenId)) { PowerGeneratorComponent val6 = powerSystem.genPool[entity.powerGenId]; if (val6.id == entity.powerGenId && val6.entityId == entity.id && val6.gamma && val6.productId > 0) { Add(result, val6.productId, entity.protoId, 0, "Photon generation"); } } if (powerSystem != null && Has(powerSystem.excPool, entity.powerExcId)) { PowerExchangerComponent val7 = powerSystem.excPool[entity.powerExcId]; if (val7.id == entity.powerExcId && val7.entityId == entity.id && val7.targetState != 0f) { Add(result, (val7.targetState > 0f) ? val7.fullId : val7.emptyId, entity.protoId, 0, (val7.targetState > 0f) ? "Accumulator charging" : "Accumulator discharging"); } } PlanetTransport transport = factory.transport; if (transport == null || !Has(transport.stationPool, entity.stationId)) { return; } StationComponent val8 = transport.stationPool[entity.stationId]; if (val8 != null && val8.id == entity.stationId && val8.entityId == entity.id && val8.isCollector && val8.storage != null) { StationStore[] storage = val8.storage; for (int j = 0; j < storage.Length; j++) { StationStore val9 = storage[j]; Add(result, val9.itemId, entity.protoId, 0, "Orbital collection"); } } } } internal sealed class ProductionWindow : IDisposable { private readonly Plugin plugin; private Rect rect = new Rect(70f, 70f, 1480f, 820f); private Vector2 planetsScroll; private Vector2 productsScroll; private string search = ""; private bool localSystem; private bool descending; private bool dragging; private bool editing; private int blockedThrough = -1; private GameObject shield; private RectTransform shieldRect; private Texture2D logo; private readonly Vector3[] panelCorners = (Vector3[])(object)new Vector3[4]; private NativeStyle label; private NativeStyle small; private NativeStyle title; private NativeStyle button; private NativeStyle field; private NativeStyle right; private NativeStyle tip; private NativeStyle detail; private readonly NativePanel ui = new NativePanel(); private readonly List<PlanetInfo> filtered = new List<PlanetInfo>(); private static readonly string[] Locations = new string[2] { "Entire star cluster", "Current system" }; private static readonly string[] SortOrders = new string[2] { "Planet name A-Z", "Planet name Z-A" }; internal bool Visible; private float Scale { get { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) UIGame val = (((Object)(object)UIRoot.instance == (Object)null) ? null : UIRoot.instance.uiGame); RectTransform val2 = (RectTransform)(((Object)(object)val == (Object)null || (Object)(object)val.controlPanelWindow == (Object)null) ? null : /*isinst with value type is only supported in some contexts*/); Canvas val3 = (((Object)(object)val2 == (Object)null) ? null : ((Component)val2).GetComponentInParent<Canvas>()); if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null) { Rect val4 = val2.rect; if (((Rect)(ref val4)).width > 0f) { val2.GetWorldCorners(panelCorners); Camera val5 = (((int)val3.renderMode == 0) ? null : val3.worldCamera); float num = Math.Abs(RectTransformUtility.WorldToScreenPoint(val5, panelCorners[2]).x - RectTransformUtility.WorldToScreenPoint(val5, panelCorners[0]).x); if (num > 0f) { Rect val6 = val2.rect; return Mathf.Clamp(num / ((Rect)(ref val6)).width, 0.25f, 4f); } } } return Mathf.Clamp((float)Screen.height / 1080f, 0.7f, 1.6f); } } internal bool KeyboardBlocking { get { if (Visible) { return editing; } return false; } } internal bool Blocking { get { //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_0066: Unknown result type (might be due to invalid IL or missing references) Vector3 mousePosition = Input.mousePosition; if (Time.frameCount > blockedThrough) { if (Visible) { if (!dragging && !ui.Dragging && !ui.Editing) { return ((Rect)(ref rect)).Contains(new Vector2(mousePosition.x / Scale, ((float)Screen.height - mousePosition.y) / Scale)); } return true; } return false; } return true; } } internal ProductionWindow(Plugin plugin) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) this.plugin = plugin; } internal void Toggle() { if (Visible) { Close(); } else { Visible = true; } } internal void Close() { if (Visible) { Visible = false; dragging = (editing = false); blockedThrough = Time.frameCount + 1; ui.Active(value: false); } } internal void UpdateShield() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) bool flag = Visible || Time.frameCount <= blockedThrough; if (flag && (Object)(object)shield == (Object)null) { shield = new GameObject("Star System Production input shield", new Type[3] { typeof(RectTransform), typeof(Canvas), typeof(GraphicRaycaster) }); Object.DontDestroyOnLoad((Object)(object)shield); Canvas component = shield.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = 32760; GameObject val = new GameObject("Window-sized hit surface", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(shield.transform, false); Image component2 = val.GetComponent<Image>(); ((Graphic)component2).color = Color.clear; ((Graphic)component2).raycastTarget = true; shieldRect = ((Graphic)component2).rectTransform; RectTransform obj = shieldRect; RectTransform obj2 = shieldRect; Vector2 val2 = (shieldRect.pivot = new Vector2(0f, 1f)); Vector2 anchorMin = (obj2.anchorMax = val2); obj.anchorMin = anchorMin; } if ((Object)(object)shield != (Object)null) { shield.SetActive(flag); } if ((Object)(object)shieldRect != (Object)null) { shieldRect.anchoredPosition = new Vector2(((Rect)(ref rect)).x * Scale, (0f - ((Rect)(ref rect)).y) * Scale); shieldRect.sizeDelta = ((Rect)(ref rect)).size * Scale; } } private void Styles() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (label == null) { UIControlPanelWindow controlPanelWindow = UIRoot.instance.uiGame.controlPanelWindow; int fontSize = controlPanelWindow.filterPanel.sortFilterLabel.fontSize; label = new NativeStyle { fontSize = fontSize }; small = new NativeStyle { fontSize = fontSize }; title = new NativeStyle { fontSize = fontSize + 2 }; button = new NativeStyle { fontSize = fontSize, alignment = (TextAnchor)4 }; field = new NativeStyle { fontSize = fontSize }; detail = new NativeStyle { fontSize = fontSize + 2 }; right = new NativeStyle { fontSize = fontSize + 2, alignment = (TextAnchor)5 }; tip = new NativeStyle { fontSize = fontSize }; logo = Branding.LoadIcon(); } } private void MatchControlPanelSize() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) float num = (float)Screen.width * 0.96f; float num2 = (float)Screen.height * 0.9f; UIGame val = (((Object)(object)UIRoot.instance == (Object)null) ? null : UIRoot.instance.uiGame); UIControlPanelWindow val2 = (((Object)(object)val == (Object)null) ? null : val.controlPanelWindow); if ((Object)(object)val2 != (Object)null) { Transform transform = ((Component)val2).transform; RectTransform val3 = (RectTransform)(object)((transform is RectTransform) ? transform : null); Canvas val4 = (((Object)(object)val3 == (Object)null) ? null : ((Component)val3).GetComponentInParent<Canvas>()); if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null) { val3.GetWorldCorners(panelCorners); Camera val5 = (((int)val4.renderMode == 0) ? null : val4.worldCamera); Vector2 val6 = RectTransformUtility.WorldToScreenPoint(val5, panelCorners[0]); Vector2 val7 = RectTransformUtility.WorldToScreenPoint(val5, panelCorners[2]); if (Math.Abs(val7.x - val6.x) > 800f && Math.Abs(val7.y - val6.y) > 500f) { num = Math.Abs(val7.x - val6.x); num2 = Math.Abs(val7.y - val6.y); } } } ((Rect)(ref rect)).width = Math.Min(num * 0.92f / Scale, (float)Screen.width / Scale - 20f); ((Rect)(ref rect)).height = Math.Min(num2 / Scale, (float)Screen.height / Scale - 20f); } internal void Draw() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) ui.Active(Visible); if (Visible) { Styles(); MatchControlPanelSize(); ((Rect)(ref rect)).x = Mathf.Clamp(((Rect)(ref rect)).x, 0f, Math.Max(0f, (float)Screen.width / Scale - ((Rect)(ref rect)).width)); ((Rect)(ref rect)).y = Mathf.Clamp(((Rect)(ref rect)).y, 0f, Math.Max(0f, (float)Screen.height / Scale - ((Rect)(ref rect)).height)); ui.Begin(rect, Scale, delegate(Vector2 delta) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) ref Rect reference = ref rect; ((Rect)(ref reference)).position = ((Rect)(ref reference)).position + delta; blockedThrough = Time.frameCount + 1; }); Contents(0); ui.End(); editing = ui.Editing; UpdateShield(); } } private static string ItemName(int id) { ItemProto val = (((Object)(object)LDB.items == (Object)null) ? null : ((ProtoSet<ItemProto>)(object)LDB.items).Select(id)); if (val != null) { return DisplayNames.Name((Proto)(object)val); } return "Item " + id; } private static string RecipeName(Producer source) { RecipeProto val = (((Object)(object)LDB.recipes == (Object)null) ? null : ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(source.Recipe)); if (val != null) { return DisplayNames.Name((Proto)(object)val); } return source.Kind; } private static bool Matches(string text, string query) { if (text != null) { return text.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private void Contents(int id) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Unknown result type (might be due to invalid IL or missing references) //IL_0638: Unknown result type (might be due to invalid IL or missing references) ui.Surface(new Rect(0f, 0f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), "frame", selected: false); ui.Surface(new Rect(0f, 0f, ((Rect)(ref rect)).width, 78f), "header", selected: false); ui.DrawTexture(new Rect(14f, 6f, 28f, 28f), (Texture)(object)logo, (ScaleMode)2); ui.Label(new Rect(50f, 3f, 600f, 24f), "Star System Production", title); ui.Label(new Rect(50f, 25f, 500f, 16f), "Loki Moon Labs", small); if (ui.Button(new Rect(((Rect)(ref rect)).width - 170f, 8f, 104f, 24f), "Refresh", button)) { plugin.Model.Refresh(); } if (ui.Button(new Rect(((Rect)(ref rect)).width - 54f, 8f, 36f, 24f), "X", button)) { Close(); return; } localSystem = ui.Dropdown(new Rect(16f, 44f, 190f, 26f), Locations, localSystem ? 1 : 0) == 1; descending = ui.Dropdown(new Rect(214f, 44f, 190f, 26f), SortOrders, descending ? 1 : 0) == 1; int num = ui.Dropdown(new Rect(412f, 44f, 190f, 26f), Rates.Labels, plugin.Model.Level); if (num != plugin.Model.Level) { plugin.Model.Level = num; plugin.Model.Refresh(); } search = ui.TextField(new Rect(614f, 44f, Math.Max(140f, ((Rect)(ref rect)).width - 630f), 26f), search, field); if (string.IsNullOrEmpty(search)) { ui.Label(new Rect(620f, 45f, 400f, 24f), "Search planets or products...", small); } float num2 = 330f; float num3 = 90f; flo