using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using XYModLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("Small")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a41686fc8229a1a9e22e8031c2b9aab0bd0ed958")]
[assembly: AssemblyProduct("DSPTransferInfo")]
[assembly: AssemblyTitle("DSPTransferInfo")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace XYModLib
{
public class EnumSelectGUI
{
private Type EnumType;
private string[] EnumNames;
private string name;
public int NowSelectedIndex;
public int VerticalWidth = 100;
public bool HideSkin;
public EnumSelectGUI(Type e, string guiName)
{
name = guiName;
EnumType = e;
EnumNames = Enum.GetNames(e);
}
public void VerticalGUI()
{
if (HideSkin)
{
GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width((float)VerticalWidth),
GUILayout.ExpandHeight(true)
});
}
else
{
GUILayout.BeginVertical(name, GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width((float)VerticalWidth),
GUILayout.ExpandHeight(true)
});
}
GUILayout.Space(16f);
NowSelectedIndex = GUILayout.SelectionGrid(NowSelectedIndex, EnumNames, 1, Array.Empty<GUILayoutOption>());
GUILayout.EndVertical();
}
public void HorizontalGUI()
{
if (HideSkin)
{
GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
}
else
{
GUILayout.BeginHorizontal(GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
}
NowSelectedIndex = GUILayout.SelectionGrid(NowSelectedIndex, EnumNames, EnumNames.Length, Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
}
}
public static class GUIHelper
{
private static Dictionary<string, string> strCache = new Dictionary<string, string>();
public static void ClearCache()
{
strCache.Clear();
}
public static int IntTextGUI(int num, string key, int width = 0, int min = int.MinValue, int max = int.MaxValue)
{
if (!strCache.ContainsKey(key))
{
strCache[key] = num.ToString();
}
if (width > 0)
{
strCache[key] = GUILayout.TextField(strCache[key], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((float)width) });
}
else
{
strCache[key] = GUILayout.TextField(strCache[key], Array.Empty<GUILayoutOption>());
}
if (int.TryParse(strCache[key], out var result))
{
strCache.Remove(key);
return Mathf.Clamp(result, min, max);
}
return num;
}
public static uint UIntTextGUI(uint num, string key, int width = 0, uint min = 0u, uint max = uint.MaxValue)
{
if (!strCache.ContainsKey(key))
{
strCache[key] = num.ToString();
}
if (width > 0)
{
strCache[key] = GUILayout.TextField(strCache[key], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((float)width) });
}
else
{
strCache[key] = GUILayout.TextField(strCache[key], Array.Empty<GUILayoutOption>());
}
if (uint.TryParse(strCache[key], out var result))
{
strCache.Remove(key);
if (result < min)
{
result = min;
}
if (result > max)
{
result = max;
}
return result;
}
return num;
}
public static long LongTextGUI(long num, string key, int width = 0, long min = long.MinValue, long max = long.MaxValue)
{
if (!strCache.ContainsKey(key))
{
strCache[key] = num.ToString();
}
if (width > 0)
{
strCache[key] = GUILayout.TextField(strCache[key], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((float)width) });
}
else
{
strCache[key] = GUILayout.TextField(strCache[key], Array.Empty<GUILayoutOption>());
}
if (long.TryParse(strCache[key], out var result))
{
strCache.Remove(key);
if (result < min)
{
result = min;
}
if (result > max)
{
result = max;
}
return result;
}
return num;
}
public static ulong ULongTextGUI(ulong num, string key, int width = 0, ulong min = 0uL, ulong max = ulong.MaxValue)
{
if (!strCache.ContainsKey(key))
{
strCache[key] = num.ToString();
}
if (width > 0)
{
strCache[key] = GUILayout.TextField(strCache[key], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((float)width) });
}
else
{
strCache[key] = GUILayout.TextField(strCache[key], Array.Empty<GUILayoutOption>());
}
if (ulong.TryParse(strCache[key], out var result))
{
strCache.Remove(key);
if (result < min)
{
result = min;
}
if (result > max)
{
result = max;
}
return result;
}
return num;
}
public static float FloatTextGUI(float num, string key, int width = 0, float min = float.MinValue, float max = float.MaxValue)
{
if (!strCache.ContainsKey(key))
{
strCache[key] = num.ToString();
}
if (width > 0)
{
strCache[key] = GUILayout.TextField(strCache[key], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((float)width) });
}
else
{
strCache[key] = GUILayout.TextField(strCache[key], Array.Empty<GUILayoutOption>());
}
if (float.TryParse(strCache[key], out var result))
{
strCache.Remove(key);
return Mathf.Clamp(result, min, max);
}
return num;
}
}
public class RayBlocker
{
private RectTransform rt;
private GameObject canvasObj;
private GameObject rayblockerObj;
private Func<Rect> getRectFunc;
private Func<bool> getShowFunc;
private RayBlockerMono mono;
public RayBlocker(Func<Rect> getRect, Func<bool> getShow)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
//IL_00aa: 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)
getRectFunc = getRect;
getShowFunc = getShow;
canvasObj = new GameObject("RayBlockerCanvas");
Object.DontDestroyOnLoad((Object)(object)canvasObj);
canvasObj.AddComponent<Canvas>().renderMode = (RenderMode)0;
Type type = AccessTools.TypeByName("UnityEngine.UI.GraphicRaycaster");
Type type2 = AccessTools.TypeByName("UnityEngine.UI.Image");
canvasObj.AddComponent(type);
rayblockerObj = new GameObject("RayBlocker");
rt = rayblockerObj.AddComponent<RectTransform>();
((Transform)rt).SetParent(canvasObj.transform);
rt.pivot = new Vector2(0f, 1f);
Component obj = rayblockerObj.AddComponent(type2);
Traverse.Create((object)obj).Property("color", (object[])null).SetValue((object)Color.clear);
Traverse.Create((object)obj).Property("raycastTarget", (object[])null).SetValue((object)true);
mono = canvasObj.AddComponent<RayBlockerMono>();
mono.OnUpdate = Update;
}
public void Update()
{
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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)
if (getRectFunc == null || getShowFunc == null)
{
return;
}
if (getShowFunc())
{
Rect val = getRectFunc();
rt.sizeDelta = ((Rect)(ref val)).size;
((Transform)rt).position = Vector2.op_Implicit(new Vector2(((Rect)(ref val)).position.x, (float)Screen.height - ((Rect)(ref val)).position.y));
if (!rayblockerObj.activeSelf)
{
rayblockerObj.SetActive(true);
}
}
else
{
rt.sizeDelta = Vector2.zero;
if (rayblockerObj.activeSelf)
{
rayblockerObj.SetActive(false);
}
}
}
}
public class RayBlockerMono : MonoBehaviour
{
public Action OnUpdate;
private void Update()
{
if (OnUpdate != null)
{
OnUpdate();
}
}
}
public class SearchGUI<T>
{
private List<T> searchResultList = new List<T>();
private List<T> searchSource = new List<T>();
private string searchStr = "";
private int nowPage;
private int maxPage;
private int tmpPage;
private int tmpShow;
private Vector2 sv;
private int perPageNum;
private int searchInputWidth;
private Func<T, string, bool> searchFunc;
private Func<List<T>> getSearchObjFunc;
private Action<T> showObjGUIAction;
public bool EnableSVSkin;
public SearchGUI(Func<List<T>> getSearchObjFunc, Func<T, string, bool> searchFunc, Action<T> showObjGUIAction, int perPageNum = 10, int searchInputWidth = 100)
{
this.perPageNum = perPageNum;
this.searchFunc = searchFunc;
this.showObjGUIAction = showObjGUIAction;
this.getSearchObjFunc = getSearchObjFunc;
this.searchInputWidth = searchInputWidth;
}
public void OnGUI()
{
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
GUILayout.Label("搜索", Array.Empty<GUILayoutOption>());
searchStr = GUILayout.TextField(searchStr, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((float)searchInputWidth) });
GUILayout.FlexibleSpace();
searchSource = getSearchObjFunc();
searchResultList.Clear();
foreach (T item in searchSource)
{
if (searchFunc(item, searchStr))
{
searchResultList.Add(item);
}
}
maxPage = searchResultList.Count / perPageNum;
if (searchResultList.Count % perPageNum != 0)
{
maxPage++;
}
GUILayout.Label($" 第{nowPage + 1}页 共{maxPage}页", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
if (GUILayout.Button("上一页", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
{
nowPage--;
}
if (GUILayout.Button("下一页", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }))
{
nowPage++;
}
if (nowPage < 0)
{
nowPage = maxPage - 1;
}
if (nowPage >= maxPage)
{
nowPage = 0;
}
tmpPage = 0;
tmpShow = 0;
GUILayout.EndHorizontal();
if (EnableSVSkin)
{
sv = GUILayout.BeginScrollView(sv, GUI.skin.box);
}
else
{
sv = GUILayout.BeginScrollView(sv, Array.Empty<GUILayoutOption>());
}
foreach (T searchResult in searchResultList)
{
if (tmpPage < nowPage * perPageNum)
{
tmpPage++;
continue;
}
tmpShow++;
showObjGUIAction(searchResult);
if (tmpShow < perPageNum)
{
continue;
}
break;
}
GUILayout.EndScrollView();
GUILayout.EndVertical();
}
}
public class UIWindow
{
public int WindowID;
public Rect WindowRect = new Rect((float)(Screen.width / 2 - 400), (float)(Screen.height / 2 - 300), 800f, 600f);
public RayBlocker RayBlocker;
public string Name;
private bool show;
public bool CanDrag = true;
public Action OnWindowOpen;
public Action OnWindowClose;
public Action OnWinodwGUI;
public bool Show
{
get
{
return show;
}
set
{
if (show == value)
{
return;
}
show = value;
if (show)
{
if (OnWindowOpen != null)
{
OnWindowOpen();
}
}
else if (OnWindowClose != null)
{
OnWindowClose();
}
}
}
public UIWindow(string name)
{
//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)
Name = name;
WindowID = Random.Range(1000000, int.MaxValue);
RayBlocker = new RayBlocker(() => WindowRect, () => Show);
}
public UIWindow(string name, Rect rect)
{
//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_0046: 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)
Name = name;
WindowRect = rect;
WindowID = Random.Range(1000000, int.MaxValue);
RayBlocker = new RayBlocker(() => WindowRect, () => Show);
}
public void OnGUI()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (Show)
{
WindowRect = GUILayout.Window(WindowID, WindowRect, new WindowFunction(WindowFunc), Name, Array.Empty<GUILayoutOption>());
}
}
public void WindowFunc(int id)
{
if (OnWinodwGUI != null)
{
OnWinodwGUI();
}
else
{
GUILayout.Label(" ", Array.Empty<GUILayoutOption>());
}
if (CanDrag)
{
GUI.DragWindow();
}
}
}
public static class ResourceUtils
{
private static Dictionary<string, Texture2D> texDict = new Dictionary<string, Texture2D>();
public static byte[] ReadAllBytes(this Stream input)
{
byte[] array = new byte[16384];
using MemoryStream memoryStream = new MemoryStream();
int count;
while ((count = input.Read(array, 0, array.Length)) > 0)
{
memoryStream.Write(array, 0, count);
}
return memoryStream.ToArray();
}
public static byte[] GetEmbeddedResource(string resourceFileName, Assembly containingAssembly = null)
{
if (containingAssembly == null)
{
containingAssembly = Assembly.GetCallingAssembly();
}
string name = containingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(resourceFileName));
using Stream stream = containingAssembly.GetManifestResourceStream(name);
return (stream ?? throw new InvalidOperationException("The resource " + resourceFileName + " was not found")).ReadAllBytes();
}
public static Texture2D LoadTexture(byte[] texData)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
Texture2D val = new Texture2D(1, 1, (TextureFormat)5, false);
MethodInfo method = typeof(Texture2D).GetMethod("LoadImage", new Type[1] { typeof(byte[]) });
if (method != null)
{
method.Invoke(val, new object[1] { texData });
}
else
{
Type? type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule");
if (type == null)
{
throw new ArgumentNullException("converter");
}
MethodInfo? method2 = type.GetMethod("LoadImage", new Type[2]
{
typeof(Texture2D),
typeof(byte[])
});
if (method2 == null)
{
throw new ArgumentNullException("converterMethod");
}
method2.Invoke(null, new object[2] { val, texData });
}
return val;
}
public static Texture2D GetTex(string name)
{
if (texDict.ContainsKey(name))
{
return texDict[name];
}
Texture2D val = LoadTexture(GetEmbeddedResource(name));
Object.DontDestroyOnLoad((Object)(object)val);
texDict.Add(name, val);
return val;
}
}
}
namespace MyFirstPlugin
{
internal class TransportInfo : IComparable<TransportInfo>
{
public int id;
public int gid;
public string name;
public string[] items;
public int entityId;
public int planetId;
public bool isCollector;
public TransportInfo()
{
items = new string[5] { "", "", "", "", "" };
}
public int CompareTo(TransportInfo other)
{
return other.planetId.CompareTo(planetId);
}
}
internal class Cell
{
private string name;
private Dictionary<string, List<TransportInfo>> data;
private bool isCollapse = true;
private bool isInSpace;
private Action<TransportInfo> callback;
private static GUIStyle _pluginHeaderSkin;
public Cell(string name, Dictionary<string, List<TransportInfo>> data, Action<TransportInfo> callback, bool isInSpace)
{
this.name = name;
this.data = data;
this.callback = callback;
this.isInSpace = isInSpace;
}
public void Draw(string search, bool showCollector)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
if (_pluginHeaderSkin == null)
{
_pluginHeaderSkin = new GUIStyle(GUI.skin.box)
{
alignment = (TextAnchor)1,
wordWrap = true,
stretchWidth = true
};
}
GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
if (string.IsNullOrEmpty(search))
{
if (isCollapse)
{
if (GUILayout.Button(name + "\n...", _pluginHeaderSkin, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
{
isCollapse = !isCollapse;
}
}
else
{
if (GUILayout.Button(name, _pluginHeaderSkin, Array.Empty<GUILayoutOption>()))
{
isCollapse = !isCollapse;
}
foreach (KeyValuePair<string, List<TransportInfo>> datum in data)
{
List<TransportInfo> ed2 = new List<TransportInfo>();
datum.Value.ForEach(delegate(TransportInfo item)
{
if (showCollector || !item.isCollector)
{
ed2.Add(item);
}
});
if (ed2.Count > 0)
{
GUILayout.Label(datum.Key, _pluginHeaderSkin, Array.Empty<GUILayoutOption>());
ed2.ForEach(DrawItem);
}
}
}
}
else
{
GUILayout.Label(name, _pluginHeaderSkin, Array.Empty<GUILayoutOption>());
foreach (KeyValuePair<string, List<TransportInfo>> datum2 in data)
{
List<TransportInfo> ed = new List<TransportInfo>();
datum2.Value.ForEach(delegate(TransportInfo item)
{
if (searched(item, search) && (showCollector || !item.isCollector))
{
ed.Add(item);
}
});
if (ed.Count > 0)
{
GUILayout.Label(datum2.Key, _pluginHeaderSkin, Array.Empty<GUILayoutOption>());
ed.ForEach(DrawItem);
}
}
}
GUILayout.EndVertical();
}
private bool searched(TransportInfo item, string search)
{
if (item.name.IndexOf(search) >= 0)
{
return true;
}
string[] items = item.items;
for (int i = 0; i < items.Length; i++)
{
if (items[i].IndexOf(search) >= 0)
{
return true;
}
}
return false;
}
private void DrawItem(TransportInfo item)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label(item.id.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(25f) });
GUILayout.Label(item.name, Array.Empty<GUILayoutOption>());
string[] items = item.items;
for (int i = 0; i < items.Length; i++)
{
GUILayout.Label(items[i], (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) });
}
if (!isInSpace && GUILayout.Button("info", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
{
callback(item);
}
GUILayout.EndHorizontal();
}
}
internal class DSPPatch
{
}
[BepInPlugin("com.small.dsp.transferInfo", "dsp", "1.1")]
public class Plugin : BaseUnityPlugin
{
public const string PluginName = "com.small.dsp.transferInfo";
private UIWindow Window;
private PropertyInfo planetSetter;
private List<TransportInfo> arrayList = new List<TransportInfo>();
internal static string search = "";
internal static Dictionary<int, string> itemCache = new Dictionary<int, string>();
internal static List<Cell> cells = new List<Cell>();
internal static Vector2 scroll = new Vector2(0f, 0f);
internal static double time = 0.0;
internal static bool showCollector = false;
public ConfigEntry<KeyCode> GUIHotkey;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.small.dsp.transferInfo is loaded!");
Window = new UIWindow("Logistic Station Info");
Window.Show = false;
Window.OnWinodwGUI = guiInfo;
Window.OnWindowOpen = delegate
{
arrayList.Clear();
itemCache.Clear();
cells.Clear();
getInfo();
};
GUIHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Common", "GUIHotkey", (KeyCode)285, "Hotkey to show Logistic Station Info");
planetSetter = typeof(GameData).GetProperty("localPlanet");
}
protected void OnDestroy()
{
Harmony.UnpatchAll();
}
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(GUIHotkey.Value))
{
if (!GameMain.isRunning || GameMain.isPaused)
{
Window.Show = false;
}
else if (!UICursor.locked)
{
Window.Show = !Window.Show;
}
}
}
private void getInfo()
{
StationComponent[] stationPool = GameMain.data.galacticTransport.stationPool;
Dictionary<int, Dictionary<string, List<TransportInfo>>> dictionary = new Dictionary<int, Dictionary<string, List<TransportInfo>>>();
Dictionary<int, PlanetFactory> dictionary2 = new Dictionary<int, PlanetFactory>();
StationComponent[] array = stationPool;
foreach (StationComponent val in array)
{
if (val != null && !val.isVeinCollector)
{
TransportInfo transportInfo = new TransportInfo();
transportInfo.id = val.id;
transportInfo.gid = val.gid;
transportInfo.entityId = val.entityId;
transportInfo.planetId = val.planetId;
transportInfo.isCollector = val.isCollector;
int key = val.planetId / 100;
if (!dictionary.ContainsKey(key))
{
dictionary.Add(key, new Dictionary<string, List<TransportInfo>>());
}
string text = "";
if (!dictionary2.ContainsKey(transportInfo.planetId))
{
dictionary2[transportInfo.planetId] = GameMain.data.GetOrCreateFactory(GameMain.data.galaxy.PlanetById(transportInfo.planetId));
text = dictionary2[transportInfo.planetId].planet.name;
dictionary[key].Add(text, new List<TransportInfo>());
}
else
{
text = dictionary2[transportInfo.planetId].planet.name;
}
transportInfo.name = dictionary2[transportInfo.planetId].ReadExtraInfoOnEntity(transportInfo.entityId);
transportInfo.name = ((transportInfo.name == "") ? ((val.isCollector ? "collector-" : "transfer-") + transportInfo.id) : transportInfo.name);
arrayList.Add(transportInfo);
dictionary[key][text].Add(transportInfo);
}
}
bool isInSpace = GameMain.data.localPlanet == null;
foreach (KeyValuePair<int, Dictionary<string, List<TransportInfo>>> item in dictionary)
{
string displayName = GameMain.galaxy.StarById(item.Key).displayName;
cells.Add(new Cell(displayName, item.Value, OpenTransfer, isInSpace));
}
}
private void UpdateItems()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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_006f: 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)
StationComponent[] stationPool = GameMain.data.galacticTransport.stationPool;
foreach (TransportInfo array in arrayList)
{
StationComponent obj = stationPool[array.gid];
int num = 0;
StationStore[] storage = obj.storage;
foreach (StationStore val in storage)
{
if (val.itemId > 0)
{
if (!itemCache.ContainsKey(val.itemId))
{
itemCache.Add(val.itemId, LDB.ItemName(val.itemId));
}
array.items[num] = $"{itemCache[val.itemId]}\n{val.count}";
if (num >= 4)
{
break;
}
num++;
}
}
}
}
private void OpenTransfer(TransportInfo item)
{
UIGame uiGame = UIRoot.instance.uiGame;
uiGame.OpenPlayerInventory();
UIStationWindow stationWindow = uiGame.stationWindow;
PlanetData localPlanet = GameMain.localPlanet;
if (localPlanet == null)
{
Window.Show = false;
return;
}
if (localPlanet.id != item.planetId)
{
PlanetData val = GameMain.data.galaxy.PlanetById(item.planetId);
val.factory = GameMain.data.GetOrCreateFactory(val);
planetSetter.SetValue(GameMain.data, val);
}
stationWindow.stationId = item.id;
((ManualBehaviour)stationWindow)._Open();
planetSetter.SetValue(GameMain.data, localPlanet);
Window.Show = false;
}
private void OnGUI()
{
Window.OnGUI();
}
private void guiInfo()
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
if (GameMain.gameTime - time > 1.0)
{
UpdateItems();
time = GameMain.gameTime;
}
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
showCollector = GUILayout.Toggle(showCollector, "显示采集器/show collector", Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("Search:", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
search = GUILayout.TextField(search, Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
scroll = GUILayout.BeginScrollView(scroll, Array.Empty<GUILayoutOption>());
foreach (Cell cell in cells)
{
cell.Draw(search, showCollector);
}
GUILayout.EndScrollView();
}
}
}