Decompiled source of BUG BasicModPack v1.0.0
BUG_BasicModPack.dll
Decompiled 17 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BasicModPack { public static class PowerAlert { public static ConfigEntry<bool> Enabled; public const double Low = 0.9; public const double Recovered = 0.95; private static bool warned; private static int planet; public static bool Next(bool warned, double? ratio) { if (ratio.HasValue) { if (!warned) { return ratio < 0.9; } return ratio < 0.95; } return false; } public static void Tick() { if (!Enabled.Value || Time.frameCount % 60 != 0) { return; } PlanetFactory val = GameMain.localPlanet?.factory; if (val == null) { warned = false; return; } if (val.planetId != planet) { planet = val.planetId; warned = false; } PowerSystem powerSystem = val.powerSystem; double? num = null; for (int i = 1; i < powerSystem.netCursor; i++) { PowerNetwork val2 = powerSystem.netPool[i]; if (val2 != null && val2.id == i && val2.energyRequired > 0 && (!num.HasValue || val2.consumerRatio < num)) { num = val2.consumerRatio; } } bool flag = Next(warned, num); if (flag && !warned) { UIRealtimeTip.Popup(Lang.F("Low power on {0}: {1}% of demand met.", val.planet.displayName, (int)(num.Value * 100.0)), "ui-error", 0); } warned = flag; } } public static class StationAlert { public static ConfigEntry<bool> Enabled; private static HashSet<string> short_ = new HashSet<string>(); private static GameData data; public static void Tick() { if (!Enabled.Value || Time.frameCount % 300 != 0) { return; } if (GameMain.data != data) { data = GameMain.data; short_.Clear(); } bool logisticShipWarpDrive = GameMain.history.logisticShipWarpDrive; HashSet<string> hashSet = new HashSet<string>(); List<string> list = new List<string>(); for (int i = 0; i < data.factoryCount; i++) { PlanetFactory val = data.factories[i]; StationComponent[] array = val?.transport?.stationPool; if (array == null) { continue; } for (int j = 1; j < val.transport.stationCursor; j++) { StationComponent val2 = array[j]; if (val2 == null || val2.id != j || !val2.isStellar || val2.isCollector || val2.isVeinCollector) { continue; } string text = ((val2.idleShipCount + val2.workShipCount == 0) ? "vessels" : ((logisticShipWarpDrive && val2.warperCount == 0) ? "warpers" : null)); if (text != null) { string item = val.planetId + "/" + j + "/" + text; hashSet.Add(item); if (!short_.Contains(item)) { list.Add(Name(val, val2) + " (" + Lang.T(text) + ")"); } } } } short_ = hashSet; string text2 = string.Join(", ", list.Take(3).ToArray()); if (list.Count > 3) { text2 = Lang.F("{0} and {1} more", text2, list.Count - 3); } if (list.Count > 0) { UIRealtimeTip.Popup(Lang.F("Out of stock: {0}.", text2), "ui-error", 0); } } private static string Name(PlanetFactory factory, StationComponent s) { string text = factory.ReadExtraInfoOnEntity(s.entityId); if (!string.IsNullOrEmpty(text)) { return text; } return factory.planet.displayName + " #" + s.id; } } public static class AutoUpgrade { public static string Run() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) Player player = GameMain.mainPlayer; Player obj = player; PlanetFactory val = ((obj != null) ? obj.factory : null); Player obj2 = player; PlayerAction_Build val2 = ((obj2 == null) ? null : obj2.controller?.actionBuild); if (val == null || GameMain.localPlanet?.factory != val || player.package == null || val2 == null) { return Lang.T("Land on a planet first."); } GameHistoryData history = GameMain.history; float buildArea = player.mecha.buildArea; float num = buildArea * buildArea; Vector3 position = player.position; EntityData[] entityPool = val.entityPool; int num2 = 0; bool flag = false; int num4 = default(int); for (int i = 1; i < val.entityCursor; i++) { if (entityPool[i].id != i || (entityPool[i].beltId == 0 && entityPool[i].inserterId == 0)) { continue; } Vector3 val3 = entityPool[i].pos - position; if (((Vector3)(ref val3)).sqrMagnitude > num) { continue; } ItemProto val4 = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)entityPool[i].protoId); if (val4 == null || !val4.canUpgrade) { continue; } int num3 = BestGrade(val4.Grade, val4.Upgrades, (int num5) => history.ItemUnlocked(num5) ? player.package.GetItemCount(num5) : 0); if (num3 != val4.Grade) { if (player.package.isFull) { flag = true; break; } if (val2.DoUpgradeObject(i, num3, 0, ref num4)) { num2++; } } } if (num2 != 0 || flag) { return Lang.F(flag ? "Upgrade: {0} upgraded; stopped, inventory full." : "Upgrade: {0} upgraded.", num2); } return Lang.T("Upgrade: nothing to upgrade in range."); } public static int BestGrade(int grade, int[] upgrades, Func<int, int> count) { for (int num = upgrades.Length; num > grade; num--) { if (upgrades[num - 1] != 0 && count(upgrades[num - 1]) > 0) { return num; } } return grade; } } public static class BeltCounter { public static ConfigEntry<bool> Enabled; private static Text label; public static string Line(string item, int carried, int placing) { if (placing <= 0) { return Lang.F("{0}: {1} carried", item, carried); } return Lang.F("{0}: {1} to place, {2} carried", item, placing, carried) + ((placing > carried) ? Lang.F(" ({0} short)", placing - carried) : ""); } public static void Tick() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) string text = (Enabled.Value ? Current() : null); if (text == null) { Hide(); return; } if ((Object)(object)label == (Object)null) { Build(); } label.text = text; Vector2 val = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Component)label).transform.parent, Vector2.op_Implicit(Input.mousePosition), UIRoot.instance.overlayCanvas.worldCamera, ref val)) { ((Transform)((Graphic)label).rectTransform).localPosition = Vector2.op_Implicit(val + new Vector2(24f, -24f)); } ((Component)label).gameObject.SetActive(true); } public static void Hide() { if ((Object)(object)label != (Object)null) { ((Component)label).gameObject.SetActive(false); } } private static string Current() { Player mainPlayer = GameMain.mainPlayer; PlayerAction_Build val = ((mainPlayer == null) ? null : mainPlayer.controller?.actionBuild); if (val == null || mainPlayer.controller.cmd.mode != 1 || mainPlayer.package == null) { return null; } ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(mainPlayer.controller.cmd.refId); if (val2 == null) { return null; } int carried = mainPlayer.package.GetItemCount(((Proto)val2).ID) + ((mainPlayer.inhandItemId == ((Proto)val2).ID) ? mainPlayer.inhandItemCount : 0); int num = 0; BuildTool activeTool = val.activeTool; BuildTool_Path val3 = (BuildTool_Path)(object)((activeTool is BuildTool_Path) ? activeTool : null); if (val3 != null && ((BuildTool)val3).buildPreviews != null) { foreach (BuildPreview buildPreview in ((BuildTool)val3).buildPreviews) { if (buildPreview.item == val2 && buildPreview.coverObjId == 0) { num++; } } } return Line(((Proto)val2).name, carried, num); } private static void Build() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_00ab: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Component)UIRoot.instance.uiGame.generatorWindow).transform.parent; label = Ui.NewText(Ui.ValueTpl, parent, Vector2.zero, new Vector2(320f, 22f), (TextAnchor)0, ""); ((Object)label).name = "bug-build-counter"; ((Component)label).transform.SetAsLastSibling(); ((Graphic)label).color = Ui.Ink; label.fontSize = 14; label.horizontalOverflow = (HorizontalWrapMode)1; ((Shadow)((Component)label).gameObject.AddComponent<Outline>()).effectColor = new Color(0f, 0f, 0f, 0.85f); } } public enum Language { English, Chinese, Turkish } public static class Lang { public static Language Current = Language.English; private static readonly Dictionary<string, string[]> texts = new Dictionary<string, string[]> { ["One-time actions"] = new string[2] { "一次性操作", "Tek seferlik işlemler" }, ["Always on"] = new string[2] { "持续生效", "Sürekli aktif işlemler" }, ["Apply"] = new string[2] { "应用", "Uygula" }, ["Apply all"] = new string[2] { "全部应用", "Tümünü uygula" }, ["ON"] = new string[2] { "开", "AÇIK" }, ["OFF"] = new string[2] { "关", "KAPALI" }, ["{0} opens this panel. Actions work within your construction range; switches and the language are kept in the config file."] = new string[2] { "{0} 打开此面板。操作在建造范围内生效;开关和语言保存在配置文件中。", "{0} bu paneli açar. İşlemler inşa menzilin içinde çalışır; anahtarlar ve dil yapılandırma dosyasında saklanır." }, ["Upgrade in range"] = new string[2] { "范围内升级", "Menzilde yükselt" }, ["Belts and sorters in construction range become the best tier you carry; the old ones go back to your inventory."] = new string[2] { "建造范围内的传送带和分拣器升级为你携带的最高等级;旧的返回背包。", "İnşa menzilindeki bant ve sorterlar taşıdığın en iyi seviyeye yükselir; eskileri envantere döner." }, ["Fill stations in range"] = new string[2] { "填充范围内物流站", "Menzildeki istasyonları doldur" }, ["Logistics drones, vessels and space warpers from your inventory into the stations in range, up to their capacity."] = new string[2] { "把背包中的物流无人机、物流运输船和空间翘曲器放入范围内的物流站,直到上限。", "Envanterdeki lojistik dron, gemi ve warper'lar menzildeki istasyonlara kapasiteleri kadar konur." }, ["Fuel generators in range"] = new string[2] { "为范围内发电机加燃料", "Menzildeki jeneratörlere yakıt koy" }, ["Tops up the fuel of burning generators in range; an empty one gets the fitting fuel you carry most of."] = new string[2] { "补满范围内燃料发电机的燃料;空的发电机放入你携带最多的适用燃料。", "Menzildeki yakıtlı jeneratörlerin yakıtını tamamlar; boş olana en çok taşıdığın uygun yakıt konur." }, ["Clear ruins in range"] = new string[2] { "清除范围内废墟", "Menzildeki kalıntıları temizle" }, ["Removes the rubble of destroyed buildings, and Dark Fog base remains the game lets you clear. Ruins hold no items."] = new string[2] { "清除被摧毁建筑的废墟,以及游戏允许清除的黑雾基地残骸。废墟不含物品。", "Yıkılan binaların enkazını ve oyunun izin verdiği Kara Sis üs kalıntılarını kaldırır. Kalıntılardan eşya çıkmaz." }, ["Storage limit in range"] = new string[2] { "范围内储物仓限制", "Menzildeki depo sınırı" }, ["Sets the red limit bar of every storage in range to the number of open slots typed here; 0 removes it."] = new string[2] { "把范围内每个储物仓的红色限制条设为此处输入的开放格数;0 为取消限制。", "Menzildeki her deponun kırmızı sınır çubuğunu buraya yazılan açık slot sayısına çeker; 0 sınırı kaldırır." }, ["Pick up drops in range"] = new string[2] { "拾取范围内掉落物", "Menzildeki ganimeti topla" }, ["Items on the ground in construction range fly to you. ON: by itself, as the item filter allows; OFF: with Apply."] = new string[2] { "建造范围内地上的物品飞向你。开:按拾取筛选自动拾取;关:点击应用拾取。", "İnşa menzilindeki yerdeki eşyalar sana uçar. AÇIK: toplama filtresine göre kendiliğinden; KAPALI: Uygula ile." }, ["Item filter:"] = new string[2] { "拾取筛选:", "Toplama filtresi:" }, ["Pick all"] = new string[2] { "全部拾取", "Hepsini topla" }, ["Pick none"] = new string[2] { "全不拾取", "Hiçbirini toplama" }, ["Invert"] = new string[2] { "反选", "Tersine çevir" }, ["Random"] = new string[2] { "随机", "Rastgele" }, ["Item filter: every item is picked up automatically."] = new string[2] { "拾取筛选:所有物品自动拾取。", "Toplama filtresi: tüm eşyalar otomatik toplanır." }, ["Item filter: no item is picked up."] = new string[2] { "拾取筛选:不拾取任何物品。", "Toplama filtresi: hiçbir eşya toplanmaz." }, ["Item filter: inverted; the rest is picked up automatically."] = new string[2] { "拾取筛选:已反选;其余物品自动拾取。", "Toplama filtresi: tersine çevrildi; diğerleri otomatik toplanır." }, ["Item filter: each item set at random."] = new string[2] { "拾取筛选:每种物品随机设置。", "Toplama filtresi: her eşya rastgele ayarlandı." }, ["Station templates"] = new string[2] { "物流站模板", "İstasyon şablonları" }, ["Save a station's slots, limits and range settings under a name, then apply them to any station of the same type from its window."] = new string[2] { "以名称保存物流站的栏位、上限和范围设置,然后在同类物流站窗口中一键应用。", "Bir istasyonun slot, sınır ve menzil ayarlarını bir adla kaydet, sonra aynı türdeki istasyonlara penceresinden uygula." }, ["Power warning"] = new string[2] { "电力警告", "Güç uyarısı" }, ["A message and a sound when the planet you are on gets less than 90% of the power it needs."] = new string[2] { "所在星球的电力满足率低于 90% 时,显示提示并播放声音。", "Bulunduğun gezegen ihtiyacı olan gücün %90'ından azını aldığında mesaj ve ses verir." }, ["Station stock warning"] = new string[2] { "物流站库存警告", "İstasyon eksik uyarısı" }, ["Names the interstellar station that has run out of vessels, or of warpers while it has vessels."] = new string[2] { "提示运输船用完、或有运输船但翘曲器用完的星际物流站名称。", "Gemisi biten ya da gemisi varken warper'ı biten yıldızlararası istasyonun adını söyler." }, ["Build counter"] = new string[2] { "建造计数", "İnşa sayacı" }, ["Beside the cursor while building: how many you carry, and how many a dragged belt line takes."] = new string[2] { "建造时在光标旁显示:携带数量,以及拖动的传送带需要多少。", "İnşa ederken imlecin yanında: kaç tane taşıdığın ve sürüklenen bant hattının kaç parça tuttuğu." }, ["Land on a planet first."] = new string[2] { "请先登陆星球。", "Önce bir gezegene in." }, ["Upgrade: nothing to upgrade in range."] = new string[2] { "升级:范围内没有可升级的。", "Yükseltme: menzilde yükseltilecek bir şey yok." }, ["Upgrade: {0} upgraded."] = new string[2] { "升级:已升级 {0} 个。", "Yükseltme: {0} yükseltildi." }, ["Upgrade: {0} upgraded; stopped, inventory full."] = new string[2] { "升级:已升级 {0} 个;背包已满,已停止。", "Yükseltme: {0} yükseltildi; envanter dolu, durdu." }, ["Stations: nothing to fill (full, or none in your inventory)."] = new string[2] { "物流站:没有可填充的(已满,或背包中没有)。", "İstasyonlar: doldurulacak bir şey yok (dolu ya da envanterde yok)." }, ["Stations: {0} filled with {1} drones, {2} vessels, {3} warpers."] = new string[2] { "物流站:填充了 {0} 座,无人机 {1}、运输船 {2}、翘曲器 {3}。", "İstasyonlar: {0} istasyona {1} dron, {2} gemi, {3} warper kondu." }, ["Generators: nothing to fuel (full, or no fitting fuel carried)."] = new string[2] { "发电机:没有可添加的(已满,或没有适用燃料)。", "Jeneratörler: yakıt konacak yer yok (dolu ya da uygun yakıt yok)." }, ["Generators: {0} fuelled with {1} items."] = new string[2] { "发电机:为 {0} 台添加了 {1} 个燃料。", "Jeneratörler: {0} jeneratöre {1} yakıt kondu." }, ["Ruins: none in range."] = new string[2] { "废墟:范围内没有。", "Kalıntılar: menzilde yok." }, ["Ruins: {0} cleared."] = new string[2] { "废墟:已清除 {0} 处。", "Kalıntılar: {0} temizlendi." }, ["Storage limit: type the number of open slots first (0 removes the limit)."] = new string[2] { "储物仓限制:请先输入开放格数(0 为取消限制)。", "Depo sınırı: önce açık slot sayısını yaz (0 sınırı kaldırır)." }, ["Storage limit: no storage in range."] = new string[2] { "储物仓限制:范围内没有储物仓。", "Depo sınırı: menzilde depo yok." }, ["Storage limit: removed on {0} storages."] = new string[2] { "储物仓限制:已取消 {0} 个储物仓的限制。", "Depo sınırı: {0} depoda kaldırıldı." }, ["Storage limit: {0} storages open {1} slots each."] = new string[2] { "储物仓限制:{0} 个储物仓各开放 {1} 格。", "Depo sınırı: {0} depoda {1} slot açık." }, ["Pickup: nothing to pick up in range."] = new string[2] { "拾取:范围内没有可拾取的物品。", "Toplama: menzilde toplanacak eşya yok." }, ["Pickup: {0} items on their way."] = new string[2] { "拾取:{0} 组物品正在飞来。", "Toplama: {0} eşya yolda." }, ["Left: {0} out of range, {1} kept by the item filter, {2} still falling."] = new string[2] { "剩余:超出范围 {0},被拾取筛选保留 {1},仍在下落 {2}。", "Kalan: {0} menzil dışında, {1} toplama filtresinde, {2} hâlâ düşüyor." }, ["Pickup: inventory full."] = new string[2] { "拾取:背包已满。", "Toplama: envanter dolu." }, ["Low power on {0}: {1}% of demand met."] = new string[2] { "{0} 电力不足:仅满足需求的 {1}%。", "{0} gezegeninde güç düşük: ihtiyacın %{1}'i karşılanıyor." }, ["Out of stock: {0}."] = new string[2] { "库存耗尽:{0}。", "Tükendi: {0}." }, ["{0} and {1} more"] = new string[2] { "{0} 等另外 {1} 座", "{0} ve {1} istasyon daha" }, ["vessels"] = new string[2] { "运输船", "gemi" }, ["warpers"] = new string[2] { "翘曲器", "warper" }, ["{0}: {1} to place, {2} carried"] = new string[2] { "{0}:需放置 {1},携带 {2}", "{0}: {1} yerleştirilecek, {2} taşınıyor" }, ["{0}: {1} carried"] = new string[2] { "{0}:携带 {1}", "{0}: {1} taşınıyor" }, [" ({0} short)"] = new string[2] { "(缺 {0})", " ({0} eksik)" }, ["Template {0}"] = new string[2] { "模板 {0}", "Şablon {0}" }, ["No template for this station type yet."] = new string[2] { "此类物流站还没有模板。", "Bu istasyon türü için henüz şablon yok." }, ["1 template for this station type"] = new string[2] { "此类物流站有 1 个模板", "Bu istasyon türü için 1 şablon" }, ["{0} templates for this station type"] = new string[2] { "此类物流站有 {0} 个模板", "Bu istasyon türü için {0} şablon" }, ["Template saved: {0}"] = new string[2] { "模板已保存:{0}", "Şablon kaydedildi: {0}" }, ["Template applied: {0}"] = new string[2] { "模板已应用:{0}", "Şablon uygulandı: {0}" }, ["Save"] = new string[2] { "保存", "Kaydet" }, ["Fold or unfold"] = new string[2] { "折叠或展开", "Daralt veya genişlet" }, ["Shows one template, or the whole list."] = new string[2] { "只显示一个模板,或显示全部。", "Tek şablonu ya da tüm listeyi gösterir." }, ["Apply template"] = new string[2] { "应用模板", "Şablonu uygula" }, ["Sets this station's items, limits, slot directions and range settings."] = new string[2] { "设置此物流站的物品、上限、栏位方向和范围。", "Bu istasyonun eşyalarını, sınırlarını, slot yönlerini ve menzil ayarlarını uygular." }, ["Delete template"] = new string[2] { "删除模板", "Şablonu sil" } }; public static IEnumerable<KeyValuePair<string, string[]>> All => texts; public static string T(string english) { if (Current == Language.English || !texts.TryGetValue(english, out var value)) { return english; } return value[(int)(Current - 1)]; } public static string F(string english, params object[] args) { return string.Format(CultureInfo.InvariantCulture, T(english), args); } } public static class LootPickup { public enum FilterMode { All, None, Invert, Random } public static ConfigEntry<bool> Enabled; public static string Run() { string why; int far; int kept; int falling; int num = Pick(manual: true, out why, out far, out kept, out falling); if (why != null) { return why; } string text = ((num == 0) ? Lang.T("Pickup: nothing to pick up in range.") : Lang.F("Pickup: {0} items on their way.", num)); if (far + kept + falling > 0) { text = text + " " + Lang.F("Left: {0} out of range, {1} kept by the item filter, {2} still falling.", far, kept, falling); } return text; } public static void Tick() { if (Enabled.Value && Time.frameCount % 30 == 0) { Pick(manual: false, out var _, out var _, out var _, out var _); } } public static int Next(FilterMode mode, int? current, Random random) { return mode switch { FilterMode.Invert => (current != 1) ? 1 : 0, FilterMode.None => 0, FilterMode.All => 1, _ => random.Next(2), }; } public static string SetFilter(FilterMode mode) { Player mainPlayer = GameMain.mainPlayer; Dictionary<int, int> dictionary = ((mainPlayer == null) ? null : mainPlayer.controller?.actionPick?.pickFilters); if (dictionary == null) { return Lang.T("Land on a planet first."); } Random random = new Random(); ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray; foreach (ItemProto val in dataArray) { if (val != null) { int value; int? current = (dictionary.TryGetValue(((Proto)val).ID, out value) ? new int?(value) : ((int?)null)); dictionary[((Proto)val).ID] = Next(mode, current, random); } } UILootFilter lootFilter = UIRoot.instance.uiGame.lootFilter; if ((Object)(object)lootFilter != (Object)null && ((ManualBehaviour)lootFilter).active) { Traverse val2 = Traverse.Create((object)lootFilter); string[] array = new string[4] { "GetFilterSettings", "RefreshIcons", "SetBufferData", "SetMaterialProps" }; foreach (string text in array) { val2.Method(text, Array.Empty<object>()).GetValue(); } } return Lang.T(mode switch { FilterMode.Invert => "Item filter: inverted; the rest is picked up automatically.", FilterMode.None => "Item filter: no item is picked up.", FilterMode.All => "Item filter: every item is picked up automatically.", _ => "Item filter: each item set at random.", }); } public static bool Wanted(int item, int? filter, bool manual) { if (!manual) { if (item != 1099) { return filter == 1; } return true; } return filter != 0; } private static int Pick(bool manual, out string why, out int far, out int kept, out int falling) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0195: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) why = null; far = (kept = (falling = 0)); Player mainPlayer = GameMain.mainPlayer; PlanetData localPlanet = GameMain.localPlanet; TrashContainer val = GameMain.data?.trashSystem?.container; if (mainPlayer == null || localPlanet == null || val == null || mainPlayer.package == null || !mainPlayer.isAlive) { why = Lang.T("Land on a planet first."); return 0; } if (mainPlayer.package.isFull) { why = Lang.T("Pickup: inventory full."); return 0; } Dictionary<int, int> dictionary = mainPlayer.controller?.actionPick?.pickFilters; float num = mainPlayer.mecha.buildArea * mainPlayer.mecha.buildArea; Vector3 position = mainPlayer.position; TrashObject[] trashObjPool = val.trashObjPool; TrashData[] trashDataPool = val.trashDataPool; int num2 = 0; for (int i = 0; i < val.trashCursor; i++) { int item = trashObjPool[i].item; if (item <= 0 || trashObjPool[i].expire >= 0) { continue; } if (trashDataPool[i].landPlanetId != localPlanet.astroId) { if (trashDataPool[i].landPlanetId == 0 && trashDataPool[i].nearPlanetId == localPlanet.id) { falling++; } continue; } int value; int? filter = ((dictionary != null && dictionary.TryGetValue(item, out value)) ? new int?(value) : ((int?)null)); if (!Wanted(item, filter, manual)) { kept++; continue; } Vector3 val2 = trashObjPool[i].rPos - position; if (((Vector3)(ref val2)).sqrMagnitude > num) { far++; continue; } trashObjPool[i].expire = 35; num2++; } if (num2 > 0) { VFAudio.Create("knock-1", mainPlayer.transform, Vector3.zero, true, 3, -1, -1L); } return num2; } } public class Feature { public string Name; public string Description; public ConfigEntry<bool> Enabled; public Func<string> Run; public ConfigEntry<string> Value; public string RowLabel; public KeyValuePair<string, Func<string>>[] Row; public bool OneTime => Enabled == null; } [BepInPlugin("bug.dsp.basicmodpack", "BUG_BasicModPack", "1.0.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static Func<string> <0>__Run; public static Func<string> <1>__FillStations; public static Func<string> <2>__FuelGenerators; public static Func<string> <3>__ClearRuins; public static Func<string> <4>__Run; public static Func<Feature, bool> <5>__Applicable; public static UnityAction <6>__ApplyAll; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<string> <>9__9_1; public static Func<string> <>9__9_2; public static Func<string> <>9__9_3; public static Func<string> <>9__9_4; public static Func<Feature, string> <>9__17_0; public static UnityAction <>9__20_0; public static Func<Feature, bool> <>9__20_9; public static Func<Feature, bool> <>9__20_10; internal string <Awake>b__9_1() { return LootPickup.SetFilter(LootPickup.FilterMode.All); } internal string <Awake>b__9_2() { return LootPickup.SetFilter(LootPickup.FilterMode.None); } internal string <Awake>b__9_3() { return LootPickup.SetFilter(LootPickup.FilterMode.Invert); } internal string <Awake>b__9_4() { return LootPickup.SetFilter(LootPickup.FilterMode.Random); } internal string <ApplyAll>b__17_0(Feature f) { return f.Run(); } internal void <Build>b__20_0() { KeepPosition(); win.SetActive(false); } internal bool <Build>b__20_9(Feature f) { return f.OneTime; } internal bool <Build>b__20_10(Feature f) { return !f.OneTime; } } public const string Guid = "bug.dsp.basicmodpack"; public static readonly List<Feature> Features = new List<Feature>(); private static ConfigEntry<KeyboardShortcut> hotkey; private static ConfigEntry<Language> language; private static ConfigEntry<string> panelPosition; private static GameObject win; private static readonly Dictionary<Feature, UIButton> switches = new Dictionary<Feature, UIButton>(); private static readonly Dictionary<Feature, UIButton> applies = new Dictionary<Feature, UIButton>(); private static readonly Dictionary<Language, UIButton> languageButtons = new Dictionary<Language, UIButton>(); private static bool InGame { get { if (GameMain.isRunning && !DSPGame.IsMenuDemo) { return GameMain.mainPlayer != null; } return false; } } private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Hotkey", new KeyboardShortcut((KeyCode)98, (KeyCode[])(object)new KeyCode[2] { (KeyCode)306, (KeyCode)304 }), "Opens and closes the mod pack panel."); language = ((BaseUnityPlugin)this).Config.Bind<Language>("General", "Language", Language.English, "Language of the pack's texts; also chosen on the panel."); Lang.Current = language.Value; panelPosition = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PanelPosition", "", "Where the panel was last left (x,y); empty: the default place."); Add("Upgrade in range", "Belts and sorters in construction range become the best tier you carry; the old ones go back to your inventory.", AutoUpgrade.Run); Add("Fill stations in range", "Logistics drones, vessels and space warpers from your inventory into the stations in range, up to their capacity.", RangeActions.FillStations); Add("Fuel generators in range", "Tops up the fuel of burning generators in range; an empty one gets the fitting fuel you carry most of.", RangeActions.FuelGenerators); Add("Clear ruins in range", "Removes the rubble of destroyed buildings, and Dark Fog base remains the game lets you clear. Ruins hold no items.", RangeActions.ClearRuins); Feature limit = Add("Storage limit in range", "Sets the red limit bar of every storage in range to the number of open slots typed here; 0 removes it.", null); limit.Value = ((BaseUnityPlugin)this).Config.Bind<string>("Features", "Storage limit slots", "", "Open slots that \"Storage limit in range\" sets; 0 removes the limit."); limit.Run = () => RangeActions.StorageLimit(limit.Value.Value); Feature feature = Switch("Pick up drops in range", "Items on the ground in construction range fly to you. ON: by itself, as the item filter allows; OFF: with Apply.", LootPickup.Run, on: false); LootPickup.Enabled = feature.Enabled; feature.RowLabel = "Item filter:"; feature.Row = new KeyValuePair<string, Func<string>>[4] { new KeyValuePair<string, Func<string>>("Pick all", () => LootPickup.SetFilter(LootPickup.FilterMode.All)), new KeyValuePair<string, Func<string>>("Pick none", () => LootPickup.SetFilter(LootPickup.FilterMode.None)), new KeyValuePair<string, Func<string>>("Invert", () => LootPickup.SetFilter(LootPickup.FilterMode.Invert)), new KeyValuePair<string, Func<string>>("Random", () => LootPickup.SetFilter(LootPickup.FilterMode.Random)) }; StationTemplates.Bind(((BaseUnityPlugin)this).Config); StationTemplates.Enabled = Switch("Station templates", "Save a station's slots, limits and range settings under a name, then apply them to any station of the same type from its window.").Enabled; PowerAlert.Enabled = Switch("Power warning", "A message and a sound when the planet you are on gets less than 90% of the power it needs.").Enabled; StationAlert.Enabled = Switch("Station stock warning", "Names the interstellar station that has run out of vessels, or of warpers while it has vessels.").Enabled; BeltCounter.Enabled = Switch("Build counter", "Beside the cursor while building: how many you carry, and how many a dragged belt line takes.").Enabled; } private Feature Add(string name, string description, Func<string> run) { Feature feature = new Feature { Name = name, Description = description, Run = run }; Features.Add(feature); return feature; } private Feature Switch(string name, string description, Func<string> run = null, bool on = true) { Feature feature = Add(name, description, run); feature.Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Features", name, on, description); return feature; } private void Update() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!InGame || GameMain.isPaused || !((ManualBehaviour)UIRoot.instance.uiGame).active) { if ((Object)(object)win != (Object)null) { win.SetActive(false); } BeltCounter.Hide(); return; } KeyboardShortcut value = hotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown() && !VFInput.inputing) { if ((Object)(object)win == (Object)null) { Build(); } if (win.activeSelf) { KeepPosition(); } win.SetActive(!win.activeSelf); if (win.activeSelf) { win.transform.SetAsLastSibling(); Show(); } } StationTemplates.Tick(); PowerAlert.Tick(); StationAlert.Tick(); BeltCounter.Tick(); LootPickup.Tick(); } private static void Show() { foreach (KeyValuePair<Feature, UIButton> @switch in switches) { bool value = @switch.Key.Enabled.Value; @switch.Value.highlighted = value; ((Component)@switch.Value).GetComponentInChildren<Text>().text = Lang.T(value ? "ON" : "OFF"); if (applies.TryGetValue(@switch.Key, out var value2)) { ((Component)value2).gameObject.SetActive(!value); } } foreach (KeyValuePair<Language, UIButton> languageButton in languageButtons) { languageButton.Value.highlighted = languageButton.Key == Lang.Current; } } private static bool Applicable(Feature f) { if (f.Run != null && (f.Enabled == null || !f.Enabled.Value)) { if (f.Value != null) { return f.Value.Value.Trim().Length > 0; } return true; } return false; } private static void ApplyAll() { UIRealtimeTip.Popup(string.Join("\n", (from f in Features.Where(Applicable) select f.Run()).ToArray()), true, 0); } private static void SetLanguage(Language l) { if (l != Lang.Current) { language.Value = (Lang.Current = l); KeepPosition(); Object.Destroy((Object)(object)win); Build(); win.SetActive(true); win.transform.SetAsLastSibling(); Show(); StationTemplates.Rebuild(); } } private static void KeepPosition() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)win != (Object)null) { panelPosition.Value = StationTemplates.FormatPosition(((RectTransform)win.transform).anchoredPosition); } } private static void Build() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_0150: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_0328: 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_034f: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) object obj = <>c.<>9__20_0; if (obj == null) { UnityAction val = delegate { KeepPosition(); win.SetActive(false); }; <>c.<>9__20_0 = val; obj = (object)val; } win = Ui.Window("BUG Basic Mod Pack", 580f, (UnityAction)obj); RectTransform root = (RectTransform)win.transform; switches.Clear(); applies.Clear(); languageButtons.Clear(); Image obj2 = Ui.Card((Transform)(object)root, Vector2.zero, new Vector2(500f, 36f), Color.clear); ((Graphic)obj2).raycastTarget = true; ((Component)obj2).gameObject.AddComponent<DragHandle>().Moved = delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) panelPosition.Value = StationTemplates.FormatPosition(root.anchoredPosition); }; if (StationTemplates.ParsePosition(panelPosition.Value, out var p)) { root.anchoredPosition = p; } string[] array = new string[3] { "EN", "中文", "TR" }; Language[] array2 = new Language[3] { Language.English, Language.Turkish, Language.Chinese }; foreach (Language language in array2) { int num2 = language switch { Language.Turkish => 1, Language.English => 0, _ => 2, }; Language lang = language; languageButtons[language] = Ui.NewButton((Transform)(object)root, new Vector2(215f + (float)num2 * 50f, -40f), new Vector2(46f, 22f), array[(int)language], (UnityAction)delegate { SetLanguage(lang); }); } ScrollRect val2 = Ui.ScrollArea((Transform)(object)root, new Vector2(24f, -70f), 532f, 40f); RectTransform content = val2.content; float y = 0f; object obj3 = <>O.<6>__ApplyAll; if (obj3 == null) { UnityAction val3 = ApplyAll; <>O.<6>__ApplyAll = val3; obj3 = (object)val3; } Heading("One-time actions", "Apply all", (UnityAction)obj3); foreach (Feature item in Features.Where((Feature f) => f.OneTime)) { Card(item); } y -= 8f; Heading("Always on", null, null); foreach (Feature item2 in Features.Where((Feature f) => !f.OneTime)) { Card(item2); } float num3 = 0f - y - 6f; content.sizeDelta = new Vector2(0f, num3); float num4 = Mathf.Min(num3, 560f); Ui.SizeScrollArea(val2, num4); float num5 = -70f - num4 - 10f; Text obj4 = Ui.NewText(Ui.LabelTpl, (Transform)(object)root, new Vector2(24f, num5), new Vector2(532f, 0f), (TextAnchor)0, Lang.F("{0} opens this panel. Actions work within your construction range; switches and the language are kept in the config file.", hotkey.Value)); obj4.fontSize = 12; obj4.horizontalOverflow = (HorizontalWrapMode)0; float num6 = Ui.TextHeight(obj4, 532f); ((Graphic)obj4).rectTransform.sizeDelta = new Vector2(532f, num6); root.sizeDelta = new Vector2(580f, 0f - num5 + num6 + 24f); win.SetActive(false); void Card(Feature f) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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_01db: Expected O, but got Unknown //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_028b: 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_02ab: Expected O, but got Unknown //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Expected O, but got Unknown bool flag = f.Run != null && f.Enabled != null; float num7 = 98f + ((f.Value != null) ? 72f : 0f) + (flag ? 96f : 0f); float num8 = 522f - num7 - 10f; Image val4 = Ui.Card((Transform)(object)content, new Vector2(0f, y), new Vector2(532f, 60f), Ui.Well); Text obj5 = Ui.NewText(Ui.ValueTpl, (Transform)(object)content, new Vector2(10f, y - 6f), new Vector2(num8, 22f), (TextAnchor)3, Lang.T(f.Name)); ((Graphic)obj5).color = Ui.Ink; obj5.fontSize = 16; Text obj6 = Ui.NewText(Ui.LabelTpl, (Transform)(object)content, new Vector2(10f, y - 27f), new Vector2(num8, 0f), (TextAnchor)0, Lang.T(f.Description)); obj6.horizontalOverflow = (HorizontalWrapMode)0; obj6.fontSize = 12; float num9 = Ui.TextHeight(obj6, num8); ((Graphic)obj6).rectTransform.sizeDelta = new Vector2(num8, num9); float num10 = Mathf.Max(60f, 27f + num9 + 4f); Vector2 val5 = default(Vector2); ((Vector2)(ref val5))..ctor(434f, y - (num10 - 28f) / 2f); if (f.Enabled != null) { switches[f] = Ui.NewButton((Transform)(object)content, val5, new Vector2(88f, 28f), "", (UnityAction)delegate { f.Enabled.Value = !f.Enabled.Value; Show(); }); val5.x -= 96f; } if (f.Value != null) { InputField obj7 = Ui.NewInput((Transform)(object)content, val5 - new Vector2(72f, 0f), new Vector2(64f, 28f), 4); obj7.contentType = (ContentType)2; obj7.text = f.Value.Value; ((UnityEvent<string>)(object)obj7.onEndEdit).AddListener((UnityAction<string>)delegate(string v) { f.Value.Value = v.Trim(); }); } if (f.Run != null) { applies[f] = Ui.NewButton((Transform)(object)content, val5, new Vector2(88f, 28f), Lang.T("Apply"), (UnityAction)delegate { UIRealtimeTip.Popup(f.Run(), true, 0); }); } float num11 = num10; if (f.Row != null) { float num12 = y - num10; Ui.NewText(Ui.LabelTpl, (Transform)(object)content, new Vector2(10f, num12), new Vector2(120f, 24f), (TextAnchor)3, Lang.T(f.RowLabel)).fontSize = 12; float num13 = (392f - (float)(f.Row.Length - 1) * 6f) / (float)f.Row.Length; for (int num14 = 0; num14 < f.Row.Length; num14++) { Func<string> run = f.Row[num14].Value; Ui.NewButton((Transform)(object)content, new Vector2(130f + (float)num14 * (num13 + 6f), num12), new Vector2(num13, 24f), Lang.T(f.Row[num14].Key), (UnityAction)delegate { UIRealtimeTip.Popup(run(), true, 0); }); } num11 += 32f; } ((Graphic)val4).rectTransform.sizeDelta = new Vector2(532f, num11); y -= num11 + 6f; } void Heading(string title, string buttonLabel, UnityAction onClick) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0071: Unknown result type (might be due to invalid IL or missing references) Text obj5 = Ui.NewText(Ui.ValueTpl, (Transform)(object)content, new Vector2(2f, y), new Vector2(444f, 26f), (TextAnchor)3, Lang.T(title)); ((Graphic)obj5).color = Ui.Accent; obj5.fontSize = 15; if (onClick != null) { Ui.NewButton((Transform)(object)content, new Vector2(434f, y - 1f), new Vector2(88f, 24f), Lang.T(buttonLabel), onClick); } y -= 30f; } } } public static class RangeActions { public const string NotLanded = "Land on a planet first."; private static bool Here(out Player player, out PlanetFactory factory, out Func<Vector3, bool> inRange) { //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) player = GameMain.mainPlayer; Player obj = player; factory = ((obj != null) ? obj.factory : null); inRange = null; if (factory == null || GameMain.localPlanet?.factory != factory || player.package == null) { return false; } float range2 = player.mecha.buildArea * player.mecha.buildArea; Vector3 at = player.position; inRange = delegate(Vector3 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pos - at; return ((Vector3)(ref val)).sqrMagnitude <= range2; }; return true; } private static int Take(Player player, int item, int want, out int inc) { inc = 0; if (want <= 0) { return 0; } int num = item; int result = want; player.package.TakeTailItems(ref num, ref result, ref inc, false); if (num != item) { return 0; } return result; } public static string FillStations() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (!Here(out var player, out var factory, out var inRange)) { return Lang.T("Land on a planet first."); } bool logisticShipWarpDrive = GameMain.history.logisticShipWarpDrive; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; StationComponent[] stationPool = factory.transport.stationPool; for (int i = 1; i < factory.transport.stationCursor; i++) { StationComponent val = stationPool[i]; if (val == null || val.id != i || val.isCollector || val.isVeinCollector || !inRange(factory.entityPool[val.entityId].pos)) { continue; } int num5 = num + num2 + num3; int num6 = Take(player, 5001, val.workDroneDatas.Length - val.workDroneCount - val.idleDroneCount, out var inc); val.idleDroneCount += num6; num += num6; if (val.isStellar) { num6 = Take(player, 5002, val.workShipDatas.Length - val.workShipCount - val.idleShipCount, out inc); val.idleShipCount += num6; num2 += num6; if (logisticShipWarpDrive) { num6 = Take(player, 1210, val.warperMaxCount - val.warperCount, out inc); val.warperCount += num6; num3 += num6; } } if (num + num2 + num3 > num5) { num4++; } } if (num4 != 0) { return Lang.F("Stations: {0} filled with {1} drones, {2} vessels, {3} warpers.", num4, num, num2, num3); } return Lang.T("Stations: nothing to fill (full, or none in your inventory)."); } public static string FuelGenerators() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (!Here(out var player, out var factory, out var inRange)) { return Lang.T("Land on a planet first."); } PowerGeneratorComponent[] genPool = factory.powerSystem.genPool; int num = 0; int num2 = 0; for (int i = 1; i < factory.powerSystem.genCursor; i++) { ref PowerGeneratorComponent reference = ref genPool[i]; if (reference.id != i || reference.fuelMask == 0 || reference.gamma || reference.wind || reference.photovoltaic || !inRange(factory.entityPool[reference.entityId].pos)) { continue; } int num3 = reference.fuelId; if (num3 == 0) { int[] array = ItemProto.fuelNeeds[reference.fuelMask]; if (array == null) { continue; } num3 = Most(array, (Func<int, int>)player.package.GetItemCount); if (num3 == 0) { continue; } } ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(num3); int inc; int num4 = Take(player, num3, (val?.StackSize ?? 0) - reference.fuelCount, out inc); if (num4 != 0) { if (reference.fuelId == 0) { ((PowerGeneratorComponent)(ref reference)).SetNewFuel(num3, (short)num4, (short)inc); } else { reference.fuelCount += (short)num4; reference.fuelInc += (short)inc; } num++; num2 += num4; } } if (num != 0) { return Lang.F("Generators: {0} fuelled with {1} items.", num, num2); } return Lang.T("Generators: nothing to fuel (full, or no fitting fuel carried)."); } public static int Most(int[] ids, Func<int, int> count) { int result = 0; int num = 0; foreach (int num2 in ids) { int num3 = count(num2); if (num3 > num) { num = num3; result = num2; } } return result; } public static string ClearRuins() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (!Here(out var _, out var factory, out var inRange)) { return Lang.T("Land on a planet first."); } HashSet<int> removableDFGBaseRuinIds = factory.GetRemovableDFGBaseRuinIds(); int num = 0; for (int i = 1; i < factory.ruinCursor; i++) { RuinData val = factory.ruinPool[i]; if (val.id == i && inRange(val.pos) && (val.modelIndex != 406 || removableDFGBaseRuinIds.Contains(i))) { factory.RemoveRuinWithComponet(i); num++; } } if (num != 0) { return Lang.F("Ruins: {0} cleared.", num); } return Lang.T("Ruins: none in range."); } public static string StorageLimit(string value) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (!Here(out var _, out var factory, out var inRange)) { return Lang.T("Land on a planet first."); } if (!int.TryParse(value?.Trim(), out var result) || result < 0) { return Lang.T("Storage limit: type the number of open slots first (0 removes the limit)."); } StorageComponent[] storagePool = factory.factoryStorage.storagePool; int num = 0; for (int i = 1; i < factory.factoryStorage.storageCursor; i++) { StorageComponent val = storagePool[i]; if (val != null && val.id == i && factory.entityPool[val.entityId].battleBaseId == 0 && inRange(factory.entityPool[val.entityId].pos)) { val.SetBans((result != 0) ? (val.size - result) : 0); num++; } } if (num != 0) { if (result != 0) { return Lang.F("Storage limit: {0} storages open {1} slots each.", num, result); } return Lang.F("Storage limit: removed on {0} storages.", num); } return Lang.T("Storage limit: no storage in range."); } } public static class StationTemplates { public class Template { public string Name; public int ProtoId; public int[] Params; } [CompilerGenerated] private static class <>O { public static Func<Template, string> <0>__Format; public static UnityAction <1>__Save; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<int, string> <>9__34_0; public static Func<char, bool> <>9__36_0; public static Func<UIButton, bool> <>9__48_0; public static UnityAction <>9__56_0; public static Action <>9__56_1; public static Func<Image, bool> <>9__56_2; public static Action<int> <>9__56_3; internal string <Format>b__34_0(int v) { return v.ToString(); } internal bool <Clean>b__36_0(char c) { if (c != '\t' && c != '\n') { return c != '\r'; } return false; } internal bool <ListCount>b__48_0(UIButton b) { return ((Component)b).gameObject.activeSelf; } internal void <Build>b__56_0() { dismissed = true; win.SetActive(false); } internal void <Build>b__56_1() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) position.Value = FormatPosition(root.anchoredPosition); } internal bool <Build>b__56_2(Image i) { return ((Object)i).name == "mbicon"; } internal void <Build>b__56_3(int _) { folded.Value = !folded.Value; Layout(ListCount()); } } public static ConfigEntry<bool> Enabled; private static ConfigEntry<string> position; private static ConfigEntry<bool> folded; public const int Stored = 384; public const int GameLength = 2048; public const int VisibleRows = 8; private static List<Template> templates; private static GameObject win; private static GameObject body; private static RectTransform root; private static RectTransform viewport; private static RectTransform content; private static ScrollRect scroll; private static InputField nameInput; private static Text infoText; private static RectTransform buttonBox; private static GameObject plusBar; private const float Width = 300f; private const float Pad = 24f; private const float Row = 30f; private const float ListTop = -118f; private const float Bottom = 24f; public const int FoldFrom = 3; private static readonly List<UIButton> applyButtons = new List<UIButton>(); private static readonly List<UIButton> deleteButtons = new List<UIButton>(); private static int shownStation = -1; private static int shownVersion = -1; private static int version; private static bool dismissed; private static bool placed; private static RectTransform barRect; private static string FilePath => Path.Combine(Paths.ConfigPath, "BUG_BasicModPack.templates.txt"); private static UIStationWindow Window => UIRoot.instance.uiGame.stationWindow; public static void Bind(ConfigFile config) { position = config.Bind<string>("Station templates", "WindowPosition", "", "Where the template window was last left (x,y); empty: next to the station window."); folded = config.Bind<bool>("Station templates", "Folded", false, "The template list shows one row (with 3 or more templates)."); } public static string Format(Template t) { return Clean(t.Name) + "\t" + t.ProtoId + "\t" + string.Join(",", (from v in t.Params.Take(384) select v.ToString()).ToArray()); } public static Template Parse(string line) { string[] array = line.Split(new char[1] { '\t' }); if (array.Length != 3 || array[0].Length == 0 || !int.TryParse(array[1], out var result)) { return null; } string[] array2 = array[2].Split(new char[1] { ',' }); int[] array3 = new int[2048]; for (int i = 0; i < array2.Length && i < 384; i++) { if (!int.TryParse(array2[i], out array3[i])) { return null; } } return new Template { Name = array[0], ProtoId = result, Params = array3 }; } public static string Clean(string name) { return new string((name ?? "").Where((char c) => c != '\t' && c != '\n' && c != '\r').ToArray()).Trim(); } public static string FormatPosition(Vector2 p) { return p.x.ToString("0", CultureInfo.InvariantCulture) + "," + p.y.ToString("0", CultureInfo.InvariantCulture); } public static bool ParsePosition(string s, out Vector2 p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) p = Vector2.zero; string[] array = (s ?? "").Split(new char[1] { ',' }); if (array.Length != 2 || !float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || !float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) || float.IsNaN(result) || float.IsNaN(result2)) { return false; } p = new Vector2(result, result2); return true; } public static int Rows(int count, bool fold) { if (!fold || count < 3) { return Math.Max(1, Math.Min(count, 8)); } return 1; } public static float Height(int count, bool fold) { return 118f + (float)Rows(count, fold) * 30f + 24f; } private static List<Template> All() { if (templates != null) { return templates; } templates = new List<Template>(); try { if (File.Exists(FilePath)) { string[] array = File.ReadAllLines(FilePath); for (int i = 0; i < array.Length; i++) { Template template = Parse(array[i]); if (template != null) { templates.Add(template); } } } } catch (Exception ex) { Debug.LogWarning((object)("BUG_BasicModPack: templates not read: " + ex.Message)); } return templates; } private static void Write() { version++; try { string text = FilePath + ".new"; File.WriteAllLines(text, templates.Select(Format).ToArray()); if (File.Exists(FilePath)) { File.Replace(text, FilePath, null); } else { File.Move(text, FilePath); } } catch (Exception ex) { Debug.LogWarning((object)("BUG_BasicModPack: templates not saved: " + ex.Message)); } } private static StationComponent Station(out PlanetFactory factory) { UIStationWindow window = Window; factory = window.factory; if (factory == null || window.stationId <= 0 || window.stationId >= factory.transport.stationCursor) { return null; } StationComponent val = factory.transport.stationPool[window.stationId]; if (val == null || val.id != window.stationId || val.isCollector || val.isVeinCollector) { return null; } return val; } public static void Rebuild() { if ((Object)(object)win != (Object)null) { Object.Destroy((Object)(object)win); } win = null; applyButtons.Clear(); deleteButtons.Clear(); shownStation = -1; placed = false; } public static void Tick() { //IL_0245: Unknown result type (might be due to invalid IL or missing references) UIStationWindow window = Window; PlanetFactory factory = null; StationComponent val = (((Object)(object)window != (Object)null && ((ManualBehaviour)window).active && Enabled.Value) ? Station(out factory) : null); if ((Object)(object)window == (Object)null || !((ManualBehaviour)window).active) { dismissed = false; } if (val == null || dismissed) { if ((Object)(object)win != (Object)null && win.activeSelf) { win.SetActive(false); } shownStation = -1; return; } if ((Object)(object)win == (Object)null) { Build(window); } if (!win.activeSelf) { win.SetActive(true); win.transform.SetAsLastSibling(); if (!placed) { Place(window); } } if (shownStation == val.id && shownVersion == version) { return; } if (shownStation != val.id) { string text = factory.ReadExtraInfoOnEntity(val.entityId); nameInput.text = (string.IsNullOrEmpty(text) ? Lang.F("Template {0}", All().Count + 1) : text); scroll.verticalNormalizedPosition = 1f; } shownStation = val.id; shownVersion = version; int proto = factory.entityPool[val.entityId].protoId; List<Template> list = (from t in All() where t.ProtoId == proto select t).ToList(); while (applyButtons.Count < list.Count) { AddRow(); } for (int num = 0; num < applyButtons.Count; num++) { bool flag = num < list.Count; ((Component)applyButtons[num]).gameObject.SetActive(flag); ((Component)deleteButtons[num]).gameObject.SetActive(flag); if (flag) { ((Component)applyButtons[num]).GetComponentInChildren<Text>().text = list[num].Name; } } content.sizeDelta = new Vector2(0f, (float)list.Count * 30f); infoText.text = ((list.Count == 0) ? Lang.T("No template for this station type yet.") : ((list.Count == 1) ? Lang.T("1 template for this station type") : Lang.F("{0} templates for this station type", list.Count))); Layout(list.Count); } private static int ListCount() { return applyButtons.Count((UIButton b) => ((Component)b).gameObject.activeSelf); } private static void Layout(int count) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) bool value = folded.Value; Ui.OneButton(buttonBox, count < 3); plusBar.SetActive(value); Vector2 val = TopLeft(); root.sizeDelta = new Vector2(300f, Height(count, value)); RectTransform obj = root; obj.anchoredPosition += val - TopLeft(); viewport.sizeDelta = new Vector2(252f, (float)Rows(count, value) * 30f); barRect.sizeDelta = new Vector2(5f, viewport.sizeDelta.y); } private static Vector2 TopLeft() { //IL_001c: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[4]; root.GetWorldCorners(array); return Vector2.op_Implicit(((Transform)(RectTransform)((Transform)root).parent).InverseTransformPoint(array[1])); } private static void Place(UIStationWindow w) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) placed = true; if (ParsePosition(position.Value, out var p)) { root.anchoredPosition = p; return; } Vector3[] array = (Vector3[])(object)new Vector3[4]; Vector3[] array2 = (Vector3[])(object)new Vector3[4]; w.windowTrans.GetWorldCorners(array); root.GetWorldCorners(array2); RectTransform obj = root; ((Transform)obj).position = ((Transform)obj).position + (array[2] - array2[1]); ((Transform)root).localPosition = new Vector3(((Transform)root).localPosition.x + 8f, ((Transform)root).localPosition.y, 0f); } private static List<Template> ForOpenStation(out StationComponent station, out PlanetFactory factory) { station = Station(out factory); if (station == null) { return new List<Template>(); } int proto = factory.entityPool[station.entityId].protoId; return (from t in All() where t.ProtoId == proto select t).ToList(); } private static void Save() { //IL_0036: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) PlanetFactory factory; StationComponent val = Station(out factory); string name = Clean(nameInput.text); if (val == null || name.Length == 0) { return; } BuildingParameters val2 = default(BuildingParameters); if (((BuildingParameters)(ref val2)).CopyFromFactoryObject(val.entityId, factory, false, false) && (int)val2.type == 9 && val2.parameters != null) { int proto = factory.entityPool[val.entityId].protoId; All().RemoveAll((Template t) => t.ProtoId == proto && t.Name == name); templates.Add(new Template { Name = name, ProtoId = proto, Params = val2.parameters }); Write(); UIRealtimeTip.Popup(Lang.F("Template saved: {0}", name), true, 0); } } private static void Apply(int row) { StationComponent station; PlanetFactory factory; List<Template> list = ForOpenStation(out station, out factory); if (row < list.Count) { int[] array = new int[2048]; Array.Copy(list[row].Params, array, Math.Min(list[row].Params.Length, 2048)); BuildingParameters.ApplyPrebuildParametersToEntity(station.entityId, 0, 0, array, (string)null, factory); Window.stationId = Window.stationId; UIRealtimeTip.Popup(Lang.F("Template applied: {0}", list[row].Name), true, 0); } } private static void Delete(int row) { StationComponent station; PlanetFactory factory; List<Template> list = ForOpenStation(out station, out factory); if (row < list.Count) { templates.Remove(list[row]); Write(); } } private static void Build(UIStationWindow w) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_002e: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Expected O, but got Unknown //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Expected O, but got Unknown //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Expected O, but got Unknown //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_030f: 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_035e: 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_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: 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_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Expected O, but got Unknown //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Expected O, but got Unknown string title = Lang.T("Station templates"); object obj = <>c.<>9__56_0; if (obj == null) { UnityAction val = delegate { dismissed = true; win.SetActive(false); }; <>c.<>9__56_0 = val; obj = (object)val; } win = Ui.Window(title, 300f, (UnityAction)obj, keepMenu: true); root = (RectTransform)win.transform; root.sizeDelta = new Vector2(300f, Height(0, fold: false)); Image obj2 = Ui.Card((Transform)(object)root, Vector2.zero, new Vector2(204f, 40f), Color.clear); ((Graphic)obj2).raycastTarget = true; ((Component)obj2).gameObject.AddComponent<DragHandle>().Moved = delegate { //IL_000a: Unknown result type (might be due to invalid IL or missing references) position.Value = FormatPosition(root.anchoredPosition); }; buttonBox = (RectTransform)((Transform)root).Find("panel-bg/btn-box"); Transform val2 = ((Transform)buttonBox).Find("menu-wnd-btn"); Image obj3 = ((Component)val2).GetComponentsInChildren<Image>(true).First((Image i) => ((Object)i).name == "mbicon"); Image component = ((Component)((Transform)buttonBox).Find("close-wnd-btn/x-icon")).GetComponent<Image>(); obj3.sprite = null; ((Graphic)obj3).material = ((Graphic)component).material; ((Graphic)obj3).color = ((Graphic)component).color; ((Graphic)obj3).rectTransform.sizeDelta = new Vector2(12f, 2f); ((Graphic)obj3).rectTransform.anchoredPosition = new Vector2(2f, 0f); Image obj4 = Object.Instantiate<Image>(obj3, ((Component)obj3).transform.parent, false); ((Graphic)obj4).rectTransform.sizeDelta = new Vector2(2f, 12f); plusBar = ((Component)obj4).gameObject; UIGenericMenuButton[] componentsInChildren = ((Component)val2).GetComponentsInChildren<UIGenericMenuButton>(true); for (int num = 0; num < componentsInChildren.Length; num++) { Object.DestroyImmediate((Object)(object)componentsInChildren[num]); } Button[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren<Button>(true); foreach (Button obj5 in componentsInChildren2) { obj5.onClick = new ButtonClickedEvent(); ((Selectable)obj5).interactable = true; } ((Component)val2).GetComponentInChildren<UIButton>(true).onClick += delegate { folded.Value = !folded.Value; Layout(ListCount()); }; UIButton[] componentsInChildren3 = ((Component)val2).GetComponentsInChildren<UIButton>(true); foreach (UIButton obj6 in componentsInChildren3) { obj6.tips.tipTitle = Lang.T("Fold or unfold"); obj6.tips.tipText = Lang.T("Shows one template, or the whole list."); } body = new GameObject("body", new Type[1] { typeof(RectTransform) }); RectTransform val3 = (RectTransform)body.transform; ((Transform)val3).SetParent((Transform)(object)root, false); Ui.Place(val3, Vector2.zero, new Vector2(300f, 0f)); Vector2 size = default(Vector2); ((Vector2)(ref size))..ctor(180f, 26f); nameInput = Ui.NewInput((Transform)(object)val3, new Vector2(24f, -52f), size, 40); Vector2 pos = new Vector2(210f, -52f); Vector2 size2 = new Vector2(66f, 26f); string label = Lang.T("Save"); object obj7 = <>O.<1>__Save; if (obj7 == null) { UnityAction val4 = Save; <>O.<1>__Save = val4; obj7 = (object)val4; } Ui.NewButton((Transform)(object)val3, pos, size2, label, (UnityAction)obj7); infoText = Ui.NewText(Ui.LabelTpl, (Transform)(object)val3, new Vector2(24f, -86f), new Vector2(252f, 22f), (TextAnchor)3, ""); infoText.fontSize = 12; Image val5 = Ui.Card((Transform)(object)val3, new Vector2(24f, -118f), new Vector2(252f, 30f), Color.clear); ((Graphic)val5).raycastTarget = true; viewport = ((Graphic)val5).rectTransform; ((Component)val5).gameObject.AddComponent<RectMask2D>(); content = (RectTransform)new GameObject("content", new Type[1] { typeof(RectTransform) }).transform; ((Transform)content).SetParent((Transform)(object)viewport, false); content.anchorMin = new Vector2(0f, 1f); content.anchorMax = new Vector2(1f, 1f); content.pivot = new Vector2(0.5f, 1f); content.anchoredPosition = Vector2.zero; content.sizeDelta = Vector2.zero; scroll = (ScrollRect)(object)((Component)val5).gameObject.AddComponent<WheelScroll>(); scroll.horizontal = false; scroll.movementType = (MovementType)2; scroll.scrollSensitivity = 30f; scroll.viewport = viewport; scroll.content = content; scroll.verticalScrollbar = Scrollbar(viewport); scroll.verticalScrollbarVisibility = (ScrollbarVisibility)1; applyButtons.Clear(); deleteButtons.Clear(); win.SetActive(false); } private static void AddRow() { //IL_0030: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0066: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown int row = applyButtons.Count; float num = (float)(-row) * 30f; UIButton val = Ui.NewButton((Transform)(object)content, new Vector2(0f, num), new Vector2(220f, 26f), "", (UnityAction)delegate { Apply(row); }); UIButton val2 = Ui.NewButton((Transform)(object)content, new Vector2(224f, num), new Vector2(28f, 26f), "×", (UnityAction)delegate { Delete(row); }); ((Component)val2).GetComponentInChildren<Text>().fontSize = 20; val.tips.tipTitle = Lang.T("Apply template"); val.tips.tipText = Lang.T("Sets this station's items, limits, slot directions and range settings."); val2.tips.tipTitle = Lang.T("Delete template"); applyButtons.Add(val); deleteButtons.Add(val2); } private static Scrollbar Scrollbar(RectTransform viewport) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) //IL_005a: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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) Image obj = Ui.Card(((Transform)viewport).parent, Vector2.zero, Vector2.zero, Ui.Well); ((Graphic)obj).raycastTarget = true; RectTransform rectTransform = ((Graphic)obj).rectTransform; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); rectTransform.pivot = val; Vector2 anchorMin = (rectTransform.anchorMax = val); rectTransform.anchorMin = anchorMin; rectTransform.anchoredPosition = viewport.anchoredPosition + new Vector2(viewport.sizeDelta.x + 4f, 0f); Image val3 = Ui.Card((Transform)(object)rectTransform, Vector2.zero, Vector2.zero, Ui.Soft); ((Graphic)val3).raycastTarget = true; RectTransform rectTransform2 = ((Graphic)val3).rectTransform; rectTransform2.anchorMin = Vector2.zero; rectTransform2.anchorMax = Vector2.one; anchorMin = (rectTransform2.offsetMax = Vector2.zero); rectTransform2.offsetMin = anchorMin; Scrollbar obj2 = ((Component)obj).gameObject.AddComponent<Scrollbar>(); obj2.handleRect = rectTransform2; ((Selectable)obj2).targetGraphic = (Graphic)(object)val3; obj2.direction = (Direction)2; barRect = rectTransform; return obj2; } } public class DragHandle : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { public Action Moved; private RectTransform window; private RectTransform parent; private Vector2 startPointer; private Vector2 startPosition; private bool Local(PointerEventData e, out Vector2 p) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return RectTransformUtility.ScreenPointToLocalPointInRectangle(parent, e.position, e.pressEventCamera, ref p); } public void OnBeginDrag(PointerEventData e) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0033: 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) window = (RectTransform)((Component)this).transform.parent; parent = (RectTransform)((Transform)window).parent; startPosition = window.anchoredPosition; if (!Local(e, out startPointer)) { window = null; } } public void OnDrag(PointerEventData e) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0031: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)window != (Object)null && Local(e, out var p)) { window.anchoredPosition = startPosition + p - startPointer; } } public void OnEndDrag(PointerEventData e) { //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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0119: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)window == (Object)null)) { Rect rect = parent.rect; Vector3[] array = (Vector3[])(object)new Vector3[4]; window.GetWorldCorners(array); Vector2 val = Vector2.op_Implicit(((Transform)parent).InverseTransformPoint(array[1])); Vector2 zero = Vector2.zero; if (val.x < ((Rect)(ref rect)).xMin) { zero.x = ((Rect)(ref rect)).xMin - val.x; } float x = val.x; Rect rect2 = window.rect; if (x + ((Rect)(ref rect2)).width > ((Rect)(ref rect)).xMax) { float num = ((Rect)(ref rect)).xMax - val.x; rect2 = window.rect; zero.x = num - ((Rect)(ref rect2)).width; } if (val.y > ((Rect)(ref rect)).yMax) { zero.y = ((Rect)(ref rect)).yMax - val.y; } if (val.y - 40f < ((Rect)(ref rect)).yMin) { zero.y = ((Rect)(ref rect)).yMin - val.y + 40f; } RectTransform obj = window; obj.anchoredPosition += zero; Moved?.Invoke(); } } } public class WheelScroll : ScrollRect { public override void OnBeginDrag(PointerEventData e) { } public override void OnDrag(PointerEventData e) { } public override void OnEndDrag(PointerEventData e) { } } public static class Ui { public static readonly Color Ink = Color32.op_Implicit(new Color32((byte)232, (byte)246, (byte)252, byte.MaxValue)); public static readonly Color Soft = Color32.op_Implicit(new Color32((byte)176, (byte)208, (byte)220, byte.MaxValue)); public static readonly Color Accent = Color32.op_Implicit(new Color32((byte)253, (byte)150, (byte)94, byte.MaxValue)); public static readonly Color AccentInk = Color32.op_Implicit(new Color32((byte)28, (byte)14, (byte)6, byte.MaxValue)); public static readonly Color Scrim = Color32.op_Implicit(new Color32((byte)4, (byte)22, (byte)30, (byte)168)); public static readonly Color Well = Color32.op_Implicit(new Color32((byte)0, (byte)10, (byte)16, (byte)120)); private static readonly Color[] Glass = (Color[])(object)new Color[4] { Color32.op_Implicit(new Color32((byte)167, (byte)233, byte.MaxValue, (byte)56)), Color32.op_Implicit(new Color32((byte)167, (byte)233, byte.MaxValue, (byte)92)), Color32.op_Implicit(new Color32((byte)167, (byte)233, byte.MaxValue, (byte)32)), Ink }; public const float LinePitch = 1.75f; private static Transform Src => ((Component)UIRoot.instance.uiGame.generatorWindow).transform; public static Text LabelTpl => ((Component)Src.Find("power-network-desc/desc-group/label-1")).GetComponent<Text>(); public static Text ValueTpl => ((Component)Src.Find("power-network-desc/desc-group/value-1")).GetComponent<Text>(); private static GameObject ButtonTpl => ((Component)Src.Find("ray-receiver/switch-button-1")).gameObject; public static GameObject Window(string title, float width, UnityAction onClose, bool keepMenu = false) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(((Component)Src).gameObject, Src.parent, false); ((Object)val).name = title; Object.DestroyImmediate((Object)(object)val.GetComponent<UIPowerGeneratorWindow>()); foreach (Transform item in val.transform) { Transform val2 = item; if (((Object)val2).name != "panel-bg") { Object.Destroy((Object)(object)((Component)val2).gameObject); } } if (!keepMenu) { OneButton((RectTransform)val.transform.Find("panel-bg/btn-box"), one: true); } StripLocalizers(val); Backdrop(val.transform.Find("panel-bg")); Button component = ((Component)val.transform.Find("panel-bg/btn-box/close-wnd-btn")).GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener(onClose); Text component2 = ((Component)val.transform.Find("panel-bg/title-text")).GetComponent<Text>(); component2.text = title; ((Graphic)component2).rectTransform.sizeDelta = new Vector2(width - 80f, ((Graphic)component2).rectTransform.sizeDelta.y); val.AddComponent<UIScrollZone>(); RectTransform val3 = (RectTransform)val.transform; val3.anchoredPosition = new Vector2(-300f, 300f); val3.sizeDelta = new Vector2(width, 200f); return val; } public static void OneButton(RectTransform box, bool one) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Transform)box).Find("menu-wnd-btn"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(!one); } float num = box.anchoredPosition.x + box.sizeDelta.x / 2f; float num2 = (one ? 48f : 64f); box.sizeDelta = new Vector2(num2, box.sizeDelta.y); box.anchoredPosition = new Vector2(num - num2 / 2f, box.anchoredPosition.y); ((RectTransform)((Transform)box).Find("close-wnd-btn")).anchoredPosition = new Vector2(one ? 8f : 16f, 0f); } public static InputField NewInput(Transform parent, Vector2 pos, Vector2 size, int limit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_012d: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) ((Shadow)((Component)Card(parent, pos, size, Well)).gameObject.AddComponent<Outline>()).effectColor = Color32.op_Implicit(new Color32((byte)167, (byte)233, byte.MaxValue, (byte)60)); InputField val = Object.Instantiate<InputField>(UIRoot.instance.uiGame.stationWindow.nameInput, parent, false); StripLocalizers(((Component)val).gameObject); UIInputField[] componentsInChildren = ((Component)val).GetComponentsInChildren<UIInputField>(true); foreach (UIInputField val2 in componentsInChildren) { if ((Object)(object)val2.iconSelectBtn != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val2.iconSelectBtn).gameObject); } if ((Object)(object)val2.overText != (Object)null && (Object)(object)val2.overText != (Object)(object)val.textComponent) { Object.DestroyImmediate((Object)(object)((Component)val2.overText).gameObject); } Object.DestroyImmediate((Object)(object)val2); } UIButton[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<UIButton>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } ((Selectable)val).transition = (Transition)0; Image[] componentsInChildren3 = ((Component)val).GetComponentsInChildren<Image>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { ((Graphic)componentsInChildren3[i]).color = Color.clear; } val.onEndEdit = new EndEditEvent(); val.onValueChanged = new OnChangeEvent(); val.characterLimit = limit; Place((RectTransform)((Component)val).transform, pos + new Vector2(8f, 0f), new Vector2(size.x - 16f, size.y)); Text textComponent = val.textComponent; ((Graphic)textComponent).material = null; ((Graphic)textComponent).color = Ink; textComponent.fontSize = 14; textComponent.alignment = (TextAnchor)3; ((Graphic)textComponent).rectTransform.anchorMin = Vector2.zero; ((Graphic)textComponent).rectTransform.anchorMax = Vector2.one; RectTransform rectTransform = ((Graphic)textComponent).rectTransform; Vector2 offsetMin = (((Graphic)textComponent).rectTransform.offsetMax = Vector2.zero); rectTransform.offsetMin = offsetMin; val.selectionColor = Color32.op_Implicit(new Color32((byte)253, (byte)150, (byte)94, (byte)110)); return val; } public static ScrollRect ScrollArea(Transform parent, Vector2 pos, float width, float step) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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) //IL_0043: 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_0053: Expected O, but got Unknown //IL_006b: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) Image val = Card(parent, pos, new Vector2(width, 0f), Color.clear); ((Graphic)val).raycastTarget = true; ((Component)val).gameObject.AddComponent<RectMask2D>(); RectTransform val2 = (RectTransform)new GameObject("content", new Type[1] { typeof(RectTransform) }).transform; ((Transform)val2).SetParent(((Component)val).transform, false); val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(1f, 1f); val2.pivot = new Vector2(0.5f, 1f); Vector2 anchoredPosition = (val2.sizeDelta = Vector2.zero); val2.anchoredPosition = anchoredPosition; WheelScroll wheelScroll = ((Component)val).gameObject.AddComponent<WheelScroll>(); ((ScrollRect)wheelScroll).horizontal = false; ((ScrollRect)wheelScroll).movementType = (MovementType)2; ((ScrollRect)wheelScroll).scrollSensitivity = step; ((ScrollRect)wheelScroll).viewport = ((Graphic)val).rectTransform; ((ScrollRect)wheelScroll).content = val2; Image obj = Card(parent, pos + new Vector2(width + 8f, 0f), new Vector2(5f, 0f), Well); ((Graphic)obj).raycastTarget = true; Image val3 = Card(((Component)obj).transform, Vector2.zero, Vector2.zero, Soft); ((Graphic)val3).raycastTarget = true; RectTransform rectTransform = ((Graphic)val3).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; anchoredPosition = (rectTransform.offsetMax = Vector2.zero); rectTransform.offsetMin = anchoredPosition; Scrollbar val4 = ((Component)obj).gameObject.AddComponent<Scrollbar>(); val4.handleRect = rectTransform; ((Selectable)val4).targetGraphic = (Graphic)(object)val3; val4.direction = (Direction)2; ((ScrollRect)wheelScroll).verticalScrollbar = val4; ((ScrollRect)wheelScroll).verticalScrollbarVisibility = (ScrollbarVisibility)1; return (ScrollRect)(object)wheelScroll; } public static void SizeScrollArea(ScrollRect scroll, float height) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Un