using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("AAABuildMenu")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Azumatt")] [assembly: AssemblyProduct("AAABuildMenu")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: AssemblyFileVersion("1.0.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class ExtensionMarkerAttribute : Attribute { public ExtensionMarkerAttribute(string name) { } } } namespace LocalizationManager { [PublicAPI] public class Localizer { private static readonly Dictionary>> PlaceholderProcessors; private static readonly Dictionary> loadedTexts; private static readonly ConditionalWeakTable localizationLanguage; private static readonly List> localizationObjects; private static BaseUnityPlugin? _plugin; private static readonly List fileExtensions; private static BaseUnityPlugin plugin { get { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown if (_plugin == null) { IEnumerable source; try { source = Assembly.GetExecutingAssembly().DefinedTypes.ToList(); } catch (ReflectionTypeLoadException ex) { source = from t in ex.Types where t != null select t.GetTypeInfo(); } _plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t))); } return _plugin; } } public static event Action? OnLocalizationComplete; private static void UpdatePlaceholderText(Localization localization, string key) { localizationLanguage.TryGetValue(localization, out string value); string text = loadedTexts[value][key]; if (PlaceholderProcessors.TryGetValue(key, out Dictionary> value2)) { text = value2.Aggregate(text, (string current, KeyValuePair> kv) => current.Replace("{" + kv.Key + "}", kv.Value())); } localization.AddWord(key, text); } public static void AddPlaceholder(string key, string placeholder, ConfigEntry config, Func? convertConfigValue = null) where T : notnull { if (convertConfigValue == null) { convertConfigValue = (T val) => val.ToString(); } if (!PlaceholderProcessors.ContainsKey(key)) { PlaceholderProcessors[key] = new Dictionary>(); } config.SettingChanged += delegate { UpdatePlaceholder(); }; if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage())) { UpdatePlaceholder(); } void UpdatePlaceholder() { PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value); UpdatePlaceholderText(Localization.instance, key); } } public static void AddText(string key, string text) { List> list = new List>(); foreach (WeakReference localizationObject in localizationObjects) { if (localizationObject.TryGetTarget(out var target)) { Dictionary dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)]; if (!target.m_translations.ContainsKey(key)) { dictionary[key] = text; target.AddWord(key, text); } } else { list.Add(localizationObject); } } foreach (WeakReference item in list) { localizationObjects.Remove(item); } } public static void Load() { _ = plugin; } public static void LoadLocalizationLater(Localization __instance) { LoadLocalization(Localization.instance, __instance.GetSelectedLanguage()); } public static void SafeCallLocalizeComplete() { Localizer.OnLocalizationComplete?.Invoke(); } private static void LoadLocalization(Localization __instance, string language) { if (!localizationLanguage.Remove(__instance)) { localizationObjects.Add(new WeakReference(__instance)); } localizationLanguage.Add(__instance, language); Dictionary dictionary = new Dictionary(); foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories) where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0 select f) { string[] array = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' }); if (array.Length >= 2) { string text = array[1]; if (dictionary.ContainsKey(text)) { Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped.")); } else { dictionary[text] = item; } } } byte[] array2 = LoadTranslationFromAssembly("English"); if (array2 == null) { throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml."); } Dictionary dictionary2 = new DeserializerBuilder().IgnoreFields().Build().Deserialize>(Encoding.UTF8.GetString(array2)); if (dictionary2 == null) { throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty."); } string text2 = null; if (language != "English") { if (dictionary.TryGetValue(language, out var value)) { text2 = File.ReadAllText(value); } else { byte[] array3 = LoadTranslationFromAssembly(language); if (array3 != null) { text2 = Encoding.UTF8.GetString(array3); } } } if (text2 == null && dictionary.TryGetValue("English", out var value2)) { text2 = File.ReadAllText(value2); } if (text2 != null) { foreach (KeyValuePair item2 in new DeserializerBuilder().IgnoreFields().Build().Deserialize>(text2) ?? new Dictionary()) { dictionary2[item2.Key] = item2.Value; } } loadedTexts[language] = dictionary2; foreach (KeyValuePair item3 in dictionary2) { UpdatePlaceholderText(__instance, item3.Key); } } static Localizer() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_008f: 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_00ca: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown PlaceholderProcessors = new Dictionary>>(); loadedTexts = new Dictionary>(); localizationLanguage = new ConditionalWeakTable(); localizationObjects = new List>(); fileExtensions = new List(2) { ".json", ".yml" }; Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager"); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "SetupGui", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalizationLater", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "SafeCallLocalizeComplete", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static byte[]? LoadTranslationFromAssembly(string language) { foreach (string fileExtension in fileExtensions) { byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension); if (array != null) { return array; } } return null; } public static byte[]? ReadEmbeddedFileBytes(string resourceFileName, Assembly? containingAssembly = null) { using MemoryStream memoryStream = new MemoryStream(); if ((object)containingAssembly == null) { containingAssembly = Assembly.GetCallingAssembly(); } string text = containingAssembly.GetManifestResourceNames().FirstOrDefault((string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal)); if (text != null) { containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream); } return (memoryStream.Length == 0L) ? null : memoryStream.ToArray(); } } public static class LocalizationManagerVersion { public const string Version = "1.4.1"; } } namespace AAABuildMenu { public static class BuildMenuKeyHints { private static GameObject? _rowHolder; private static GameObject? _favoriteRow; private static GameObject? _pinRow; private static GameObject? _searchRow; private const string FavoriteToken = "$aaabuildmenu_hint_favorite"; private const string PinToken = "$aaabuildmenu_hint_pin"; private const string SearchToken = "$aaabuildmenu_hint_search"; private static TMP_Text? _favoriteKey; private static TMP_Text? _pinKey; private static TMP_Text? _searchKey; private static TMP_Text? _favoriteLabel; private static TMP_Text? _pinLabel; private static TMP_Text? _searchLabel; private static bool _configHooked; private static KeyHints? _owner; public static void Refresh(KeyHints kh) { if (!((Object)(object)kh == (Object)null) && !((Object)(object)kh.m_buildHints == (Object)null)) { if ((Object)(object)_owner != (Object)(object)kh) { _rowHolder = (_favoriteRow = (_pinRow = (_searchRow = null))); _favoriteKey = (_pinKey = (_searchKey = null)); _favoriteLabel = (_pinLabel = (_searchLabel = null)); _owner = kh; } if (AAABuildMenuPlugin.ShowKeyHints.Value.IsOff()) { SetActive(_rowHolder, active: false); return; } EnsureRows(kh); SetActive(_favoriteRow, active: true); SetActive(_pinRow, AAABuildMenuPlugin.EnablePinning.Value.IsOn()); SetActive(_searchRow, AAABuildMenuPlugin.EnableSearch.Value.IsOn()); Transform keyboardGroup = GetKeyboardGroup(kh); bool flag = (Object)(object)keyboardGroup != (Object)null && ((Component)keyboardGroup).gameObject.activeInHierarchy; SetActive(_rowHolder, Hud.IsPieceSelectionVisible() && flag); } } private static Transform? GetKeyboardGroup(KeyHints kh) { UIInputHint component = kh.m_buildHints.GetComponent(); GameObject val = (((Object)(object)component != (Object)null) ? component.m_mouseKeyboardHint : null); if (!((Object)(object)val != (Object)null)) { return null; } return val.transform; } private static void EnsureRows(KeyHints kh) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown Transform keyboardGroup = GetKeyboardGroup(kh); Transform val = (((Object)(object)keyboardGroup != (Object)null) ? FindHintItemTemplate(keyboardGroup) : null); if (!((Object)(object)keyboardGroup == (Object)null) && !((Object)(object)val == (Object)null)) { if ((Object)(object)_rowHolder == (Object)null) { _rowHolder = CreateRowHolder(kh, (RectTransform)keyboardGroup); } Transform transform = _rowHolder.transform; Transform template = keyboardGroup.Find("Copy") ?? val; string mouseLeft = GetKeycapText(keyboardGroup.Find("Place")) ?? "Mouse-1"; if ((Object)(object)_favoriteRow == (Object)null) { _favoriteRow = CreateClickRow(template, transform, "AAABuildMenu_FavoriteHint", "$aaabuildmenu_hint_favorite", mouseLeft, out _favoriteKey, out _favoriteLabel); } if ((Object)(object)_pinRow == (Object)null) { _pinRow = CreateClickRow(template, transform, "AAABuildMenu_PinHint", "$aaabuildmenu_hint_pin", mouseLeft, out _pinKey, out _pinLabel); } if ((Object)(object)_searchRow == (Object)null) { _searchRow = CreateSingleKeyRow(val, transform, "AAABuildMenu_SearchHint", "$aaabuildmenu_hint_search", out _searchKey, out _searchLabel); } ApplyKeyText(); HookConfigOnce(); } } private static void ApplyKeyText() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_favoriteKey != (Object)null) { _favoriteKey.text = Format(AAABuildMenuPlugin.QuickFavoriteModifier.Value); } if ((Object)(object)_pinKey != (Object)null) { _pinKey.text = Format(AAABuildMenuPlugin.QuickPinModifier.Value); } if ((Object)(object)_searchKey != (Object)null) { _searchKey.text = Format(AAABuildMenuPlugin.FocusSearchKey.Value); } } private static void OnLanguageChanged() { if ((Object)(object)_favoriteLabel != (Object)null) { _favoriteLabel.text = Localization.instance.Localize("$aaabuildmenu_hint_favorite"); } if ((Object)(object)_pinLabel != (Object)null) { _pinLabel.text = Localization.instance.Localize("$aaabuildmenu_hint_pin"); } if ((Object)(object)_searchLabel != (Object)null) { _searchLabel.text = Localization.instance.Localize("$aaabuildmenu_hint_search"); } } private static void HookConfigOnce() { if (!_configHooked) { _configHooked = true; AAABuildMenuPlugin.QuickFavoriteModifier.SettingChanged += Apply; AAABuildMenuPlugin.QuickPinModifier.SettingChanged += Apply; AAABuildMenuPlugin.FocusSearchKey.SettingChanged += Apply; Localization.OnLanguageChange = (Action)Delegate.Combine(Localization.OnLanguageChange, new Action(OnLanguageChanged)); } static void Apply(object _, EventArgs __) { ApplyKeyText(); } } private static GameObject CreateRowHolder(KeyHints kh, RectTransform vanillaRow) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) //IL_0029: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown GameObject val = new GameObject("AAABuildMenu_HintRow"); val.transform.SetParent(kh.m_buildHints.transform, false); RectTransform obj = val.AddComponent(); obj.anchorMin = vanillaRow.anchorMin; obj.anchorMax = vanillaRow.anchorMax; obj.pivot = vanillaRow.pivot; obj.sizeDelta = vanillaRow.sizeDelta; Rect rect = vanillaRow.rect; float num = ((Rect)(ref rect)).height; if (num <= 1f) { num = 34f; } obj.anchoredPosition = vanillaRow.anchoredPosition + new Vector2(0f, num + 6f); HorizontalLayoutGroup component = ((Component)vanillaRow).GetComponent(); HorizontalLayoutGroup val2 = val.AddComponent(); if ((Object)(object)component != (Object)null) { ((HorizontalOrVerticalLayoutGroup)val2).spacing = ((HorizontalOrVerticalLayoutGroup)component).spacing; ((LayoutGroup)val2).padding = ((LayoutGroup)component).padding; ((LayoutGroup)val2).childAlignment = ((LayoutGroup)component).childAlignment; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = ((HorizontalOrVerticalLayoutGroup)component).childControlWidth; ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = ((HorizontalOrVerticalLayoutGroup)component).childControlHeight; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = ((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = ((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight; return val; } ((LayoutGroup)val2).childAlignment = (TextAnchor)4; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false; return val; } private static GameObject CreateClickRow(Transform template, Transform container, string name, string labelToken, string mouseLeft, out TMP_Text? modifierKey, out TMP_Text? label) { GameObject val = Object.Instantiate(((Component)template).gameObject, container); ((Object)val).name = name; val.transform.SetAsLastSibling(); List list = CollectKeycaps(val.transform); modifierKey = ((list.Count > 0) ? list[0] : null); if (list.Count >= 2) { list[1].text = mouseLeft; } label = SetLabel(val.transform, labelToken); val.SetActive(false); return val; } private static GameObject CreateSingleKeyRow(Transform template, Transform container, string name, string labelToken, out TMP_Text? key, out TMP_Text? label) { GameObject val = Object.Instantiate(((Component)template).gameObject, container); ((Object)val).name = name; val.transform.SetAsLastSibling(); Transform val2 = val.transform.Find("key_bkg/Key"); key = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent() : null); label = SetLabel(val.transform, labelToken); val.SetActive(false); return val; } private static TMP_Text? SetLabel(Transform row, string labelToken) { Transform val = row.Find("Text"); TMP_Text val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)val2 == (Object)null) { return null; } Localize component = ((Component)val2).GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } val2.text = Localization.instance.Localize(labelToken); val2.textWrappingMode = (TextWrappingModes)0; val2.overflowMode = (TextOverflowModes)0; return val2; } private static List CollectKeycaps(Transform row) { List list = new List(); for (int i = 0; i < row.childCount; i++) { Transform child = row.GetChild(i); if (((Object)child).name.StartsWith("key_bkg")) { Transform val = child.Find("Key"); TMP_Text val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)val2 != (Object)null) { list.Add(val2); } } } return list; } private static string? GetKeycapText(Transform? item) { if ((Object)(object)item == (Object)null) { return null; } Transform val = item.Find("key_bkg/Key"); TMP_Text val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if (!((Object)(object)val2 != (Object)null)) { return null; } return val2.text; } private static Transform? FindHintItemTemplate(Transform keyboardGroup) { for (int i = 0; i < keyboardGroup.childCount; i++) { Transform child = keyboardGroup.GetChild(i); if (!((Object)child).name.StartsWith("AAABuildMenu_") && (Object)(object)child.Find("key_bkg/Key") != (Object)null && (Object)(object)child.Find("Text") != (Object)null) { return child; } } return null; } private static void SetActive(GameObject? go, bool active) { if ((Object)(object)go != (Object)null && go.activeSelf != active) { go.SetActive(active); } } private static string Format(KeyboardShortcut shortcut) { //IL_0002: 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) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0) { return ""; } List list = ((KeyboardShortcut)(ref shortcut)).Modifiers.Select(Pretty).ToList(); list.Add(Pretty(((KeyboardShortcut)(ref shortcut)).MainKey)); return string.Join("+", list); } private unsafe static string Pretty(KeyCode key) { //IL_0000: 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_0024: Expected I4, but got Unknown switch (key - 303) { case 0: case 1: return "Shift"; case 2: case 3: return "Ctrl"; case 4: case 5: return "Alt"; default: return ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString(); } } } [RequireComponent(typeof(CanvasGroup))] public abstract class BuildMenuGripHandle : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IBeginDragHandler, IDragHandler, IEndDragHandler { private CanvasGroup _cg; private float _scale = 1f; private bool _dragging; private bool _hovered; protected virtual void Awake() { _cg = ((Component)this).GetComponent(); Canvas componentInParent = ((Component)this).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && componentInParent.scaleFactor > 0f) { _scale = componentInParent.scaleFactor; } } private void Update() { float num = ((_dragging || _hovered) ? 1f : 0f); _cg.alpha = Mathf.MoveTowards(_cg.alpha, num, Time.unscaledDeltaTime * 8f); } public void OnPointerEnter(PointerEventData eventData) { _hovered = true; } public void OnPointerExit(PointerEventData eventData) { _hovered = false; } public void OnBeginDrag(PointerEventData eventData) { _dragging = true; } public void OnDrag(PointerEventData eventData) { //IL_0002: 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) Apply(eventData.delta / _scale); } public void OnEndDrag(PointerEventData eventData) { _dragging = false; EnhancedBuildMenu.OnGripDragEnd(); } protected abstract void Apply(Vector2 scaledDelta); } public class BuildMenuResizeHandle : BuildMenuGripHandle { protected override void Apply(Vector2 scaledDelta) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) EnhancedBuildMenu.OnResizeDrag(scaledDelta); } } public class BuildMenuMoveHandle : BuildMenuGripHandle { protected override void Apply(Vector2 scaledDelta) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) EnhancedBuildMenu.OnMoveDrag(scaledDelta); } } public static class EnhancedBuildMenu { [CompilerGenerated] private static class <>O { public static Func <0>__PieceUsesAnySelectedMaterial; public static Func <1>__TotalResourceCost; public static UnityAction <2>__OnSearchTextChanged; public static UnityAction <3>__ClearSearch; public static UnityAction <4>__ResetAllFilters; public static UnityAction <5>__CycleSortMode; public static UnityAction <6>__DeselectCurrent; } internal static int Columns = 15; private const float ScrollbarGutter = 10f; private static GameObject _searchBarObject = null; private static TMP_InputField _searchInputField = null; private static ScrollRect _scrollRect = null; private static GameObject _clearSearchButton = null; private static bool _isInitialized; private static readonly PieceFilterState _currentFilter = new PieceFilterState(); private static GameObject _filterButtonRow = null; private static FilterButton? _allButton; private static FilterButton _canCraftButton = null; private static FilterButton _missingMaterialsButton = null; private static FilterButton _favoritesButton = null; private static FilterButton? _recentButton; private static GameObject _sortButton = null; private static TMP_Text _sortButtonText = null; private static TMP_Text _matchCountText = null; private static GameObject _materialsButton = null; private static GameObject _materialsDropdown = null; private static TMP_InputField _materialsSearchField = null; private static readonly HashSet _selectedMaterials = new HashSet(); private static readonly Dictionary _favoriteStars = new Dictionary(); private static readonly Dictionary _favoriteBorders = new Dictionary(); private static Sprite _favoriteBorderSprite = null; private static readonly Dictionary _pinIndicators = new Dictionary(); private static bool _pinConfigHooked; private static readonly Dictionary _prefabNameCache = new Dictionary(); private static readonly Dictionary> _categoryMasters = new Dictionary>(); private static Coroutine? _searchDebounceCoroutine; private const float SearchDebounceDelay = 0.15f; private static Vector2 _origContentSize; private static Vector2 _origContentAnchoredPos; private static bool _origCaptured; private static bool _maskAdjusted; private static Vector2 _origMaskOffsetMax; private static bool _origMaskCaptured; private static bool _liveConfigHooked; private const float SearchStripHeight = 30f; private const float FilterStripHeight = 26f; private const float CountStripHeight = 18f; private const float StripGap = 2f; private static TMP_FontAsset _uiFont = null; private static GameObject _tooltipPrefab = null; private static Sprite _buttonSprite = null; private static Hud _hud = null; private static RectTransform _resizeHandle = null; private static RectTransform _moveHandle = null; private static Sprite _vanillaButtonSprite = null; private static SpriteState _vanillaButtonSpriteState; private static ColorBlock _vanillaButtonColors; private static bool _vanillaButtonUsesSpriteSwap; private static bool _vanillaButtonResolved; private static bool _hasVanillaButton; private static readonly Color InactiveButtonColor = Color.white; private static readonly Color ActiveButtonColor = new Color(1f, 0.78f, 0.36f, 1f); private static PieceCategory _lastScrollCategory = (PieceCategory)(-999); internal static Piece? SelectedPiece; private static RectTransform _materialsListContent = null; private const float MatDropdownPad = 4f; private const float MatSearchHeight = 26f; private const float MatScrollbarWidth = 9f; private static readonly Color InactiveFilterColor = InactiveButtonColor; private static readonly Color ActiveFilterColor = ActiveButtonColor; private static Vector2 _origWindowSize; private static Vector2 _origWindowPos; private static bool _origWinCaptured; private static readonly Color GripColor = new Color(0.565f, 0.792f, 0.976f, 0.85f); private static readonly Dictionary _spriteCache = new Dictionary(); private static Sprite[] _allSprites = null; private static GameObject? _clickSfxPrefab; private static bool _sfxResolved; public static bool Active { get { if (_isInitialized) { return AAABuildMenuPlugin.EnableEnhancedMenu.Value.IsOn(); } return false; } } public static bool NeedsRefresh { get; set; } public static bool IsInitialized => _isInitialized; private static bool SearchEnabled => AAABuildMenuPlugin.EnableSearch.Value.IsOn(); private static bool FiltersEnabled => AAABuildMenuPlugin.EnableFilters.Value.IsOn(); private static bool CountEnabled => AAABuildMenuPlugin.ShowMatchCount.Value.IsOn(); internal static bool ShouldConsumeScroll() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown if (!Active || !Hud.IsPieceSelectionVisible()) { return false; } Vector2 val = Vector2.op_Implicit(Input.mousePosition); if ((Object)(object)_scrollRect != (Object)null && (Object)(object)_scrollRect.viewport != (Object)null && RectTransformUtility.RectangleContainsScreenPoint(_scrollRect.viewport, val, (Camera)null)) { return true; } if ((Object)(object)_materialsDropdown != (Object)null && _materialsDropdown.activeSelf && RectTransformUtility.RectangleContainsScreenPoint((RectTransform)_materialsDropdown.transform, val, (Camera)null)) { return true; } return false; } internal static float CellSpacing(Hud hud) { return (((Object)(object)hud != (Object)null && hud.m_pieceIconSpacing > 0f) ? hud.m_pieceIconSpacing : 64f) * Mathf.Clamp(AAABuildMenuPlugin.IconScale.Value, 0.5f, 2f); } internal static int ComputeColumns(Hud hud) { //IL_0045: 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) if ((Object)(object)hud == (Object)null) { return 15; } float num = CellSpacing(hud); float num2; if (!((Object)(object)_scrollRect != (Object)null) || !((Object)(object)_scrollRect.viewport != (Object)null)) { num2 = 15f * num; } else { Rect rect = _scrollRect.viewport.rect; num2 = ((Rect)(ref rect)).width; } return Mathf.Clamp(Mathf.FloorToInt((num2 - 10f) / num + 0.01f), 1, 64); } internal static int RowCount(int count) { return Mathf.Max(1, Mathf.CeilToInt((float)count / (float)Columns)); } private static string PrefabName(Piece piece) { if ((Object)(object)piece == (Object)null) { return string.Empty; } if (_prefabNameCache.TryGetValue(piece, out string value)) { return value; } value = Utils.GetPrefabName(((Component)piece).gameObject); _prefabNameCache[piece] = value; return value; } public static void InitializeUI(Hud hud) { if (_isInitialized || (Object)(object)hud == (Object)null) { return; } try { AAABuildMenuPlugin.AAABuildMenuLogger.LogInfo((object)"Initializing Enhanced Build Menu..."); _hud = hud; CacheVanillaButtonSprite(hud); CloneVanillaButtonStyle(); ApplySavedWindowTransform(hud); SetupScrollView(hud); BuildHeaderUI(hud); HookPinIndicatorConfig(); HookLiveConfig(); _isInitialized = true; AAABuildMenuPlugin.AAABuildMenuLogger.LogInfo((object)"Enhanced Build Menu initialized successfully!"); } catch (Exception ex) { AAABuildMenuPlugin.AAABuildMenuLogger.LogError((object)("Failed to initialize Enhanced Build Menu: " + ex.Message)); AAABuildMenuPlugin.AAABuildMenuLogger.LogError((object)ex.StackTrace); _isInitialized = false; } } private static void BuildHeaderUI(Hud hud) { ReserveHeaderSpace(hud); if (AAABuildMenuPlugin.EnableResize.Value.IsOn()) { CreateResizeHandle(hud); CreateMoveHandle(hud); } if (AAABuildMenuPlugin.EnableSearch.Value.IsOn()) { CreateSearchBar(hud); } if (AAABuildMenuPlugin.EnableFilters.Value.IsOn()) { CreateFilterButtons(hud); } if (AAABuildMenuPlugin.ShowMatchCount.Value.IsOn()) { CreateMatchCountLabel(hud); } RectTransform resizeHandle = _resizeHandle; if (resizeHandle != null) { ((Transform)resizeHandle).SetAsLastSibling(); } RectTransform moveHandle = _moveHandle; if (moveHandle != null) { ((Transform)moveHandle).SetAsLastSibling(); } } private static void RebuildEnhancedUI() { //IL_012c: Unknown result type (might be due to invalid IL or missing references) if (!_isInitialized || (Object)(object)_hud == (Object)null) { return; } try { if ((Object)(object)_searchBarObject != (Object)null) { Object.Destroy((Object)(object)_searchBarObject); } if ((Object)(object)_filterButtonRow != (Object)null) { Object.Destroy((Object)(object)_filterButtonRow); } if ((Object)(object)_matchCountText != (Object)null) { Object.Destroy((Object)(object)((Component)_matchCountText).gameObject); } if ((Object)(object)_materialsDropdown != (Object)null) { Object.Destroy((Object)(object)_materialsDropdown); } if ((Object)(object)_resizeHandle != (Object)null) { Object.Destroy((Object)(object)((Component)_resizeHandle).gameObject); } if ((Object)(object)_moveHandle != (Object)null) { Object.Destroy((Object)(object)((Component)_moveHandle).gameObject); } _searchBarObject = null; _filterButtonRow = null; _matchCountText = null; _materialsButton = null; _materialsDropdown = null; _materialsSearchField = null; _resizeHandle = null; _moveHandle = null; _sortButton = null; _sortButtonText = null; _allButton = (_recentButton = null); _canCraftButton = (_missingMaterialsButton = (_favoritesButton = null)); if (_origMaskCaptured && (Object)(object)_hud.m_pieceListMask != (Object)null) { _hud.m_pieceListMask.offsetMax = _origMaskOffsetMax; } _maskAdjusted = false; BuildHeaderUI(_hud); NeedsRefresh = true; } catch (Exception ex) { AAABuildMenuPlugin.AAABuildMenuLogger.LogError((object)("Error rebuilding enhanced UI: " + ex.Message)); } } private static void HookLiveConfig() { if (!_liveConfigHooked) { _liveConfigHooked = true; AAABuildMenuPlugin.EnableSearch.SettingChanged += Rebuild; AAABuildMenuPlugin.EnableFilters.SettingChanged += Rebuild; AAABuildMenuPlugin.ShowMatchCount.SettingChanged += Rebuild; AAABuildMenuPlugin.EnableResize.SettingChanged += Rebuild; AAABuildMenuPlugin.EnableRecentFilter.SettingChanged += Rebuild; AAABuildMenuPlugin.SearchAllCategories.SettingChanged += Rebuild; AAABuildMenuPlugin.DefaultSortMode.SettingChanged += delegate { UpdateSortButtonLabel(); NeedsRefresh = true; }; } static void Rebuild(object _, EventArgs __) { RebuildEnhancedUI(); } } private static void SetupScrollView(Hud hud) { //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_007a: 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_0179: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hud.m_pieceListRoot == (Object)null || (Object)(object)hud.m_pieceListMask == (Object)null) { AAABuildMenuPlugin.AAABuildMenuLogger.LogWarning((object)"Piece list root/mask is null, cannot setup scroll view"); return; } Transform transform = ((Component)hud.m_pieceListMask).transform; _scrollRect = ((Component)transform).GetComponent(); if ((Object)(object)_scrollRect == (Object)null) { _scrollRect = ((Component)transform).gameObject.AddComponent(); } RectTransform pieceListRoot = hud.m_pieceListRoot; if (!_origCaptured) { _origContentSize = pieceListRoot.sizeDelta; _origContentAnchoredPos = pieceListRoot.anchoredPosition; _origCaptured = true; } _scrollRect.content = pieceListRoot; _scrollRect.viewport = hud.m_pieceListMask; _scrollRect.horizontal = false; _scrollRect.vertical = true; _scrollRect.movementType = (MovementType)2; _scrollRect.inertia = true; _scrollRect.decelerationRate = 0.135f; _scrollRect.scrollSensitivity = ((hud.m_pieceIconSpacing > 0f) ? hud.m_pieceIconSpacing : 64f) * 4f; if ((Object)(object)((Component)hud.m_pieceListMask).GetComponent() == (Object)null && (Object)(object)((Component)hud.m_pieceListMask).GetComponent() == (Object)null) { ((Component)hud.m_pieceListMask).gameObject.AddComponent(); } if ((Object)(object)((Component)hud.m_pieceListMask).GetComponent() == (Object)null) { Image obj = ((Component)hud.m_pieceListMask).gameObject.AddComponent(); ((Graphic)obj).color = new Color(0f, 0f, 0f, 0f); ((Graphic)obj).raycastTarget = true; } CreateScrollbar(hud); AAABuildMenuPlugin.AAABuildMenuLogger.LogInfo((object)"ScrollRect configured successfully"); } internal static TMP_FontAsset GetUiFont(Hud hud) { if ((Object)(object)_uiFont != (Object)null) { return _uiFont; } if ((Object)(object)hud != (Object)null && (Object)(object)hud.m_buildSelection != (Object)null && (Object)(object)hud.m_buildSelection.font != (Object)null) { _uiFont = hud.m_buildSelection.font; } else { _uiFont = Resources.FindObjectsOfTypeAll().FirstOrDefault(); } return _uiFont; } internal static TMP_Text CreateText(Transform parent, string name, TMP_FontAsset font, float fontSize, Color color, TextAlignmentOptions align, bool stretch = false) { //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_000d: 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_0039: 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_0053: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.SetActive(false); val.transform.SetParent(parent, false); TextMeshProUGUI val2 = val.AddComponent(); if ((Object)(object)font != (Object)null) { ((TMP_Text)val2).font = font; } ((TMP_Text)val2).fontSize = fontSize; ((Graphic)val2).color = color; ((TMP_Text)val2).alignment = align; if (stretch) { RectTransform rectTransform = ((TMP_Text)val2).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.sizeDelta = Vector2.zero; rectTransform.anchoredPosition = Vector2.zero; } val.SetActive(true); return (TMP_Text)(object)val2; } private static GameObject GetTooltipPrefab(Hud hud) { if ((Object)(object)_tooltipPrefab != (Object)null) { return _tooltipPrefab; } UITooltip val = (((Object)(object)hud.m_pieceIconPrefab != (Object)null) ? hud.m_pieceIconPrefab.GetComponent() : null); if ((Object)(object)val == (Object)null || (Object)(object)val.m_tooltipPrefab == (Object)null) { val = hud.m_pieceSelectionWindow.GetComponentInChildren(true); } if ((Object)(object)val != (Object)null) { _tooltipPrefab = val.m_tooltipPrefab; } return _tooltipPrefab; } internal static UITooltip AddTooltip(GameObject go, string text, Hud hud) { UITooltip val = go.AddComponent(); val.m_text = text; GameObject tooltipPrefab = GetTooltipPrefab(hud); if ((Object)(object)tooltipPrefab != (Object)null) { val.m_tooltipPrefab = tooltipPrefab; } return val; } private static void CreateScrollbar(Hud hud) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00b0: 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_00c4: 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_00de: 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_00f4: 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) GameObject val = new GameObject("EnhancedMenuScrollbar"); val.transform.SetParent(((Component)hud.m_pieceListMask).transform, false); RectTransform obj = val.AddComponent(); obj.anchorMin = new Vector2(1f, 0f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(1f, 0.5f); obj.anchoredPosition = new Vector2(-1f, 0f); obj.sizeDelta = new Vector2(9f, 0f); Image obj2 = val.AddComponent(); StyleButtonImage(obj2); ((Graphic)obj2).color = new Color(0.191f, 0.078f, 0.078f, 1f); GameObject val2 = new GameObject("Handle"); val2.transform.SetParent(val.transform, false); RectTransform val3 = val2.AddComponent(); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.sizeDelta = Vector2.zero; Image val4 = val2.AddComponent(); StyleButtonImage(val4); ((Graphic)val4).color = new Color(0.8529f, 0.725f, 0.5331f, 1f); Scrollbar val5 = val.AddComponent(); val5.handleRect = val3; val5.direction = (Direction)2; ((Selectable)val5).targetGraphic = (Graphic)(object)val4; DisableNavigationAndSelection((Selectable)(object)val5); _scrollRect.verticalScrollbar = val5; _scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)1; AAABuildMenuPlugin.AAABuildMenuLogger.LogDebug((object)"Scrollbar created successfully"); } public static void RenderPieceList(Hud hud, Player player, Vector2Int selectedNr, PieceCategory category, bool updateAllBuildStatuses) { //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0226: 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_0219: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00ed: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) List list = player.GetBuildPieces() ?? new List(); int count = list.Count; Columns = ComputeColumns(hud); int num = ((Vector2Int)(ref selectedNr)).y * Columns + ((Vector2Int)(ref selectedNr)).x; if (num >= 0 && num < count) { SelectedPiece = list[num]; } EnsureIconCount(hud, Mathf.Max(count, 1)); float num2 = CellSpacing(hud); for (int i = 0; i < hud.m_pieceIcons.Count; i++) { PieceIconData val = hud.m_pieceIcons[i]; if ((Object)(object)val?.m_go == (Object)null) { continue; } int num3 = i % Columns; int num4 = i / Columns; if (i < count) { Piece val2 = list[i]; if (!val.m_go.activeSelf) { val.m_go.SetActive(true); } RectTransform val3 = (RectTransform)val.m_go.transform; val3.anchorMin = new Vector2(0f, 1f); val3.anchorMax = new Vector2(0f, 1f); ((Transform)val3).localScale = Vector3.one; val3.sizeDelta = new Vector2(num2, num2); val3.anchoredPosition = new Vector2((float)num3 * num2, (float)(-num4) * num2); val.m_marker.SetActive(new Vector2Int(num3, num4) == selectedNr); val.m_icon.sprite = val2.m_icon; ((Behaviour)val.m_icon).enabled = true; val.m_tooltip.m_text = val2.m_name; val.m_upgrade.SetActive(val2.m_isUpgrade); } else { val.m_marker.SetActive(false); ((Behaviour)val.m_icon).enabled = false; val.m_tooltip.m_text = ""; val.m_upgrade.SetActive(false); if (val.m_go.activeSelf) { val.m_go.SetActive(false); } } } hud.UpdatePieceBuildStatus(list, player); if (updateAllBuildStatuses || hud.m_lastPieceCategory != category) { hud.UpdatePieceBuildStatusAll(list, player); hud.m_lastPieceCategory = category; } bool num5 = category != _lastScrollCategory; _lastScrollCategory = category; UpdateScrollViewContentSize(count, num2); UpdateMatchCount(count); if (num5) { ScrollToTop(); if (GlobalActive()) { NeedsRefresh = true; } } if (AAABuildMenuPlugin.EnableEnhancedMenu.Value.IsOn()) { UpdateFavoriteStars(hud, list); UpdatePinIndicators(hud, list); } } private static void EnsureIconCount(Hud hud, int required) { while (hud.m_pieceIcons.Count < required) { hud.m_pieceIcons.Add(CreatePieceIcon(hud)); } } private static PieceIconData CreatePieceIcon(Hud hud) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected O, but got Unknown GameObject val = Object.Instantiate(hud.m_pieceIconPrefab, (Transform)(object)hud.m_pieceListRoot); PieceIconData val2 = new PieceIconData { m_go = val, m_tooltip = val.GetComponent(), m_icon = ((Component)val.transform.Find("icon")).GetComponent(), m_marker = ((Component)val.transform.Find("selected")).gameObject, m_upgrade = ((Component)val.transform.Find("upgrade")).gameObject }; ((Graphic)val2.m_icon).color = Hud.s_colorRedBlueZeroAlpha; UIInputHandler component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.m_onLeftDown = (Action)Delegate.Combine(component.m_onLeftDown, new Action(hud.OnLeftClickPiece)); component.m_onRightDown = (Action)Delegate.Combine(component.m_onRightDown, new Action(hud.OnRightClickPiece)); component.m_onPointerEnter = (Action)Delegate.Combine(component.m_onPointerEnter, new Action(hud.OnHoverPiece)); component.m_onPointerExit = (Action)Delegate.Combine(component.m_onPointerExit, new Action(hud.OnHoverPieceExit)); } return val2; } public static Vector2Int GetSelectedGridAll(Hud hud, UIInputHandler ih) { //IL_0019: 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_0056: Unknown result type (might be due to invalid IL or missing references) if (hud?.m_pieceIcons == null || (Object)(object)ih == (Object)null) { return new Vector2Int(-1, -1); } for (int i = 0; i < hud.m_pieceIcons.Count; i++) { if ((Object)(object)hud.m_pieceIcons[i]?.m_go == (Object)(object)((Component)ih).gameObject) { return new Vector2Int(i % Columns, i / Columns); } } return new Vector2Int(-1, -1); } private static void UpdateScrollViewContentSize(int pieceCount, float spacing) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_scrollRect == (Object)null) && !((Object)(object)_scrollRect.content == (Object)null)) { float num = (float)Mathf.Max(1, Mathf.CeilToInt((float)pieceCount / (float)Columns)) * spacing + spacing * 0.25f; _scrollRect.content.sizeDelta = new Vector2((float)Columns * spacing, num); } } private static void ScrollToTop() { PinContentTop(); } private static void PinContentTop() { //IL_003a: 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) if (!((Object)(object)_scrollRect == (Object)null) && !((Object)(object)_scrollRect.content == (Object)null)) { _scrollRect.verticalNormalizedPosition = 1f; RectTransform content = _scrollRect.content; content.anchoredPosition = new Vector2(content.anchoredPosition.x, 0f); } } private static bool HasActiveFilter() { if (string.IsNullOrWhiteSpace(_currentFilter.SearchTerm) && _selectedMaterials.Count <= 0 && !_currentFilter.ShowOnlyCraftable && !_currentFilter.ShowMissingMaterials && !_currentFilter.ShowFavoritesOnly && !_currentFilter.ShowRecentOnly) { return _currentFilter.ShowAll; } return true; } private static bool NeedsCustomView() { if (!HasActiveFilter()) { return AAABuildMenuPlugin.DefaultSortMode.Value != AAABuildMenuPlugin.PieceSortMode.Vanilla; } return true; } private static bool GlobalActive() { if (AAABuildMenuPlugin.SearchAllCategories.Value.IsOn()) { return HasActiveFilter(); } return false; } public static void CaptureMasterAndApply(Player player, PieceTable pieceTable) { if (_isInitialized && !((Object)(object)player == (Object)null) && !((Object)(object)pieceTable == (Object)null) && !((Object)(object)player != (Object)(object)Player.m_localPlayer)) { _categoryMasters.Clear(); for (int i = 0; i < pieceTable.m_availablePieces.Count; i++) { _categoryMasters[(PieceCategory)i] = new List(pieceTable.m_availablePieces[i]); } if (NeedsCustomView()) { ApplyFilter(player, pieceTable, scrollToTop: false); } } } private static List GetGlobalAggregate() { HashSet hashSet = new HashSet(); List list = new List(); foreach (List value in _categoryMasters.Values) { foreach (Piece item in value) { if ((Object)(object)item != (Object)null && hashSet.Add(item)) { list.Add(item); } } } return list; } public static void ApplyFilter(Player player, PieceTable pieceTable, bool scrollToTop) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected I4, but got Unknown //IL_003b: 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_00d2: Unknown result type (might be due to invalid IL or missing references) if (!_isInitialized || (Object)(object)player == (Object)null || (Object)(object)pieceTable == (Object)null) { return; } PieceCategory selectedCategory = pieceTable.GetSelectedCategory(); int num = (int)selectedCategory; if (num >= 0 && num < pieceTable.m_availablePieces.Count) { if (!_categoryMasters.TryGetValue(selectedCategory, out List value)) { value = new List(pieceTable.m_availablePieces[num]); _categoryMasters[selectedCategory] = value; } Piece val = SelectedPiece ?? pieceTable.GetSelectedPiece(); List list = ComputeView((List)(GlobalActive() ? ((IList)GetGlobalAggregate()) : ((IList)value)), player); List list2 = pieceTable.m_availablePieces[num]; list2.Clear(); list2.AddRange(list); int num2 = (((Object)(object)val != (Object)null) ? list.IndexOf(val) : (-1)); if (num2 < 0) { num2 = 0; } pieceTable.SetSelected(new Vector2Int(num2 % Columns, num2 / Columns)); Piece val2 = (SelectedPiece = ((num2 < list.Count) ? list[num2] : null)); if ((Object)(object)val2 != (Object)null && val != val2 && (Object)(object)player.m_placementGhost != (Object)null) { player.SetupPlacementGhost(); } NeedsRefresh = false; if (scrollToTop) { ScrollToTop(); } } } private static List ComputeView(List source, Player player) { IEnumerable enumerable = source.Where((Piece p) => (Object)(object)p != (Object)null); SearchQuery searchQuery = SearchQuery.Parse(_currentFilter.SearchTerm); if (!searchQuery.IsEmpty) { enumerable = enumerable.Where(((SearchQuery)searchQuery).Matches); } if (_selectedMaterials.Count > 0) { enumerable = enumerable.Where(PieceUsesAnySelectedMaterial); } if (_currentFilter.ShowOnlyCraftable) { enumerable = enumerable.Where((Piece p) => player.HaveRequirements(p, (RequirementMode)0)); } else if (_currentFilter.ShowMissingMaterials) { enumerable = enumerable.Where((Piece p) => !player.HaveRequirements(p, (RequirementMode)0)); } if (_currentFilter.ShowFavoritesOnly) { enumerable = enumerable.Where((Piece p) => BuildMenuDataManager.IsFavorite(Utils.GetPrefabName(((Component)p).gameObject))); } if (_currentFilter.ShowRecentOnly) { List recent = BuildMenuDataManager.GetRecentPieces(); return (from p in enumerable where recent.Contains(Utils.GetPrefabName(((Component)p).gameObject)) orderby recent.IndexOf(Utils.GetPrefabName(((Component)p).gameObject)) select p).ToList(); } return ApplySort(enumerable).ToList(); } private static bool PieceUsesAnySelectedMaterial(Piece piece) { if (piece?.m_resources == null) { return false; } Requirement[] resources = piece.m_resources; foreach (Requirement val in resources) { if (!((Object)(object)val?.m_resItem == (Object)null) && _selectedMaterials.Contains(Utils.GetPrefabName(((Component)val.m_resItem).gameObject).ToLowerInvariant())) { return true; } } return false; } private static IEnumerable ApplySort(IEnumerable pieces) { return AAABuildMenuPlugin.DefaultSortMode.Value switch { AAABuildMenuPlugin.PieceSortMode.Alphabetical => pieces.OrderBy((Piece p) => Localization.instance.Localize(p.m_name), StringComparer.OrdinalIgnoreCase), AAABuildMenuPlugin.PieceSortMode.Cost => pieces.OrderBy(TotalResourceCost), AAABuildMenuPlugin.PieceSortMode.UsageFrequency => pieces.OrderByDescending((Piece p) => BuildMenuDataManager.GetUsageCount(Utils.GetPrefabName(((Component)p).gameObject))), _ => pieces, }; } private static int TotalResourceCost(Piece piece) { if (piece.m_resources == null) { return 0; } int num = 0; Requirement[] resources = piece.m_resources; for (int i = 0; i < resources.Length; i++) { num += resources[i]?.m_amount ?? 0; } return num; } private static void CreateSearchBar(Hud hud) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_007c: 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_0091: Expected O, but got Unknown //IL_00ae: 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_00ce: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) TMP_FontAsset uiFont = GetUiFont(hud); _searchBarObject = new GameObject("EnhancedMenuSearchBar"); _searchBarObject.SetActive(false); _searchBarObject.transform.SetParent(hud.m_pieceSelectionWindow.transform, false); RectTransform rect = _searchBarObject.AddComponent(); AnchorAboveViewport(hud, rect, SearchStripOffset(), 30f); Image obj = _searchBarObject.AddComponent(); StyleButtonImage(obj); ((Graphic)obj).color = new Color(0f, 0f, 0f, 0.65f); GameObject val = new GameObject("InputField"); val.transform.SetParent(_searchBarObject.transform, false); RectTransform obj2 = val.AddComponent(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.offsetMin = new Vector2(6f, 3f); obj2.offsetMax = new Vector2(-36f, -3f); _searchInputField = val.AddComponent(); GameObject val2 = new GameObject("TextArea"); val2.transform.SetParent(val.transform, false); RectTransform val3 = val2.AddComponent(); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.offsetMin = new Vector2(8f, 0f); val3.offsetMax = new Vector2(-8f, 0f); val2.AddComponent(); TMP_Text val4 = CreateText(val2.transform, "Placeholder", uiFont, 14f, new Color(0.6f, 0.6f, 0.6f, 0.6f), (TextAlignmentOptions)4097, stretch: true); val4.text = Localization.instance.Localize("$aaabuildmenu_search_placeholder"); TMP_Text textComponent = CreateText(val2.transform, "Text", uiFont, 14f, Color.white, (TextAlignmentOptions)4097, stretch: true); _searchInputField.textViewport = val3; _searchInputField.textComponent = textComponent; _searchInputField.placeholder = (Graphic)(object)val4; _searchInputField.fontAsset = uiFont; _searchInputField.pointSize = 14f; _searchInputField.lineType = (LineType)0; _searchInputField.characterLimit = 100; ((UnityEvent)(object)_searchInputField.onValueChanged).AddListener((UnityAction)OnSearchTextChanged); DisableNavigationAndSelection((Selectable)(object)_searchInputField); CreateClearButton(hud, uiFont); _searchBarObject.SetActive(true); AAABuildMenuPlugin.AAABuildMenuLogger.LogInfo((object)"Search bar created successfully"); } private static void CreateClearButton(Hud hud, TMP_FontAsset font) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0049: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown _clearSearchButton = new GameObject("ClearButton"); _clearSearchButton.SetActive(false); _clearSearchButton.transform.SetParent(_searchBarObject.transform, false); RectTransform obj = _clearSearchButton.AddComponent(); obj.anchorMin = new Vector2(1f, 0.5f); obj.anchorMax = new Vector2(1f, 0.5f); obj.pivot = new Vector2(1f, 0.5f); obj.anchoredPosition = new Vector2(-4f, 0f); obj.sizeDelta = new Vector2(26f, 26f); Image img = _clearSearchButton.AddComponent(); Button obj2 = _clearSearchButton.AddComponent