Decompiled source of GamesOMG Item Spawner v0.4.0
GamesOMG.PlanetCrafterSpawn.dll
Decompiled an hour ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using SpaceCraft; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("GamesOMG.PlanetCrafterSpawn")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.0.0")] [assembly: AssemblyInformationalVersion("0.4.0+dd055054059ee82a8dd08edd3a08bd1b8c8d87d2")] [assembly: AssemblyProduct("GamesOMG.PlanetCrafterSpawn")] [assembly: AssemblyTitle("GamesOMG.PlanetCrafterSpawn")] [assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was created with the assistance of Generative AI (Anthropic Claude), directed and tested in game by GamesOMG.")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")] [assembly: AssemblyVersion("0.4.0.0")] [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 GamesOMG.PlanetCrafterSpawn { internal static class Catalog { private const BindingFlags Hidden = BindingFlags.Static | BindingFlags.NonPublic; private static readonly FieldInfo Table = typeof(Localization).GetField("localizationDictionary", BindingFlags.Static | BindingFlags.NonPublic); private static readonly FieldInfo Language = typeof(Localization).GetField("currentLangage", BindingFlags.Static | BindingFlags.NonPublic); private static List<ItemEntry> cache; private static string cachedLanguage; private static int cachedGroups = -1; private static List<GroupItem> cachedList; private static List<GroupConstructible> cachedBuildings; private static bool warned; private static readonly WorldUnitType[] AllUnits = (WorldUnitType[])Enum.GetValues(typeof(WorldUnitType)); public static int Skipped { get; private set; } public static int Decorations { get; private set; } public static int Buildings { get; private set; } public static int Chips { get; private set; } public static string CurrentLanguage() { try { return (Language?.GetValue(null) as string) ?? "?"; } catch (Exception) { return "?"; } } private static Dictionary<string, string> English(ManualLogSource log) { try { if (Table?.GetValue(null) is Dictionary<string, Dictionary<string, string>> dictionary && dictionary.TryGetValue("english", out var value)) { return value; } } catch (Exception ex) { if (!warned) { log.LogWarning((object)("English item names unreadable (" + ex.GetType().Name + "): search uses the shown name and the id.")); } } if (!warned) { warned = true; log.LogWarning((object)"English item names not found in this build: search uses the shown name and the id."); } return null; } public static List<ItemEntry> Items(ManualLogSource log) { //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) List<GroupItem> list; try { list = GroupsHandler.GetGroupsItem(); } catch (Exception) { list = null; } if (list == null || list.Count == 0) { return cache ?? new List<ItemEntry>(); } List<GroupConstructible> list2; try { list2 = GroupsHandler.GetGroupsConstructible(); } catch (Exception) { list2 = null; } string text = CurrentLanguage(); if (cache != null && text == cachedLanguage && list.Count == cachedGroups && list == cachedList && list2 == cachedBuildings) { return cache; } Dictionary<string, string> english = English(log); List<ItemEntry> list3 = new List<ItemEntry>(list.Count + 64); HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); HashSet<string> hashSet2 = new HashSet<string>(StringComparer.Ordinal); int num = 0; int num2 = 0; int unnamedCount = 0; int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; foreach (GroupItem item in list) { if (item == null) { continue; } string id = ((Group)item).GetId(); if (string.IsNullOrEmpty(id) || !hashSet.Add(id)) { continue; } Group val = null; try { val = item.GetUnlocksGroup(); } catch (Exception) { } if (val != null && !string.IsNullOrEmpty(val.GetId())) { hashSet2.Add(val.GetId()); } if ((Object)(object)((Group)item).GetImage() == (Object)null) { num2++; continue; } ItemEntry itemEntry; if (val != null && Decor.IsChip(item: true, val.GetId())) { itemEntry = ChipEntry(item, id, val, english, num++, ref unnamedCount); num6++; } else { itemEntry = Entry((Group)(object)item, id, english, num++, ref unnamedCount); } if (Decor.IsSkin(item: true, ((object)item.GetEquipableType()/*cast due to .constrained prefix*/).ToString())) { itemEntry.Decoration = true; num3++; } list3.Add(itemEntry); } if (list2 != null) { foreach (GroupConstructible item2 in list2) { if (item2 != null) { string id2 = ((Group)item2).GetId(); if (!string.IsNullOrEmpty(id2) && !hashSet.Contains(id2) && Placeable(item2)) { hashSet.Add(id2); ItemEntry itemEntry2 = Entry((Group)(object)item2, id2, english, num++, ref unnamedCount); itemEntry2.Decoration = (itemEntry2.Placeable = true); num4++; list3.Add(itemEntry2); } } } } if (list2 != null) { foreach (GroupConstructible item3 in list2) { if (item3 != null) { string id3 = ((Group)item3).GetId(); if (!string.IsNullOrEmpty(id3) && !hashSet.Contains(id3) && DecorBuilding(item3, hashSet2)) { hashSet.Add(id3); ItemEntry itemEntry3 = Entry((Group)(object)item3, id3, english, num++, ref unnamedCount); itemEntry3.Decoration = (itemEntry3.Placeable = (itemEntry3.Building = true)); num5++; list3.Add(itemEntry3); } } } } cache = list3; cachedLanguage = text; cachedGroups = list.Count; cachedList = list; cachedBuildings = list2; Skipped = num2; Decorations = num3 + num4 + num5; Buildings = num5; Chips = num6; log.LogInfo((object)("Item list: " + list3.Count + " items (language " + text + ", " + num2 + " without an icon left out, " + unnamedCount + " the game never names: shown only when a search matches their id). Decoration: " + num4 + " effigies and posters (buildings the game hands out in crates), " + num5 + " furniture buildings for looks, " + num3 + " spacesuit skins. Blueprints: " + num6 + " blueprint chips, each named after what it unlocks.")); return cache; } private static ItemEntry Entry(Group g, string id, Dictionary<string, string> english, int order, ref int unnamedCount) { string text = null; string value = null; try { text = Readable.GetGroupName(g); } catch (Exception) { } english?.TryGetValue(GameConfig.localizationGroupNameId + id, out value); bool flag = english != null && string.IsNullOrEmpty(value) && (string.IsNullOrEmpty(text) || text == id); if (flag) { unnamedCount++; } return ItemEntry.Make(id, text, value, order, g, flag); } private static ItemEntry ChipEntry(GroupItem g, string id, Group target, Dictionary<string, string> english, int order, ref int unnamedCount) { string id2 = target.GetId(); string text = null; string value = null; try { text = Readable.GetGroupName(target); } catch (Exception) { } english?.TryGetValue(GameConfig.localizationGroupNameId + id2, out value); if (english == null && string.IsNullOrEmpty(value)) { value = text; } ItemEntry itemEntry = Decor.ChipEntry(id, id2, text, value, order, g, target); if (itemEntry.Unnamed) { unnamedCount++; } return itemEntry; } private static bool DecorBuilding(GroupConstructible g, HashSet<string> chipTargets) { //IL_0021: 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_0049: 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) try { List<int> secondaryInventoriesSize = ((Group)g).GetSecondaryInventoriesSize(); List<float> list = new List<float>(AllUnits.Length); WorldUnitType[] allUnits = AllUnits; foreach (WorldUnitType val in allUnits) { list.Add(g.GetGroupUnitGeneration(val)); } return Decor.IsDecorBuilding(constructible: true, (Object)(object)((Group)g).GetImage() != (Object)null, ((object)g.GetGroupCategory()/*cast due to .constrained prefix*/).ToString(), ((Group)g).GetInventorySize(), secondaryInventoriesSize?.Count ?? 0, Decor.Generates(list), chipTargets.Contains(((Group)g).GetId())); } catch (Exception) { return false; } } private static bool Placeable(GroupConstructible g) { try { Recipe recipe = ((Group)g).GetRecipe(); List<Group> list = ((recipe != null) ? recipe.GetIngredientsGroupInRecipe() : null); List<int> secondaryInventoriesSize = ((Group)g).GetSecondaryInventoriesSize(); return Decor.IsPlaceable(constructible: true, (Object)(object)((Group)g).GetImage() != (Object)null, list?.Count ?? 0, ((Group)g).GetInventorySize(), secondaryInventoriesSize?.Count ?? 0); } catch (Exception) { return false; } } public static HashSet<string> Owned(IList<ItemEntry> items) { HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); HashSet<Group> hashSet2 = new HashSet<Group>(); foreach (ItemEntry item in items) { if (item != null && item.Decoration) { object obj = item.Group; Group val = (Group)((obj is Group) ? obj : null); if (val != null) { hashSet2.Add(val); } } } if (hashSet2.Count == 0) { return hashSet; } try { HashSet<int> hashSet3 = new HashSet<int>(); InventoriesHandler instance = InventoriesHandler.Instance; Dictionary<int, Inventory> dictionary = ((instance != null) ? instance.GetAllInventories() : null); if (dictionary != null) { foreach (Inventory value2 in dictionary.Values) { if (value2 == null) { continue; } foreach (WorldObject insideWorldObject in value2.GetInsideWorldObjects()) { if (insideWorldObject != null) { hashSet3.Add(insideWorldObject.GetId()); } } } } WorldObjectsHandler instance2 = WorldObjectsHandler.Instance; Dictionary<int, WorldObject> dictionary2 = ((instance2 != null) ? instance2.GetAllWorldObjects() : null); if (dictionary2 != null) { foreach (KeyValuePair<int, WorldObject> item2 in dictionary2) { WorldObject value = item2.Value; Group val2 = ((value != null) ? value.GetGroup() : null); if (val2 != null && hashSet2.Contains(val2)) { int id = value.GetId(); if (Decor.Counts(hashSet3.Contains(id), value.GetIsPlaced(), WorldObjectsIdHandler.IsWorldObjectFromScene(id))) { hashSet.Add(val2.GetId()); } } } } } catch (Exception) { } return hashSet; } public static ItemEntry Find(IList<ItemEntry> items, string id) { foreach (ItemEntry item in items) { if (item.Id == id) { return item; } } return null; } public static Sprite Icon(ItemEntry e) { object obj = e?.Group; object obj2 = ((obj is Group) ? obj : null); if (obj2 == null) { return null; } return ((Group)obj2).GetImage(); } public static int CountIn(Inventory inventory, ItemEntry e) { if (inventory != null) { object obj = e?.Group; Group val = (Group)((obj is Group) ? obj : null); if (val != null) { int num = 0; try { foreach (WorldObject insideWorldObject in inventory.GetInsideWorldObjects()) { if (insideWorldObject != null && insideWorldObject.GetGroup() == val) { num++; } } } catch (Exception) { } return num; } } return 0; } } internal static class Chord { public static readonly HashSet<string> Harmless = new HashSet<string> { "SecretDevKey", "AccessibilityKey" }; public static List<string> Parts(string chord) { List<string> list = new List<string>(); string[] array = (chord ?? "").Split('+'); foreach (string text in array) { if (!KeyCheck.Empty(text)) { list.Add(text.Trim()); } } return list; } public static string Label(string chord, bool playStation) { List<string> list = Parts(chord); if (list.Count == 0) { return L.T("key.none"); } List<string> list2 = new List<string>(); foreach (string item in list) { list2.Add(KeyCheck.Label(item, playStation)); } return string.Join(" + ", list2); } public static List<string> Clashes(string chord, IList<GameBinding> game) { List<string> list = new List<string>(); List<string> list2 = Parts(chord); if (list2.Count == 0 || game == null) { return list; } foreach (GameBinding item in game) { if (item.Map != "PlayerMovable" || (list2.Count > 1 && Harmless.Contains(item.Action))) { continue; } foreach (string item2 in list2) { if (KeyCheck.Overlap(item2, item.Path) && !list.Contains(item.Action)) { list.Add(item.Action); } } } return list; } } internal static class Decor { public static bool IsPlaceable(bool constructible, bool hasIcon, int recipeCount, int inventorySize, int secondaryInventories) { if (constructible && hasIcon && recipeCount == 0 && inventorySize <= 0) { return secondaryInventories <= 0; } return false; } public static bool IsDecorBuilding(bool constructible, bool hasIcon, string category, int inventorySize, int secondaryInventories, bool generates, bool chipLinked) { if (constructible && hasIcon && category == "Furnitures" && inventorySize <= 0 && secondaryInventories <= 0 && !generates) { return !chipLinked; } return false; } public static bool Generates(IEnumerable<float> perUnit) { if (perUnit != null) { foreach (float item in perUnit) { if (item > 0f) { return true; } } } return false; } public static bool IsChip(bool item, string unlocksId) { if (item) { return !string.IsNullOrEmpty(unlocksId); } return false; } public static ItemEntry ChipEntry(string id, string targetId, string targetName, string targetEnglish, int order, object group = null, object target = null) { ItemEntry obj = ((!string.IsNullOrEmpty(targetEnglish) || (!string.IsNullOrEmpty(targetName) && !(targetName == targetId))) ? ItemEntry.Make(id, targetName, targetEnglish, order, group) : ItemEntry.Make(id, id, null, order, group, unnamed: true)); obj.Chip = true; obj.UnlocksId = targetId ?? ""; obj.Unlocks = target; return obj; } public static bool IsSkin(bool item, string equipableType) { if (item) { return equipableType == "Skin"; } return false; } public static List<ItemEntry> Missing(IList<ItemEntry> shown, ICollection<string> had) { List<ItemEntry> list = new List<ItemEntry>(); HashSet<string> hashSet = new HashSet<string>(); if (shown == null) { return list; } foreach (ItemEntry item in shown) { if (item != null && item.Decoration && hashSet.Add(item.Id) && (had == null || !had.Contains(item.Id))) { list.Add(item); } } return list; } public static List<ItemEntry> Only(IList<ItemEntry> all) { List<ItemEntry> list = new List<ItemEntry>(); if (all != null) { foreach (ItemEntry item in all) { if (item != null && item.Decoration) { list.Add(item); } } } return list; } public static List<ItemEntry> Chips(IList<ItemEntry> all) { List<ItemEntry> list = new List<ItemEntry>(); if (all != null) { foreach (ItemEntry item in all) { if (item != null && item.Chip) { list.Add(item); } } } return list; } public static bool Counts(bool inInventory, bool placed, bool fromScene) { if (!inInventory) { if (placed) { return !fromScene; } return false; } return true; } } internal sealed class HotKey : IDisposable { private readonly ConfigEntry<string> path; private readonly ManualLogSource log; private readonly string name; private InputAction action; private bool logged; public string Path => path.Value; public string Label => KeyCheck.Label(path?.Value); private bool Unset => KeyCheck.Empty(path?.Value); public HotKey(string name, ConfigEntry<string> path, ManualLogSource log) { this.name = name; this.path = path; this.log = log; path.SettingChanged += delegate { Bind(); }; Bind(); } private void Bind() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown InputAction obj = action; if (obj != null) { obj.Disable(); } InputAction obj2 = action; if (obj2 != null) { obj2.Dispose(); } action = null; logged = false; if (Unset) { return; } try { action = new InputAction("GamesOMG" + name, (InputActionType)1, path.Value, (string)null, (string)null, (string)null); action.Enable(); } catch (Exception ex) { log.LogWarning((object)(name + " key binding was rejected: " + ex.GetType().Name)); } } public void Tick() { //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) if (action != null && !action.enabled) { action.Enable(); } if (action != null && action.enabled && !logged) { logged = true; log.LogInfo((object)(name + " key " + path.Value + " is on, matched to " + action.controls.Count + " control(s).")); } } public bool Pressed(out string via) { //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) via = null; if (Unset) { return false; } if (action != null && action.WasPressedThisFrame()) { via = "action"; return true; } Keyboard current = Keyboard.current; if (current == null || !((ButtonControl)current.anyKey).wasPressedThisFrame) { return false; } try { InputControlList<InputControl> val = InputSystem.FindControls(path.Value); try { for (int i = 0; i < val.Count; i++) { InputControl obj = val[i]; ButtonControl val2 = (ButtonControl)(object)((obj is ButtonControl) ? obj : null); if (val2 != null && val2.wasPressedThisFrame) { via = "device " + ((InputControl)val[i].device).displayName; log.LogInfo((object)("The " + name + " action missed a press that " + via + " saw; using it.")); return true; } } } finally { ((IDisposable)val/*cast due to .constrained prefix*/).Dispose(); } } catch (Exception ex) { log.LogWarning((object)(name + " key lookup failed: " + ex.GetType().Name)); } return false; } public void Dispose() { InputAction obj = action; if (obj != null) { obj.Disable(); } InputAction obj2 = action; if (obj2 != null) { obj2.Dispose(); } action = null; } } internal sealed class Place { public string Id = ""; public string Name = ""; public int Order; } internal sealed class Tier { public string Name = ""; public float Range; public int Machines; } internal static class InfoText { public const float Epsilon = 1.1920929E-07f; private static readonly Regex LeadingTier = new Regex("^\\s*(?:[TtKkGgPpТт]\\s?\\d+\\s+|\\d+\\s*[级級]\\s*)", RegexOptions.CultureInvariant); private static readonly Regex TrailingTier = new Regex("\\s+(?:[TtKkGgPpТт]|St\\.?)\\s?\\d+\\s*$", RegexOptions.CultureInvariant); public static string Untiered(string name) { if (string.IsNullOrEmpty(name)) { return name ?? ""; } string text = TrailingTier.Replace(LeadingTier.Replace(name, ""), "").Trim(); if (text.Length != 0) { return text; } return name.Trim(); } public static string Stem(string id) { return (id ?? "").TrimEnd('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); } private static int TierNumber(string id) { string text = id ?? ""; int num = text.Length; while (num > 0 && char.IsDigit(text[num - 1])) { num--; } if (num >= text.Length || !int.TryParse(text.Substring(num), NumberStyles.None, CultureInfo.InvariantCulture, out var result)) { return 0; } return result; } public static List<string> Families(IEnumerable<Place> places) { Dictionary<string, Place> dictionary = new Dictionary<string, Place>(StringComparer.Ordinal); Dictionary<string, int> first = new Dictionary<string, int>(StringComparer.Ordinal); foreach (Place place in places) { if (place != null) { string key = Stem(place.Id); if (!dictionary.TryGetValue(key, out var value) || TierNumber(place.Id) < TierNumber(value.Id)) { dictionary[key] = place; } if (!first.TryGetValue(key, out var value2) || place.Order < value2) { first[key] = place.Order; } } } List<string> list = new List<string>(dictionary.Keys); list.Sort((string a, string b) => first[a].CompareTo(first[b])); List<string> list2 = new List<string>(); HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); foreach (string item in list) { string text = Untiered(dictionary[item].Name); if (text.Length > 0 && hashSet.Add(Search.Fold(text))) { list2.Add(text); } } return list2; } public static string Percent(float value) { if (!(Math.Abs((double)value - Math.Round(value)) < 0.001)) { return L.Number(value); } return Math.Round(value).ToString("0", CultureInfo.InvariantCulture); } public static string Join(params string[] sentences) { List<string> list = new List<string>(); foreach (string text in sentences) { if (!string.IsNullOrEmpty(text)) { list.Add(text); } } return string.Join(L.T("sentence.sep"), list.ToArray()); } public static string Multiplier(string label, float percent, IList<string> families, bool addUp, int elsewhere) { if (percent / 100f < 1.1920929E-07f) { return L.T("info.multNone", label); } string text = L.T("info.mult", label, Percent(percent), L.Number((double)percent / 100.0), string.Join(L.T("list.sep"), families)); return Join(text, addUp ? L.T("info.addUp") : null, elsewhere switch { 2 => L.T("info.elsewhere"), 1 => L.T("info.pot"), _ => null, }); } public static string Fuse(string label, float percent, IList<Tier> tiers) { string text = L.T("info.fuse", label, Percent(percent)); if (tiers == null || tiers.Count == 0) { return text; } List<string> list = new List<string>(); foreach (Tier tier in tiers) { list.Add(L.T("info.fuseTier", tier.Machines, Percent(tier.Range), tier.Name)); } return Join(text, L.T("info.fuseReach", string.Join(" · ", list.ToArray()))); } public static string Gauge(string kind, int value) { return L.T(kind, value); } public static string Description(string text, string name) { if (string.IsNullOrEmpty(text)) { return ""; } string input = Regex.Replace(text, "<br\\s*/?>", " ", RegexOptions.IgnoreCase); input = Regex.Replace(input, "<[^>]{1,40}>", ""); input = Regex.Replace(input, "\\s+", " ").Trim(); if (input.Length == 0 || Search.Fold(input) == Search.Fold(name)) { return ""; } return input; } } internal sealed class InputHold { private static readonly FieldInfo OpenedUi = typeof(WindowsHandler).GetField("_openedUi", BindingFlags.Instance | BindingFlags.NonPublic); private readonly ManualLogSource log; private readonly List<InputAction> disabled = new List<InputAction>(); private WindowsHandler windows; private PlayerMainController player; private bool markerSet; private bool cursorWasLocked; public bool Active { get; private set; } public PlayerMainController Player => player; public static bool Available { get { if (OpenedUi != null) { return OpenedUi.FieldType == typeof(UiType); } return false; } } public InputHold(ManualLogSource log) { this.log = log; } public bool Begin(PlayerMainController who) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 if (Active) { return true; } WindowsHandler val = InputHold.SafeManager<WindowsHandler>(); if ((Object)(object)val == (Object)null || (Object)(object)who == (Object)null || !Available) { if (!Available) { log.LogWarning((object)"Input hold unavailable: WindowsHandler._openedUi not found in this build."); } return false; } windows = val; player = who; try { cursorWasLocked = (int)Cursor.lockState == 1; OpenedUi.SetValue(windows, (object)(UiType)12); markerSet = true; Active = true; Keep(); SetCursorLocked(locked: false); } catch (Exception ex) { log.LogWarning((object)("Input hold could not start (" + ex.GetType().Name + "); undone.")); if (Active) { End("the hold could not start"); } windows = null; player = null; return false; } log.LogInfo((object)("Input held: " + disabled.Count + " game actions off.")); return true; } public unsafe string Check() { //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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Invalid comparison between Unknown and I4 if (!Active) { return null; } WindowsHandler val = InputHold.SafeManager<WindowsHandler>(); if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)windows || (Object)(object)player == (Object)null || !Object.op_Implicit((Object)(object)player)) { return "the world changed"; } UiType openedUi; try { openedUi = val.GetOpenedUi(); } catch (Exception) { return "the window handler went away"; } if ((int)openedUi != 12) { markerSet = false; return "a game window opened (" + ((object)(*(UiType*)(&openedUi))/*cast due to .constrained prefix*/).ToString() + ")"; } Keep(); return null; } private void Keep() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_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_0037: 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) foreach (InputActionAsset item in GameInputAssets()) { Enumerator<InputActionMap> enumerator2 = item.actionMaps.GetEnumerator(); try { while (enumerator2.MoveNext()) { Enumerator<InputAction> enumerator3 = enumerator2.Current.actions.GetEnumerator(); try { while (enumerator3.MoveNext()) { InputAction current = enumerator3.Current; if (current.enabled) { current.Disable(); if (!disabled.Contains(current)) { disabled.Add(current); } } } } finally { ((IDisposable)enumerator3/*cast due to .constrained prefix*/).Dispose(); } } } finally { ((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } } private IEnumerable<InputActionAsset> GameInputAssets() { List<InputActionAsset> list = new List<InputActionAsset>(); try { PlayerInputDispatcher val = (((Object)(object)player != (Object)null) ? ((Component)player).GetComponent<PlayerInputDispatcher>() : null); if ((Object)(object)val != (Object)null && (Object)(object)val.inputMap != (Object)null) { list.Add(val.inputMap); } WindowsGamepadHandler val2 = InputHold.SafeManager<WindowsGamepadHandler>(); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.InputMap != (Object)null && !list.Contains(val2.InputMap)) { list.Add(val2.InputMap); } } catch (Exception ex) { log.LogWarning((object)("Game input lookup failed: " + ex.GetType().Name)); } return list; } public void End(string why) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 if (!Active) { return; } Active = false; HashSet<InputAction> hashSet = GameWindowActions(); try { if (markerSet && (Object)(object)windows != (Object)null && Object.op_Implicit((Object)(object)windows) && (int)windows.GetOpenedUi() == 12) { OpenedUi.SetValue(windows, (object)(UiType)0); } } catch (Exception ex) { log.LogWarning((object)("Input hold marker cleanup: " + ex.GetType().Name)); } markerSet = false; int num = 0; int num2 = 0; foreach (InputAction item in disabled) { if (hashSet.Contains(item)) { num2++; continue; } try { item.Enable(); num++; } catch (Exception ex2) { log.LogWarning((object)("Could not switch a game key back on: " + ex2.GetType().Name)); } } if (num2 > 0) { log.LogInfo((object)("Input: " + num2 + " game actions left to the game's open window.")); } disabled.Clear(); try { bool flag = (Object)(object)windows != (Object)null && Object.op_Implicit((Object)(object)windows) && windows.GetHasUiOpen(); if (cursorWasLocked && !flag) { SetCursorLocked(locked: true); } } catch (Exception ex3) { log.LogWarning((object)("Input hold cursor restore: " + ex3.GetType().Name)); } windows = null; player = null; GUIUtility.keyboardControl = 0; log.LogInfo((object)("Input released (" + why + "); " + num + " game actions back on.")); } private HashSet<InputAction> GameWindowActions() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_0070: 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_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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) HashSet<InputAction> hashSet = new HashSet<InputAction>(); try { if ((Object)(object)windows == (Object)null || !Object.op_Implicit((Object)(object)windows)) { return hashSet; } UiType openedUi = windows.GetOpenedUi(); if ((int)openedUi == 0 || (int)openedUi == 12) { return hashSet; } WindowsGamepadHandler val = InputHold.SafeManager<WindowsGamepadHandler>(); if ((Object)(object)val == (Object)null || (Object)(object)val.InputMap == (Object)null) { return hashSet; } ReadOnlyArray<InputActionMap> actionMaps = val.InputMap.actionMaps; for (int i = 0; i < actionMaps.Count && i < 2; i++) { Enumerator<InputAction> enumerator = actionMaps[i].actions.GetEnumerator(); try { while (enumerator.MoveNext()) { InputAction current = enumerator.Current; hashSet.Add(current); } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } } catch (Exception ex) { log.LogWarning((object)("Game window input lookup failed: " + ex.GetType().Name)); } return hashSet; } private static void SetCursorLocked(bool locked) { try { CursorStateManager.SetLockCursorStatus(locked); } catch (Exception) { Cursor.lockState = (CursorLockMode)(locked ? 1 : 0); Cursor.visible = !locked; } } public static T SafeManager<T>() where T : MonoBehaviour { try { T manager = Managers.GetManager<T>(); return ((Object)(object)manager != (Object)null && Object.op_Implicit((Object)(object)manager)) ? manager : default(T); } catch (Exception) { return default(T); } } } internal sealed class Info { public string Description = ""; public string Stat = ""; public string Kind = "none"; public string Unit = ""; public float Percent; public int Value; public List<string> Places = new List<string>(); public List<string> Elsewhere = new List<string>(); public List<Tier> Tiers = new List<Tier>(); public bool AddUp; public string Target = ""; public bool Unlocked; internal string ChipNew = ""; internal string ChipDone = ""; internal object TargetGroup; } internal static class ItemInfo { private sealed class Building { public string Id = ""; public string Name = ""; public int Order; public int Size; public GroupConstructible Group; public bool HasUnit; public bool Hunger; public WorldUnitType Unit; public bool Filtered; public List<ItemCategory> Cats; public List<ItemCategory> NotCats; public List<ItemSubCategory> Subs; public List<ItemSubCategory> NotSubs; public float Range; public int Machines = -1; } private static readonly Dictionary<ItemSubCategory, WorldUnitType> FuseUnits = new Dictionary<ItemSubCategory, WorldUnitType> { [(ItemSubCategory)10] = (WorldUnitType)4, [(ItemSubCategory)9] = (WorldUnitType)1, [(ItemSubCategory)8] = (WorldUnitType)3, [(ItemSubCategory)11] = (WorldUnitType)7, [(ItemSubCategory)6] = (WorldUnitType)2, [(ItemSubCategory)15] = (WorldUnitType)9, [(ItemSubCategory)17] = (WorldUnitType)8, [(ItemSubCategory)18] = (WorldUnitType)11 }; private static readonly WorldUnitType[] Units; private const BindingFlags Hidden = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly FieldInfo AuthCats; private static readonly FieldInfo AuthSubs; private static readonly FieldInfo DenyCats; private static readonly FieldInfo DenySubs; private static List<Building> buildings; private static List<GroupConstructible> builtFrom; private static string builtFor; private static readonly Dictionary<string, Info> cache; private static bool warned; private static bool warnedFilter; private static ManualLogSource Log; public static Info For(ItemEntry e, ManualLogSource log) { if (e == null) { return new Info(); } Log = log; string text = Catalog.CurrentLanguage(); List<GroupConstructible> list = null; try { list = GroupsHandler.GetGroupsConstructible(); } catch (Exception) { } if (text != builtFor || list != builtFrom) { cache.Clear(); buildings = null; builtFor = text; builtFrom = list; } if (cache.TryGetValue(e.Id, out var value)) { return Now(value); } Info info; try { info = Make(e); } catch (Exception ex2) { info = new Info(); if (!warned) { warned = true; if (log != null) { log.LogWarning((object)("Item info unreadable for " + e.Id + " (" + ex2.GetType().Name + ": " + ex2.Message + "): the panel shows the name only.")); } } } cache[e.Id] = info; return Now(info); } private static Info Now(Info info) { if (!(info.Kind != "chip")) { object targetGroup = info.TargetGroup; Group val = (Group)((targetGroup is Group) ? targetGroup : null); if (val != null) { bool flag = false; try { flag = val.GetIsGloballyUnlocked(); } catch (Exception) { } info.Unlocked = flag; info.Stat = (flag ? info.ChipDone : info.ChipNew); return info; } } return info; } private static string GameWord(string key, string english) { string text = null; try { text = Localization.GetLocalizedString(key); } catch (Exception) { } if (!string.IsNullOrEmpty(text) && !(text == key)) { return text; } return english; } private static List<Building> Buildings() { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if (buildings != null) { return buildings; } List<GroupConstructible> list = builtFrom; bool flag = false; List<Building> list2 = new List<Building>(); int num = 0; if (list != null) { foreach (GroupConstructible item in list) { if (item == null) { continue; } string id = ((Group)item).GetId(); string groupName = Readable.GetGroupName((Group)(object)item); Building building = new Building { Id = id, Name = groupName, Order = num++, Group = item, Size = ((Group)item).GetInventorySize() }; GameObject associatedGameObject = ((Group)item).GetAssociatedGameObject(); if ((Object)(object)associatedGameObject != (Object)null) { WorldUnitMultiplierViaInventory componentInChildren = associatedGameObject.GetComponentInChildren<WorldUnitMultiplierViaInventory>(true); if ((Object)(object)componentInChildren != (Object)null && (int)item.GetWorldUnitMultiplied() == 0) { building.HasUnit = true; building.Unit = componentInChildren.worldUnitType; building.Hunger = componentInChildren.influencedByHunger; } InventoryAuthorizedGroups componentInChildren2 = associatedGameObject.GetComponentInChildren<InventoryAuthorizedGroups>(true); if ((Object)(object)componentInChildren2 != (Object)null && AuthCats != null && AuthSubs != null && DenyCats != null && DenySubs != null) { building.Filtered = true; building.Cats = (AuthCats.GetValue(componentInChildren2) as List<ItemCategory>) ?? new List<ItemCategory>(); building.Subs = (AuthSubs.GetValue(componentInChildren2) as List<ItemSubCategory>) ?? new List<ItemSubCategory>(); building.NotCats = (DenyCats.GetValue(componentInChildren2) as List<ItemCategory>) ?? new List<ItemCategory>(); building.NotSubs = (DenySubs.GetValue(componentInChildren2) as List<ItemSubCategory>) ?? new List<ItemSubCategory>(); } else if ((Object)(object)componentInChildren2 != (Object)null) { flag = true; } MachineOptimizer componentInChildren3 = associatedGameObject.GetComponentInChildren<MachineOptimizer>(true); if ((Object)(object)componentInChildren3 != (Object)null) { building.Range = componentInChildren3.range; building.Machines = componentInChildren3.maxWorldObjectPerFuse; } } list2.Add(building); } } buildings = list2; if (flag && !warnedFilter) { warnedFilter = true; ManualLogSource log = Log; if (log != null) { log.LogWarning((object)"A building's item filter is unreadable in this game build: the info line may name buildings that don't take the item."); } } return list2; } private static bool Named(Building b) { if (!string.IsNullOrEmpty(b.Name)) { return b.Name != b.Id; } return false; } private static bool Lists(Building b, GroupItem g) { //IL_0007: 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) if (!b.Cats.Contains(g.GetItemCategory())) { return b.Subs.Contains(g.GetItemSubCategory()); } return true; } private static bool Denies(Building b, GroupItem g) { //IL_0007: 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) if (!b.NotCats.Contains(g.GetItemCategory())) { return b.NotSubs.Contains(g.GetItemSubCategory()); } return true; } private static bool HasList(Building b) { return b.Cats.Count + b.Subs.Count > 0; } private static bool Takes(Building b, GroupItem g) { if (b.Filtered) { if (!HasList(b) || Lists(b, g)) { return !Denies(b, g); } return false; } return true; } private static bool Explicitly(Building b, GroupItem g) { if (b.Filtered && HasList(b) && Lists(b, g)) { return !Denies(b, g); } return false; } private unsafe static Info Make(ItemEntry e) { //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Invalid comparison between Unknown and I4 //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Expected I4, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Invalid comparison between Unknown and I4 //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Invalid comparison between Unknown and I4 //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Invalid comparison between Unknown and I4 //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0516: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Invalid comparison between Unknown and I4 //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Invalid comparison between Unknown and I4 //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Unknown result type (might be due to invalid IL or missing references) Info info = new Info(); object obj = e.Group; Group val = (Group)((obj is Group) ? obj : null); if (val == null) { return info; } if (e.Chip) { object unlocks = e.Unlocks; Group val2 = (Group)((unlocks is Group) ? unlocks : null); if (val2 != null) { string groupName = Readable.GetGroupName(val2); info.Description = InfoText.Description(Readable.GetGroupDescription(val2), groupName); info.Kind = "chip"; info.Target = val2.GetId(); info.TargetGroup = val2; string text = GameWord(GameConfig.localizationGroupNameId + "BlueprintT1", "Blueprint microchip"); string text2 = GameWord(GameConfig.localizationGroupNameId + "ScreenUnlockables", "Screen - Blueprints"); info.ChipNew = L.T("info.chip", text, text2, groupName); info.ChipDone = L.T("info.chipDone", groupName); return info; } } info.Description = InfoText.Description(Readable.GetGroupDescription(val), e.Name); if (e.Placeable) { string text3 = null; try { text3 = Localization.GetLocalizedString("Ui_clickbuildable"); } catch (Exception) { } if (!string.IsNullOrEmpty(text3) && text3 != "Ui_clickbuildable") { info.Kind = "place"; info.Stat = InfoText.Description(text3, ""); } return info; } GroupItem val3 = (GroupItem)(object)((val is GroupItem) ? val : null); if (val3 == null) { return info; } if ((int)val3.GetItemCategory() == 8) { ItemSubCategory itemSubCategory = val3.GetItemSubCategory(); string text4 = null; float num = 0f; if (FuseUnits.TryGetValue(itemSubCategory, out var value)) { text4 = Readable.GetMultiplerLabel(value); num = val3.GetGroupUnitMultiplier(value); info.Unit = ((object)(*(WorldUnitType*)(&value))/*cast due to .constrained prefix*/).ToString(); } else if ((int)itemSubCategory == 7) { text4 = L.T("info.fuseProduction"); num = val3.GetGroupValue(); info.Unit = "Production"; } else if ((int)itemSubCategory == 12) { text4 = L.T("info.fuseTrade"); num = val3.GetGroupValue(); info.Unit = "TradeRockets"; } else if ((int)itemSubCategory == 16) { text4 = L.T("info.fuseGrowth"); num = val3.GetGroupValue(); info.Unit = "Growth"; } if (text4 != null && num != 0f) { foreach (Building item in Buildings()) { if (item.Machines >= 0 && Named(item)) { info.Tiers.Add(new Tier { Name = item.Name, Range = item.Range, Machines = item.Machines }); } } info.Tiers.Sort((Tier x, Tier y) => x.Range.CompareTo(y.Range)); info.Kind = "fuse"; info.Percent = num; info.Stat = InfoText.Fuse(text4, num, info.Tiers); return info; } } string text5 = null; UsableType usableType = val3.GetUsableType(); switch (usableType - 1) { case 0: text5 = "info.food"; break; case 2: text5 = "info.water"; break; case 1: text5 = "info.oxygen"; break; case 6: text5 = "info.toxic"; break; } if (text5 != null && val3.GetGroupValue() > 0) { info.Kind = "gauge"; info.Unit = text5.Substring(5); info.Value = val3.GetGroupValue(); info.Stat = InfoText.Gauge(text5, info.Value); return info; } WorldUnitType[] units = Units; for (int num2 = 0; num2 < units.Length; num2++) { WorldUnitType val4 = units[num2]; List<Place> list = new List<Place>(); bool addUp = false; bool flag = val3.GetGroupUnitMultiplier(val4) != 0f; foreach (Building item2 in Buildings()) { if (item2.HasUnit && !item2.Hunger && item2.Unit == val4 && Named(item2) && (Explicitly(item2, val3) || (flag && Takes(item2, val3)))) { list.Add(new Place { Id = item2.Id, Name = item2.Name, Order = item2.Order }); if (item2.Size > 1) { addUp = true; } } } if (list.Count == 0) { continue; } foreach (Building item3 in Buildings()) { if ((!item3.HasUnit || item3.Unit != val4) && Named(item3) && Explicitly(item3, val3)) { info.Elsewhere.Add(item3.Id); } } ItemCategory itemCategory = val3.GetItemCategory(); bool flag2 = (int)itemCategory == 2 || (int)itemCategory == 5; info.Kind = "multiplier"; info.Unit = ((object)(*(WorldUnitType*)(&val4))/*cast due to .constrained prefix*/).ToString(); info.Percent = val3.GetGroupUnitMultiplier(val4); info.AddUp = addUp; foreach (Place item4 in list) { info.Places.Add(item4.Id); } info.Stat = InfoText.Multiplier(Readable.GetMultiplerLabel(val4), info.Percent, InfoText.Families(list), addUp, (info.Elsewhere.Count != 0) ? (flag2 ? 1 : 2) : 0); return info; } return info; } static ItemInfo() { WorldUnitType[] array = new WorldUnitType[8]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); Units = (WorldUnitType[])(object)array; AuthCats = typeof(InventoryAuthorizedGroups).GetField("authorizedItemCategories", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); AuthSubs = typeof(InventoryAuthorizedGroups).GetField("authorizedItemSubCategories", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); DenyCats = typeof(InventoryAuthorizedGroups).GetField("unauthorizedItemCategories", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); DenySubs = typeof(InventoryAuthorizedGroups).GetField("unauthorizedItemSubCategories", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); cache = new Dictionary<string, Info>(StringComparer.Ordinal); } } internal sealed class GameBinding { public string Map = ""; public string Action = ""; public string Path = ""; } internal sealed class Clash { public string Ours = ""; public string With = ""; public string Path = ""; public bool Game; } internal static class KeyCheck { public const string PlayMap = "PlayerMovable"; public static string Norm(string path) { return (path ?? "").Trim().Replace(" ", "").ToLowerInvariant(); } public static bool Empty(string path) { return Norm(path).Length == 0; } public static bool Overlap(string a, string b) { a = Norm(a); b = Norm(b); if (a.Length == 0 || b.Length == 0 || a.IndexOf('{') >= 0 || b.IndexOf('{') >= 0 || a.IndexOf('/') < 0 || b.IndexOf('/') < 0) { return false; } if (a == b || b.StartsWith(a + "/", StringComparison.Ordinal) || a.StartsWith(b + "/", StringComparison.Ordinal)) { return true; } string text = a.Substring(a.IndexOf('/')); string text2 = b.Substring(b.IndexOf('/')); if (IsPad(a) && IsPad(b)) { if (!(text == text2) && !text2.StartsWith(text + "/", StringComparison.Ordinal)) { return text.StartsWith(text2 + "/", StringComparison.Ordinal); } return true; } return false; } public static bool IsPad(string path) { string text = Norm(path); if (!text.StartsWith("<gamepad>", StringComparison.Ordinal) && !text.StartsWith("<xinputcontroller>", StringComparison.Ordinal) && !text.StartsWith("<dualshockgamepad>", StringComparison.Ordinal) && !text.StartsWith("<dualsensegamepad>", StringComparison.Ordinal)) { return text.StartsWith("<switchprocontrollerhid>", StringComparison.Ordinal); } return true; } public static List<Clash> Find(IList<KeyValuePair<string, string>> ours, IList<GameBinding> game) { List<Clash> list = new List<Clash>(); for (int i = 0; i < ours.Count; i++) { if (Empty(ours[i].Value)) { continue; } for (int j = i + 1; j < ours.Count; j++) { if (Overlap(ours[i].Value, ours[j].Value)) { list.Add(new Clash { Ours = ours[i].Key, With = ours[j].Key, Path = ours[i].Value }); list.Add(new Clash { Ours = ours[j].Key, With = ours[i].Key, Path = ours[j].Value }); } } if (game == null) { continue; } HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); foreach (GameBinding item in game) { if (item.Map == "PlayerMovable" && Overlap(ours[i].Value, item.Path) && hashSet.Add(item.Action)) { list.Add(new Clash { Ours = ours[i].Key, With = item.Action, Path = item.Path, Game = true }); } } } return list; } public static string Words(string action) { if (string.IsNullOrEmpty(action)) { return ""; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < action.Length; i++) { char c = action[i]; if (i > 0 && char.IsUpper(c) && !char.IsUpper(action[i - 1])) { stringBuilder.Append(' ').Append(char.ToLowerInvariant(c)); } else { stringBuilder.Append(c); } } return stringBuilder.ToString(); } public static string Label(string path, bool playStation = false) { string text = Norm(path); if (text.Length == 0) { return L.T("key.none"); } int num = text.IndexOf('/'); string text2 = ((num >= 0) ? text.Substring(num + 1) : text); if (IsPad(text)) { switch (text2) { case "buttonsouth": if (!playStation) { return "A"; } return L.T("pad.cross"); case "buttoneast": if (!playStation) { return "B"; } return L.T("pad.circle"); case "buttonwest": if (!playStation) { return "X"; } return L.T("pad.square"); case "buttonnorth": if (!playStation) { return "Y"; } return L.T("pad.triangle"); case "leftshoulder": if (!playStation) { return "LB"; } return "L1"; case "rightshoulder": if (!playStation) { return "RB"; } return "R1"; case "lefttrigger": if (!playStation) { return "LT"; } return "L2"; case "righttrigger": if (!playStation) { return "RT"; } return "R2"; case "leftstickpress": if (!playStation) { return "LS"; } return "L3"; case "rightstickpress": if (!playStation) { return "RS"; } return "R3"; case "select": if (!playStation) { return "View"; } return "Share"; case "start": if (!playStation) { return "Menu"; } return "Options"; case "dpad/up": return L.T("key.dpadUp"); case "dpad/down": return L.T("key.dpadDown"); case "dpad/left": return L.T("key.dpadLeft"); case "dpad/right": return L.T("key.dpadRight"); default: return text2; } } switch (text2) { case "escape": return "Esc"; case "enter": return "Enter"; case "numpadenter": return "Num Enter"; case "backquote": return "`"; case "space": return L.T("key.space"); case "tab": return "Tab"; case "backspace": return "Backspace"; case "shift": case "leftshift": return "Shift"; case "leftctrl": case "ctrl": return "Ctrl"; case "alt": case "leftalt": return "Alt"; case "pageup": return "Page Up"; case "pagedown": return "Page Down"; case "insert": return "Insert"; case "delete": return "Delete"; case "home": return "Home"; case "end": return "End"; default: if (text2.StartsWith("numpad", StringComparison.Ordinal) && text2.Length == 7) { return "Num " + text2.Substring(6); } if (text2.StartsWith("digit", StringComparison.Ordinal) && text2.Length == 6) { return text2.Substring(5); } return text2.ToUpperInvariant(); } } } internal sealed class PadChord { private readonly Func<string> path; private bool wasDown; public string Value => path() ?? ""; public PadChord(Func<string> path) { this.path = path; } public bool Pressed() { Gamepad current = Gamepad.current; if (current == null) { wasDown = false; return false; } List<string> list = Chord.Parts(Value); if (list.Count == 0) { return false; } bool flag = true; foreach (string item in list) { ButtonControl val = Control(current, item); if (val == null || !val.isPressed) { flag = false; break; } } bool result = flag && !wasDown; wasDown = flag; return result; } public bool Held() { Gamepad current = Gamepad.current; if (current == null) { return false; } foreach (string item in Chord.Parts(Value)) { ButtonControl val = Control(current, item); if (val != null && val.isPressed) { return true; } } return false; } private static ButtonControl Control(Gamepad pad, string path) { string text = KeyCheck.Norm(path); int num = text.IndexOf('/'); if (num < 0 || !KeyCheck.IsPad(text)) { return null; } try { InputControl obj = ((InputControl)pad).TryGetChildControl(text.Substring(num + 1)); return (ButtonControl)(object)((obj is ButtonControl) ? obj : null); } catch (Exception) { return null; } } } internal enum Cmd { None, Up, Down, Left, Right, PageUp, PageDown, Home, End, Next, Prev, Activate, Back, TabLeft, TabRight, Ten, Fill } internal sealed class PadInput { private const float Delay = 0.38f; private const float Rate = 0.085f; private const float Dead = 0.55f; private int heldDir; private float nextRepeat; private Vector2 lastMouse; public bool UsingPad { get; private set; } public bool PlayStation { get; private set; } public Cmd Read(bool textFocused, bool arrowsAlways = false) { //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_0090: 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_0098: 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_00b5: 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_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; Gamepad current2 = Gamepad.current; Mouse current3 = Mouse.current; Vector2 val; if (current2 != null && AnyPad(current2)) { UsingPad = true; string text = ((InputControl)current2).layout ?? ""; PlayStation = text.Contains("DualShock") || text.Contains("DualSense"); } else if (current != null && ((ButtonControl)current.anyKey).wasPressedThisFrame) { UsingPad = false; } else if (current3 != null) { val = ((InputControl<Vector2>)(object)((Pointer)current3).position).ReadValue(); if (!current3.leftButton.wasPressedThisFrame) { Vector2 val2 = val - lastMouse; if (!(((Vector2)(ref val2)).sqrMagnitude > 64f)) { goto IL_00b4; } } UsingPad = false; goto IL_00b4; } goto IL_00bc; IL_00b4: lastMouse = val; goto IL_00bc; IL_00bc: if (current != null) { bool isPressed = current.shiftKey.isPressed; if (((ButtonControl)current.escapeKey).wasPressedThisFrame) { return Cmd.Back; } if (((ButtonControl)current.enterKey).wasPressedThisFrame || ((ButtonControl)current.numpadEnterKey).wasPressedThisFrame) { return Cmd.Activate; } if (((ButtonControl)current.tabKey).wasPressedThisFrame) { if (!isPressed) { return Cmd.Next; } return Cmd.Prev; } if (((ButtonControl)current.pageUpKey).wasPressedThisFrame) { return Cmd.PageUp; } if (((ButtonControl)current.pageDownKey).wasPressedThisFrame) { return Cmd.PageDown; } if (!textFocused) { if (((ButtonControl)current.homeKey).wasPressedThisFrame) { return Cmd.Home; } if (((ButtonControl)current.endKey).wasPressedThisFrame) { return Cmd.End; } if (((ButtonControl)current.spaceKey).wasPressedThisFrame) { return Cmd.Activate; } } } if (current2 != null) { if (current2.buttonSouth.wasPressedThisFrame) { return Cmd.Activate; } if (current2.buttonEast.wasPressedThisFrame) { return Cmd.Back; } if (current2.leftShoulder.wasPressedThisFrame) { return Cmd.TabLeft; } if (current2.rightShoulder.wasPressedThisFrame) { return Cmd.TabRight; } if (current2.buttonWest.wasPressedThisFrame) { return Cmd.Ten; } if (current2.buttonNorth.wasPressedThisFrame) { return Cmd.Fill; } if (current2.leftTrigger.wasPressedThisFrame) { return Cmd.PageUp; } if (current2.rightTrigger.wasPressedThisFrame) { return Cmd.PageDown; } } int num = 0; if (current != null) { if (((ButtonControl)current.upArrowKey).isPressed) { num = 1; } else if (((ButtonControl)current.downArrowKey).isPressed) { num = 2; } else if ((!textFocused || arrowsAlways) && ((ButtonControl)current.leftArrowKey).isPressed) { num = 3; } else if ((!textFocused || arrowsAlways) && ((ButtonControl)current.rightArrowKey).isPressed) { num = 4; } } if (num == 0 && current2 != null) { Vector2 val3 = ((InputControl<Vector2>)(object)current2.leftStick).ReadValue(); if (current2.dpad.up.isPressed || val3.y > 0.55f) { num = 1; } else if (current2.dpad.down.isPressed || val3.y < -0.55f) { num = 2; } else if (current2.dpad.left.isPressed || val3.x < -0.55f) { num = 3; } else if (current2.dpad.right.isPressed || val3.x > 0.55f) { num = 4; } } if (num == 0) { heldDir = 0; return Cmd.None; } float unscaledTime = Time.unscaledTime; if (num != heldDir) { heldDir = num; nextRepeat = unscaledTime + 0.38f; return (Cmd)num; } if (unscaledTime >= nextRepeat) { nextRepeat = unscaledTime + 0.085f; return (Cmd)num; } return Cmd.None; } private static bool AnyPad(Gamepad pad) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) Enumerator<InputControl> enumerator = ((InputDevice)pad).allControls.GetEnumerator(); try { while (enumerator.MoveNext()) { InputControl current = enumerator.Current; ButtonControl val = (ButtonControl)(object)((current is ButtonControl) ? current : null); if (val != null && val.wasPressedThisFrame) { return true; } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } Vector2 val2 = ((InputControl<Vector2>)(object)pad.leftStick).ReadValue(); Vector2 val3 = ((InputControl<Vector2>)(object)pad.rightStick).ReadValue(); if (!(((Vector2)(ref val2)).sqrMagnitude > 0.3025f)) { return ((Vector2)(ref val3)).sqrMagnitude > 0.3025f; } return true; } public static string Captured(out bool cancelled) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_0032: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) cancelled = false; Keyboard current = Keyboard.current; if (current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) { cancelled = true; return null; } if (current != null && ((ButtonControl)current.anyKey).wasPressedThisFrame) { Enumerator<KeyControl> enumerator = current.allKeys.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyControl current2 = enumerator.Current; if (current2 != null && ((ButtonControl)current2).wasPressedThisFrame && current2 != current.escapeKey && current2 != current.enterKey && current2 != current.numpadEnterKey) { return "<Keyboard>/" + ((InputControl)current2).name; } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } Gamepad current3 = Gamepad.current; if (current3 != null) { Enumerator<InputControl> enumerator2 = ((InputDevice)current3).allControls.GetEnumerator(); try { while (enumerator2.MoveNext()) { InputControl current4 = enumerator2.Current; ButtonControl val = (ButtonControl)(object)((current4 is ButtonControl) ? current4 : null); if (val != null && val.wasPressedThisFrame) { string text = current4.path.Substring(((InputControl)current3).path.Length).TrimStart('/'); if (!(text == "dpad") && !text.StartsWith("leftStick/") && !text.StartsWith("rightStick/")) { return "<Gamepad>/" + text; } } } } finally { ((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } } return null; } } internal static class Palette { public const int Orange = 15761408; public const int OrangeHover = 16751150; public const int Blue = 3924991; public const int Ink = 15659509; public const int Muted = 10726843; public const int Line = 2830912; public const int Panel = 921879; public const int Surface = 1514275; public const int Raised = 2106927; public const int Hover = 2765116; public const int Good = 5230730; public const int Bad = 16739166; public const int OnOrange = 1314826; public const float SelectedAlpha = 0.22f; public const double Floor = 4.5; public static readonly string[][] Pairs = new string[32][] { new string[3] { "Title", "Ink", "Panel" }, new string[3] { "Sub", "Muted", "Panel" }, new string[3] { "Text", "Ink", "Panel" }, new string[3] { "Text", "Ink", "Surface" }, new string[3] { "TextStrong", "Ink", "Surface" }, new string[3] { "Small", "Muted", "Panel" }, new string[3] { "Small", "Muted", "Surface" }, new string[3] { "Info", "Ink", "Surface" }, new string[3] { "Head", "Muted", "Panel" }, new string[3] { "Cell", "Ink", "Surface" }, new string[3] { "Cell", "Ink", "Hover" }, new string[3] { "Cell", "Ink", "Selected" }, new string[3] { "CellTight", "Ink", "Surface" }, new string[3] { "CellTight", "Ink", "Hover" }, new string[3] { "CellTight", "Ink", "Selected" }, new string[3] { "Status", "Good", "Surface" }, new string[3] { "Status", "Good", "Panel" }, new string[3] { "StatusBad", "Bad", "Surface" }, new string[3] { "StatusBad", "Bad", "Panel" }, new string[3] { "Prompt", "Muted", "Panel" }, new string[3] { "Key", "Ink", "Raised" }, new string[3] { "Button", "Ink", "Raised" }, new string[3] { "Button", "Ink", "Hover" }, new string[3] { "Primary", "OnOrange", "Orange" }, new string[3] { "Primary", "OnOrange", "OrangeHover" }, new string[3] { "Tab", "Muted", "Panel" }, new string[3] { "Tab", "Muted", "Hover" }, new string[3] { "TabOn", "Ink", "Surface" }, new string[3] { "Field", "Ink", "Surface" }, new string[3] { "Field", "Ink", "Raised" }, new string[3] { "Placeholder", "Muted", "Surface" }, new string[3] { "Placeholder", "Muted", "Raised" } }; public static int Selected => Blend(15761408, 0.22f, 1514275); public static int Named(string name) { return name switch { "Orange" => 15761408, "OrangeHover" => 16751150, "Blue" => 3924991, "Ink" => 15659509, "Muted" => 10726843, "Line" => 2830912, "Panel" => 921879, "Surface" => 1514275, "Raised" => 2106927, "Hover" => 2765116, "Good" => 5230730, "Bad" => 16739166, "OnOrange" => 1314826, "Selected" => Selected, _ => throw new ArgumentException("no colour " + name), }; } public static double Luminance(int rgb) { return 0.2126 * Lin((rgb >> 16) & 0xFF) + 0.7152 * Lin((rgb >> 8) & 0xFF) + 0.0722 * Lin(rgb & 0xFF); static double Lin(int c) { double num = (double)c / 255.0; if (!(num <= 0.03928)) { return Math.Pow((num + 0.055) / 1.055, 2.4); } return num / 12.92; } } public static double Ratio(int a, int b) { double val = Luminance(a); double val2 = Luminance(b); return (Math.Max(val, val2) + 0.05) / (Math.Min(val, val2) + 0.05); } public static int Blend(int fg, float alpha, int bg) { return (ch(16) << 16) | (ch(8) << 8) | ch(0); int ch(int shift) { return (int)Math.Round((float)((fg >> shift) & 0xFF) * alpha + (float)((bg >> shift) & 0xFF) * (1f - alpha)); } } public static List<KeyValuePair<string, double>> Table() { List<KeyValuePair<string, double>> list = new List<KeyValuePair<string, double>>(); string[][] pairs = Pairs; foreach (string[] array in pairs) { list.Add(new KeyValuePair<string, double>(array[0] + ": " + array[1] + " on " + array[2], Ratio(Named(array[1]), Named(array[2])))); } list.Sort((KeyValuePair<string, double> x, KeyValuePair<string, double> y) => x.Value.CompareTo(y.Value)); return list; } } internal interface IPanelHost { bool Busy { get; } string KeyLabel { get; } float TextSize { get; } int LastAmount { get; set; } IList<string> Recent { get; } string LastId { get; } string GameBuild { get; } string PadLabel(bool playStation); bool ChordHeld(); void Spawn(ItemEntry item, Inventory backpack, int amount, bool fill); void SpawnSet(List<ItemEntry> items, Inventory backpack); } internal sealed class Panel { private const string SearchName = "gomg-spawn-search"; private const string AmountName = "gomg-spawn-amount"; private readonly IPanelHost host; private readonly ManualLogSource log; private readonly InputHold hold; private readonly PadInput input = new PadInput(); public readonly Theme Theme = new Theme(); private PlayerMainController player; private Inventory backpack; private List<ItemEntry> all = new List<ItemEntry>(); private List<ItemEntry> shown = new List<ItemEntry>(); private string query = ""; private string shownFor; public const int TabAll = 0; public const int TabDeco = 1; public const int TabBlue = 2; public const int TabRecent = 3; public const int Tabs = 4; private static readonly string[] TabIds = new string[4] { "tab.all", "tab.deco", "tab.blue", "tab.recent" }; private int tab; private int shownTab = -1; private HashSet<string> owned = new HashSet<string>(StringComparer.Ordinal); private List<ItemEntry> missing = new List<ItemEntry>(); private bool ownedStale = true; private int sel; private int top; private int cols = 1; private int visRows = 1; private string amountText = "1"; private string status; private bool statusBad; private bool focusSearch; private bool ignoreTabs; private bool help; private bool client; private GUIStyle amountStyle; private GUIStyle helpStyle; private GUIStyle emptyStyle; private float stylesFor = -1f; private float helpScroll; private float helpOver; private const int InfoLines = 4; public readonly HashSet<string> Overflow = new HashSet<string>(StringComparer.Ordinal); public readonly HashSet<string> Truncated = new HashSet<string>(StringComparer.Ordinal); private bool switchFocus; private readonly Dictionary<string, KeyValuePair<string, bool>> fitted = new Dictionary<string, KeyValuePair<string, bool>>(); private float fittedFor = -1f; private static string blueLabel; private static string blueFor; private readonly Dictionary<string, float> tall = new Dictionary<string, float>(); public bool Open { get; private set; } public Rect Drawn { get; private set; } public bool MeasureFit { get; set; } public Info SelectedInfo { get; private set; } public bool PlayStation => input.PlayStation; public ItemEntry Selected { get { if (sel < 0 || sel >= shown.Count) { return null; } return shown[sel]; } } public string Query => query; public int Tab => tab; public int ShownCount => shown.Count; public string Status => status; public bool StatusBad => statusBad; public int MissingCount => missing.Count; public IList<ItemEntry> Shown => shown; public Panel(IPanelHost host, ManualLogSource log) { this.host = host; this.log = log; hold = new InputHold(log); } public bool Show(PlayerMainController who, Inventory inventory, bool viaPad) { if (Open) { return true; } all = Catalog.Items(log); if (all.Count == 0) { status = null; return false; } if (!hold.Begin(who)) { return false; } player = who; backpack = inventory; client = Spawner.IsClient; Open = true; query = ""; shownFor = null; tab = 0; help = false; status = null; amountText = SpawnPlan.Clamp(host.LastAmount).ToString(CultureInfo.InvariantCulture); focusSearch = true; ignoreTabs = viaPad; ownedStale = true; Refresh(); int num = ((host.LastId == null) ? (-1) : shown.FindIndex((ItemEntry e) => e.Id == host.LastId)); sel = ((num >= 0) ? num : 0); Visible(); log.LogInfo((object)("Panel opened (" + all.Count + " items" + (client ? ", co-op client" : "") + ").")); return true; } public void Hide(string why) { if (Open) { Open = false; hold.End(why); GUIUtility.keyboardControl = 0; log.LogInfo((object)("Panel closed (" + why + ").")); } } public void Result(SpawnPlan plan, ItemEntry item) { string text = plan.ResultId(); status = L.T(text, plan.Added, item.Name, plan.DidNotFit); statusBad = text != "result.added" && text != "result.filled"; ownedStale = true; } public void SetResult(SpawnPlan plan) { string text = plan.SetResultId(); status = L.T(text, plan.Added, plan.DidNotFit); statusBad = text != "set.added"; ownedStale = true; } public void Say(string text, bool bad) { status = text; statusBad = bad; } public bool SelectId(string id) { if (!Open || id == null) { return false; } query = ""; tab = 0; help = false; Refresh(); int num = shown.FindIndex((ItemEntry e) => e.Id == id); if (num < 0) { return false; } sel = num; Visible(); return true; } public void ShowHelp(bool on) { help = on; helpScroll = 0f; } public void Update(bool toggle) { if (toggle) { Hide("the open key"); return; } string text = hold.Check(); if (text != null) { Hide(text); return; } if ((Object)(object)player == (Object)null || !Object.op_Implicit((Object)(object)player)) { Hide("the player is gone"); return; } if (ignoreTabs && !host.ChordHeld()) { ignoreTabs = false; } Refresh(); bool textFocused = GUIUtility.keyboardControl != 0; Cmd cmd = input.Read(textFocused, arrowsAlways: true); if (ignoreTabs && (cmd == Cmd.TabLeft || cmd == Cmd.TabRight)) { cmd = Cmd.None; } if (help && helpOver > 0f && (cmd == Cmd.Up || cmd == Cmd.Down || cmd == Cmd.PageUp || cmd == Cmd.PageDown)) { float num = Theme.Px((cmd == Cmd.Up || cmd == Cmd.Down) ? 40 : 200); helpScroll = Mathf.Clamp(helpScroll + ((cmd == Cmd.Up || cmd == Cmd.PageUp) ? (0f - num) : num), 0f, helpOver); return; } if (help && cmd != Cmd.None && cmd != Cmd.Back) { help = false; } switch (cmd) { case Cmd.Left: Move(-1); break; case Cmd.Right: Move(1); break; case Cmd.Up: Move(-cols); break; case Cmd.Down: Move(cols); break; case Cmd.PageUp: Move(-cols * Math.Max(1, visRows - 1)); break; case Cmd.PageDown: Move(cols * Math.Max(1, visRows - 1)); break; case Cmd.Home: sel = 0; Visible(); break; case Cmd.End: sel = Math.Max(0, shown.Count - 1); Visible(); break; case Cmd.TabLeft: SetTab((tab + 4 - 1) % 4); break; case Cmd.TabRight: SetTab((tab + 1) % 4); break; case Cmd.Next: case Cmd.Prev: switchFocus = true; break; case Cmd.Activate: Add(null, fill: false); break; case Cmd.Ten: Add(10, fill: false); break; case Cmd.Fill: if (tab == 1) { AddSet(); } else { Add(null, fill: true); } break; case Cmd.Back: if (help) { help = false; } else if (query.Length > 0 && !input.UsingPad) { query = ""; focusSearch = true; } else { Hide("Esc / B"); } break; } } private void Move(int by) { if (shown.Count != 0) { sel = Mathf.Clamp(sel + by, 0, shown.Count - 1); Visible(); } } private void SetTab(int t) { string keep = Selected?.Id; tab = t; Refresh(); int num = ((keep == null) ? (-1) : shown.FindIndex((ItemEntry e) => e.Id == keep)); sel = ((num >= 0) ? num : 0); Visible(); } private void Visible() { if (cols < 1) { cols = 1; } int num = sel / cols; if (num < top) { top = num; } if (num >= top + visRows) { top = num - visRows + 1; } if (top < 0) { top = 0; } } private void Refresh() { bool flag = false; if (tab == 1 && ownedStale && !host.Busy) { owned = Catalog.Owned(all); ownedStale = false; flag = true; } if (query == shownFor && tab == shownTab && !flag) { return; } bool flag2 = query != shownFor; shownFor = query; shownTab = tab; if (tab == 3) { List<ItemEntry> list = new List<ItemEntry>(); foreach (string item in host.Recent) { ItemEntry itemEntry = Catalog.Find(all, item); if (itemEntry != null) { list.Add(itemEntry); } } shown = ((query.Trim().Length == 0) ? list : Search.Filter(list, query)); } else if (tab == 1) { shown = Search.Filter(Decor.Only(all), query); } else if (tab == 2) { shown = Search.Filter(Decor.Chips(all), query); } else { shown = Search.Filter(all, query); } missing = ((tab == 1) ? Decor.Missing(shown, owned) : new List<ItemEntry>()); if (flag2) { sel = 0; top = 0; } if (sel >= shown.Count) { sel = Math.Max(0, shown.Count - 1); } } private void AddSet() { if (tab != 1 || help) { return; } if (host.Busy) { Say(L.T("spawn.busy"), bad: true); return; } owned = Catalog.Owned(all); ownedStale = false; missing = Decor.Missing(shown, owned); if (missing.Count == 0) { Say(L.T("set.none"), bad: false); return; } Say(L.T("set.adding", missing.Count), bad: false); host.SpawnSet(new List<ItemEntry>(missing), backpack); } private void Add(int? amount, bool fill) { ItemEntry selected = Selected; if (selected == null || help) { return; } if (host.Busy) { Say(L.T("spawn.busy"), bad: true); return; } int num = amount ?? ParseAmount(); if (!amount.HasValue && !fill) { host.LastAmount = num; } Say(L.T("spawn.adding", selected.Name), bad: false); host.Spawn(selected, backpack, num, fill); } private int ParseAmount() { int.TryParse(amountText, NumberStyles.None, CultureInfo.InvariantCulture, out var result); result = SpawnPlan.Clamp(result); amountText = result.ToString(CultureInfo.InvariantCulture); return result; } public void OnGUI() { //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Invalid comparison between Unknown and I4 //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_04d2: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04f7: Invalid comparison between Unknown and I4 //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_0695: Unknown result type (might be due to invalid IL or missing references) //IL_069f: Expected O, but got Unknown //IL_069a: Unknown result type (might be due to invalid IL or missing references) //IL_06db: Unknown result type (might be due to invalid IL or missing references) //IL_06f9: Unknown result type (might be due to invalid IL or missing references) //IL_06ff: Invalid comparison between Unknown and I4 //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Expected O, but got Unknown //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_0740: Expected O, but got Unknown //IL_073b: Unknown result type (might be due to invalid IL or missing references) //IL_0a38: Unknown result type (might be due to invalid IL or missing references) //IL_0a49: Unknown result type (might be due to invalid IL or missing references) //IL_0a2a: Unknown result type (might be due to invalid IL or missing references) //IL_0853: Unknown result type (might be due to invalid IL or missing references) //IL_085d: Expected O, but got Unknown //IL_0858: Unknown result type (might be due to invalid IL or missing references) //IL_08e6: Unknown result type (might be due to invalid IL or missing references) //IL_0903: Unknown result type (might be due to invalid IL or missing references) //IL_0959: Unknown result type (might be due to invalid IL or missing references) //IL_0aba: Unknown result type (might be due to invalid IL or missing references) //IL_0acb: Unknown result type (might be due to invalid IL or missing references) //IL_0a9d: Unknown result type (might be due to invalid IL or missing references) //IL_0ade: Unknown result type (might be due to invalid IL or missing references) //IL_0ae4: Invalid comparison between Unknown and I4 //IL_0b00: Unknown result type (might be due to invalid IL or missing references) //IL_0b06: Invalid comparison between Unknown and I4 //IL_0b36: Unknown result type (might be due to invalid IL or missing references) //IL_0b3e: Unknown result type (might be due to invalid IL or missing references) //IL_0b44: Invalid comparison between Unknown and I4 //IL_0b47: Unknown result type (might be due to invalid IL or missing references) //IL_0b4d: Invalid comparison between Unknown and I4 if (!Open) { return; } Theme theme = Theme; theme.Build(host.TextSize); if (!Mathf.Approximately(stylesFor, theme.S)) { stylesFor = theme.S; amountStyle = new GUIStyle(theme.Field) { padding = new RectOffset(theme.Px(6f), theme.Px(6f), 0, 0), alignment = (TextAnchor)4 }; GUIStyleState normal = amountStyle.normal; GUIStyleState hover = amountStyle.hover; GUIStyleState focused = amountStyle.focused; Texture2D val = (amountStyle.active.background = theme.Solid(Theme.Raised)); Texture2D val3 = (focused.background = val); Texture2D background = (hover.background = val3); normal.background = background; helpStyle = new GUIStyle(theme.Small) { wordWrap = true }; emptyStyle = new GUIStyle(theme.Small) { wordWrap = true, alignment = (TextAnchor)4 }; } GUI.depth = -1000; Event current = Event.current; float num = theme.Px(16f); float num2 = Mathf.Min(Screen.width - theme.Px(32f), theme.Px(660f)); float num3 = Mathf.Min(Screen.height - theme.Px(48f), theme.Px(780f)); Rect val6 = default(Rect); ((Rect)(ref val6))..ctor(Mathf.Round(((float)Screen.width - num2) / 2f), Mathf.Round(((float)Screen.height - num3) / 2f), num2, num3); Drawn = val6; theme.Plate(val6, Theme.Panel, theme.Px(10f)); theme.Outline(val6, Theme.Line, Mathf.Max(1, theme.Px(1f)), theme.Px(10f)); bool flag = ((Rect)(ref val6)).Contains(current.mousePosition); float num4 = ((Rect)(ref val6)).x + num; float num5 = ((Rect)(ref val6)).y + num; float num6 = ((Rect)(ref val6)).width - num * 2f; Texture2D mark = theme.Mark; float num7 = theme.Px(30f); if ((Object)(object)mark != (Object)null && (int)current.type == 7) { GUI.DrawTexture(new Rect(num4, num5 + (float)theme.Px(2f), num7, num7), (Texture)(object)mark, (ScaleMode)2); } Rect val7 = default(Rect); ((Rect)(ref val7))..ctor(num4 + num7 + (float)theme.Px(10f), num5, num6 - num7 - (float)theme.Px(90f), (float)theme.Px(24f)); Rect val8 = default(Rect); ((Rect)(ref val8))..ctor(num4 + num7 + (float)theme.Px(10f), num5 + (float)theme.Px(24f), num6 - num7 - (float)theme.Px(90f), (float)theme.Px(18f)); string text = L.T(client ? "sub.client" : "sub.solo"); GUI.Label(val7, L.T("title"), theme.Title); GUI.Label(val8, text, theme.Sub); Fits("title", theme.Title, L.T("title"), val7, wrap: false); Fits("sub", theme.Sub, text, val8, wrap: false); Fits("sub.client", theme.Sub, L.T("sub.client"), val8, wrap: false); float num8 = theme.Px(30f); Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref val6)).xMax - num - num8, num5, num8, num8); Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(((Rect)(ref r)).x - num8 - (float)theme.Px(6f), num5, num8, num8); if (IconButton(r2, Icon.Help, help)) { help = !help; } if (IconButton(r, Icon.Close, on: false)) { Hide("the close button"); return; } num5 += (float)theme.Px(48f); Rect val9 = default(Rect); ((Rect)(ref val9))..ctor(num4, num5, num6, theme.Field.fixedHeight); GUI.SetNextControlName("gomg-spawn-search"); string text2 = GUI.TextField(val9, query, 60, theme.Field); if (text2 != query) { query = text2; help = false; } theme.DrawIcon(new Rect(((Rect)(ref val9)).x + (float)theme.Px(9f), ((Rect)(ref val9)).y + (((Rect)(ref val9)).height - (float)theme.Px(16f)) / 2f, (float)theme.Px(16f), (float)theme.Px(16f)), Icon.Search, Theme.Muted); if (query.Length == 0 && (int)current.type == 7) { GUI.Label(val9, L.T("search.placeholder"), theme.Placeholder); } Fits("placeholder", theme.Placeholder, L.T("search.placeholder"), new Rect(((Rect)(ref val9)).x, ((Rect)(ref val9)).y, ((Rect)(ref val9)).width - (float)theme.Placeholder.padding.left - (float)theme.Placeholder.padding.right, ((Rect)(ref val9)).height), wrap: false); if (GUI.GetNameOfFocusedControl() == "gomg-spawn-search") { theme.Outline(val9, Theme.Blue, Mathf.Max(1, theme.Px(2f)), theme.Px(4f)); } num5 += ((Rect)(ref val9)).height + (float)theme.Px(10f); float num9 = num4; for (int i = 0; i < 4; i++) { string text3 = TabLabel(i); GUIStyle val10 = ((i == tab) ? theme.TabOn : theme.Tab); float num10 = val10.CalcSize(new GUIContent(text3)).x + (float)theme.Px(4f); if (GUI.Button(new Rect(num9, num5, num10, theme.TabH), text3, val10) && i != tab) { SetTab(i); } num9 += num10 + (float)theme.Px(4f); } string text4 = L.N("count", shown.Count); float x = theme.Small.CalcSize(new GUIContent(text4)).x; GUI.Label(new Rect(((Rect)(ref val6)).xMax - num - x, num5 + (theme.TabH - theme.Small.lineHeight) / 2f, x + 2f, theme.TabH), text4, theme.Small); if (MeasureFit && (int)current.type == 7 && num9 + (float)theme.Px(8f) > ((Rect)(ref val6)).xMax - num - theme.Small.CalcSize(new GUIContent(L.N("count", 999))).x) { Overflow.Add(L.Current + " tabs + count: " + TabLabel(0) + " | " + TabLabel(1) + " | " + TabLabel(2) + " | " + TabLabel(3) + " | " + L.N("count", 999)); } num5 += theme.TabH + (float)theme.Px(8f); if (tab == 1 && !help) { string text5 = L.T("set.button", missing.Count); float num11 = Mathf.Max((float)theme.Px(120f), theme.Primary.CalcSize(new GUIContent(L.T("set.button", 999))).x + (float)theme.Px(8f)); float num12 = num6 - num11 - (float)theme.Px(12f); string text6 = L.T("set.note"); float num13 = Mathf.Max(theme.ButtonH, LinesTall(helpStyle, 2)); Rect val11 = default(Rect); ((Rect)(ref val11))..ctor(num4, num5 + (num13 - LinesTall(helpStyle, 2)) / 2f, num12, LinesTall(helpStyle, 2)); GUI.Label(val11, text6, helpStyle); Fits("set.note", helpStyle, text6, val11, wrap: true); bool enabled = GUI.enabled; GUI.enabled = !host.Busy && missing.Count > 0; if (GUI.Button(new Rect(((Rect)(ref val6)).xMax - num - num11, num5 + (num13 - theme.ButtonH) / 2f, num11, theme.ButtonH), text5, theme.Primary)) { AddSet(); } GUI.enabled = enabled; num5 += num13 + (float)theme.Px(8f); } float num14 = theme.Px(22f); float num15 = LinesTall(theme.Status, 2) + (float)theme.Px(2f); float num16 = DetailHeight(); float num17 = ((Rect)(ref val6)).yMax - num - num14; float num18 = num17 - num15 - (float)theme.Px(4f); float num19 = num18 - num16 - (float)theme.Px(6f); Rect g = default(Rect); ((Rect)(ref g))..ctor(num4, num5, num6, num19 - (float)theme.Px(8f) - num5); if (help) { DrawHelp(new Rect(num4, num5, num6, num19 + num16 - num5), current); } else { DrawGrid(g, current); DrawDetail(new Rect(num4, num19, num6, num16), current); } Rect val12 = default(Rect); ((Rect)(ref val12))..ctor(num4, num18, num6, num15); GUIStyle val13 = (host.Busy ? helpStyle : (statusBad ? theme.StatusBad : theme.Status)); if (!string.IsNullOrEmpty(status)) { GUI.Label(val12, status, val13); } Fits("status", val13, status, val12, wrap: true); DrawPrompts(new Rect(num4, num17, num6, num14)); if (focusSearch && (int)current.type == 7) { GUI.FocusControl("gomg-spawn-search"); focusSearch = false; } if (switchFocus && (int)current.type == 7) { GUI.FocusControl((GUI.GetNameOfFocusedControl() == "gomg-spawn-amount") ? "gomg-spawn-search" : "gomg-spawn-amount"); switchFocus = false; } if (flag && ((int)current.type == 0 || (int)current.type == 1 || (int)current.type == 6)) { current.Use(); } } private bool IconButton(Rect r, Icon icon, bool on) { //IL_000e: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_0021: Unknown result type (might be due to invalid IL or missing references) Theme theme = Theme; bool flag = ((Rect)(ref r)).Contains(Event.current.mousePosition); theme.Plate(r, on ? Theme.Surface : (flag ? Theme.Hover : Theme.Raised), theme.Px(6f)); theme.DrawIcon(new Rect(((Rect)(ref r)).x + (((Rect)(ref r)).width - (float)theme.Px(16f)) / 2f, ((Rect)(ref r)).y + (((Rect)(ref r)).height - (float)theme.Px(16f)) / 2f, (float)theme.Px(16f), (float)theme.Px(16f)), icon, Theme.Ink); return GUI.Button(r, GUIContent.none, GUIStyle.none); } private void DrawGrid(Rect g, Event e) { //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Invalid comparison between Unknown and I4 //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Invalid comparison between Unknown and I4 //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0267: 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_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) Theme theme = Theme; int num = cols; int num2 = visRows; cols = Mathf.Max(1, Mathf.FloorToInt(((Rect)(ref g)).width / theme.CellW)); visRows = Mathf.Max(1, Mathf.FloorToInt(((Rect)(ref g)).height / theme.CellH)); if (cols != num || visRows != num2) { Visible(); } float num3 = ((Rect)(ref g)).width / (float)cols; int num4 = (shown.Count + cols - 1) / cols; top = Mathf.Clamp(top, 0, Mathf.Max(0, num4 - visRows)); if (shown.Count == 0) { string text = ((tab == 3 && query.Trim().Length == 0) ? L.T("empty.recent") : L.T("empty.search", query.Trim())); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref g)).x + (float)theme.Px(24f), ((Rect)(ref g)).y, ((Rect)(ref g)).width - (float)theme.Px(48f), ((Rect)(ref g)).height); GUI.Label(val, text, emptyStyle); Fits("empty", emptyStyle, text, val, wrap: true); return; } if ((int)e.type == 6 && ((Rect)(ref g)).Contains(e.mousePosition)) { top = Mathf.Clamp(top + ((e.delta.y > 0f) ? 1 : (-1)), 0, Mathf.Max(0, num4 - visRows)); e.Use(); } float num5 = theme.Px(6f); Rect r = default(Rect); Rect val2 = default(Rect); for (int i = top; i < Math.Min(num4, top + visRows); i++) { for (int j = 0; j < cols; j++) { int num6 = i * cols + j; if (num6 >= shown.Count) { break; } ((Rect)(ref r))..ctor(((Rect)(ref g)).x + (float)j * num3, ((Rect)(ref g)).y + (float)(i - top) * theme.CellH, num3 - num5, theme.CellH - num5); bool flag = ((Rect)(ref r)).Contains(e.mousePosition); bool flag2 = num6 == sel; theme.Plate(r, flag2 ? Theme.Selected : (flag ? Theme.Hover : Theme.Surface), theme.Px(6f)); if (flag2) { theme.Outline(r, Theme.Blue, Mathf.Max(1, theme.Px(2f)), theme.Px(6f)); } ItemEntry itemEntry = shown[num6]; float iconSize = theme.IconSize; Theme.DrawSprite(new Rect(((Rect)(ref r)).x + (((Rect)(ref r)).width - iconSize) / 2f, ((Rect)(ref r)).y + (float)theme.Px(6f), iconSize, iconSize), Catalog.Icon(itemEntry)); ((Rect)(ref val2))..ctor(((Rect)(ref r)).x + (float)theme.Px(4f), ((Rect)(ref r)).y + (float)theme.Px(8f) + iconSize, ((Rect)(ref r)).width - (float)theme.Px(8f), ((Rect)(ref r)).height - iconSize - (float)theme.Px(10f)); GUIStyle style; string text2 = Fit(itemEntry.Name, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height, out style); GUI.Label(val2, text2, style); if ((int)e.type == 0 && e.button == 0 && flag) { sel = num6; if (e.clickCount >= 2) { Add(null, fill: false); } e.Use(); } } } if (num4 > visRows && (int)e.type == 7) { Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(((Rect)(ref g)).xMax - (float)theme.Px(3f), ((Rect)(ref g)).y, (float)theme.Px(3f),