Decompiled source of Cards Overview v1.0.0
BepInEx\plugins\CardsOverview\CardsOverview.dll
Decompiled 21 minutes 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.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Localization; using UnityEngine.Localization.Settings; using UnityEngine.Localization.Tables; using UnityEngine.UI; [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("CardsOverview")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c9b03c0ff381adab9c0ba8924ab03e2818cd50b0")] [assembly: AssemblyProduct("CardsOverview")] [assembly: AssemblyTitle("CardsOverview")] [assembly: AssemblyVersion("1.0.0.0")] [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; } } } internal static class PluginVersion { internal const string Value = "1.0.0"; } namespace RoundsCardsOverview.Plugin { internal sealed class CardCatalogControls : IDisposable { private const string Cyrillic = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя"; private static readonly Color Ink = new Color(0.96f, 0.96f, 0.98f); private static readonly Color Muted = new Color(0.69f, 0.72f, 0.78f); private static readonly Color Accent = new Color(1f, 0.64f, 0.23f); private static readonly Color FieldColor = new Color(0.16f, 0.19f, 0.25f); private static readonly Rarity?[] Rarities = new Rarity?[4] { null, (Rarity)0, (Rarity)1, (Rarity)2 }; private readonly TextMeshProUGUI[] _labels = (TextMeshProUGUI[])(object)new TextMeshProUGUI[4]; private readonly List<TMP_Text> _fpsRaycastTargets = new List<TMP_Text>(); private readonly TMP_InputField _search; private readonly TMP_Dropdown _rarity; private readonly TMP_Dropdown _type; private readonly TMP_Dropdown _sort; private readonly Action<string, Rarity?, CardCatalogType, CardCatalogSort> _onChanged; private TMP_FontAsset? _localFont; private TMP_FontAsset? _generatedFallback; private Font? _systemFont; private int _searchCancelFrame = -1; internal TMP_FontAsset Font { get; } internal CardCatalogControls(RectTransform parent, TMP_FontAsset font, Action<string, Rarity?, CardCatalogType, CardCatalogSort> onChanged) { _onChanged = onChanged; HorizontalLayoutGroup obj = ((Component)parent).gameObject.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 18f; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true); ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false; try { Font = WithCyrillic(font); _search = CreateSearch(CreateSlot(parent, 0, 1.9f, Font), Font); _rarity = CreateDropdown(CreateSlot(parent, 1, 1f, Font), "Rarity", Font); _type = CreateDropdown(CreateSlot(parent, 2, 1.2f, Font), "Type", Font); _sort = CreateDropdown(CreateSlot(parent, 3, 1.35f, Font), "Sort", Font); RefreshLabels(); } catch { Dispose(); throw; } ((UnityEvent<string>)(object)_search.onValueChanged).AddListener((UnityAction<string>)delegate { NotifyChanged(); }); ((UnityEvent<string>)(object)_search.onEndEdit).AddListener((UnityAction<string>)delegate { if (_search.wasCanceled) { _searchCancelFrame = Time.frameCount; } }); ((UnityEvent<int>)(object)_rarity.onValueChanged).AddListener((UnityAction<int>)delegate { NotifyChanged(); }); ((UnityEvent<int>)(object)_type.onValueChanged).AddListener((UnityAction<int>)delegate { NotifyChanged(); }); ((UnityEvent<int>)(object)_sort.onValueChanged).AddListener((UnityAction<int>)delegate { NotifyChanged(); }); } internal void OnShow() { FieldInfo fieldInfo = AccessTools.Field(typeof(DebugFPS), "m_frameRateText"); if (fieldInfo == null) { return; } DebugFPS[] array = Object.FindObjectsOfType<DebugFPS>(true); foreach (DebugFPS obj in array) { object? value = fieldInfo.GetValue(obj); TMP_Text val = (TMP_Text)((value is TMP_Text) ? value : null); if (!((Object)(object)val == (Object)null) && ((Graphic)val).raycastTarget) { ((Graphic)val).raycastTarget = false; _fpsRaycastTargets.Add(val); } } } internal void OnHide() { foreach (TMP_Text fpsRaycastTarget in _fpsRaycastTargets) { if ((Object)(object)fpsRaycastTarget != (Object)null) { ((Graphic)fpsRaycastTarget).raycastTarget = true; } } _fpsRaycastTargets.Clear(); } internal void RefreshLabels() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Locale selectedLocale = LocalizationSettings.SelectedLocale; int num; if (selectedLocale == null) { num = 0; } else { LocaleIdentifier identifier = selectedLocale.Identifier; num = (((LocaleIdentifier)(ref identifier)).Code.StartsWith("ru", StringComparison.OrdinalIgnoreCase) ? 1 : 0); } bool flag = (byte)num != 0; string[] array = ((!flag) ? new string[4] { "Search", "Rarity", "Type", "Sort" } : new string[4] { "Поиск", "Редкость", "Тип", "Сортировка" }); for (int i = 0; i < _labels.Length; i++) { ((TMP_Text)_labels[i]).text = array[i]; } ((TMP_Text)_search.placeholder).text = (flag ? "Имя или описание" : "Name or description"); SetOptions(_rarity, (!flag) ? new string[4] { "Any", "Common", "Uncommon", "Rare" } : new string[4] { "Любая", "Обычные", "Необычные", "Редкие" }); SetOptions(_type, (!flag) ? new string[11] { "Any", "Affects attack", "Affects block", "Health", "Damage", "Bullet speed", "Attack speed", "Bounces", "Reload time", "Life steal", "Other properties" } : new string[11] { "Любой", "Влияет на атаку", "Влияет на блок", "Здоровье", "Урон", "Скорость пули", "Скорость атаки", "Отскоки", "Время перезарядки", "Похищение здоровья", "Другие свойства" }); SetOptions(_sort, (!flag) ? new string[2] { "Name", "Rarity" } : new string[2] { "По имени", "По редкости" }); } internal bool TryClose() { TMP_Dropdown[] array = (TMP_Dropdown[])(object)new TMP_Dropdown[3] { _rarity, _type, _sort }; foreach (TMP_Dropdown val in array) { if (val.IsExpanded) { val.Hide(); return true; } } if (!_search.isFocused) { return _searchCancelFrame == Time.frameCount; } _search.DeactivateInputField(false); EventSystem current = EventSystem.current; if ((Object)(object)current != (Object)null && (Object)(object)current.currentSelectedGameObject == (Object)(object)((Component)_search).gameObject) { current.SetSelectedGameObject((GameObject)null); } return true; } private void NotifyChanged() { _onChanged(_search.text, Rarities[_rarity.value], (CardCatalogType)_type.value, (CardCatalogSort)_sort.value); } private RectTransform CreateSlot(RectTransform parent, int index, float width, TMP_FontAsset font) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) RectTransform val = CardCatalogView.NewRect("Field", (Transform)(object)parent); ((Component)val).gameObject.AddComponent<LayoutElement>().flexibleWidth = width; RectTransform val2 = CardCatalogView.NewRect("Label", (Transform)(object)val); Stretch(val2, 0.71f, 1f); _labels[index] = ((Component)val2).gameObject.AddComponent<TextMeshProUGUI>(); StyleText((TMP_Text)(object)_labels[index], font, 22f, Muted); return val; } private static TMP_InputField CreateSearch(RectTransform slot, TMP_FontAsset font) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0110: Expected O, but got Unknown TMP_InputField component = TMP_DefaultControls.CreateInputField(default(Resources)).GetComponent<TMP_InputField>(); SetControlRect((Selectable)(object)component, slot, "Search"); ((Component)component).gameObject.AddComponent<CardCatalogSearchEditing>(); ((Selectable)component).targetGraphic = (Graphic)(object)((Component)component).GetComponent<Image>(); StyleSelectable((Selectable)(object)component); component.contentType = (ContentType)0; component.restoreOriginalTextOnEscape = false; component.richText = false; component.customCaretColor = true; component.caretColor = Ink; component.selectionColor = new Color(Accent.r, Accent.g, Accent.b, 0.43f); component.textViewport.offsetMin = new Vector2(15f, 2f); component.textViewport.offsetMax = new Vector2(-15f, -2f); StyleText(component.textComponent, font, 27f, Ink); component.textComponent.enableAutoSizing = false; component.textComponent.overflowMode = (TextOverflowModes)0; TMP_Text val = (TMP_Text)component.placeholder; StyleText(val, font, 27f, Muted); val.fontStyle = (FontStyles)0; return component; } private static TMP_Dropdown CreateDropdown(RectTransform slot, string name, TMP_FontAsset font) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00f1: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: 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_01e7: Unknown result type (might be due to invalid IL or missing references) TMP_Dropdown component = TMP_DefaultControls.CreateDropdown(default(Resources)).GetComponent<TMP_Dropdown>(); SetControlRect((Selectable)(object)component, slot, name); Image component2 = ((Component)component).GetComponent<Image>(); component2.type = (Type)0; ((Graphic)component2).raycastTarget = true; ((Graphic)component2).raycastPadding = Vector4.zero; ((Selectable)component).targetGraphic = (Graphic)(object)component2; StyleSelectable((Selectable)(object)component); StyleText(component.captionText, font, 27f, Ink); component.captionText.rectTransform.offsetMin = new Vector2(15f, 1f); component.captionText.rectTransform.offsetMax = new Vector2(-38f, -1f); RectTransform val = (RectTransform)((Component)component).transform.Find("Arrow"); val.anchoredPosition = new Vector2(-20f, 0f); ((Behaviour)((Component)val).GetComponent<Image>()).enabled = false; AddChevronStroke(val, -4f, -45f); AddChevronStroke(val, 4f, 45f); component.template.anchoredPosition = new Vector2(0f, -4f); ((Graphic)((Component)component.template).GetComponent<Image>()).color = FieldColor; Transform parent = component.itemText.transform.parent; ((RectTransform)parent).sizeDelta = new Vector2(0f, 48f); ((RectTransform)parent.parent).sizeDelta = new Vector2(0f, 56f); Toggle component3 = ((Component)parent).GetComponent<Toggle>(); StyleSelectable((Selectable)(object)component3); component3.graphic.color = Accent; RectTransform val2 = (RectTransform)((Component)component3.graphic).transform; val2.sizeDelta = new Vector2(4f, 22f); val2.anchoredPosition = new Vector2(12f, 0f); StyleText(component.itemText, font, 25f, Ink); component.itemText.rectTransform.offsetMin = new Vector2(26f, 1f); return component; } private static void SetControlRect(Selectable field, RectTransform slot, string name) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown ((Object)field).name = name; RectTransform val = (RectTransform)((Component)field).transform; ((Transform)val).SetParent((Transform)(object)slot, false); Stretch(val, 0f, 0.64f); } private static void Stretch(RectTransform rect, float bottom, float top) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = new Vector2(0f, bottom); rect.anchorMax = new Vector2(1f, top); Vector2 offsetMin = (rect.offsetMax = Vector2.zero); rect.offsetMin = offsetMin; } private static void StyleText(TMP_Text text, TMP_FontAsset font, float size, Color color) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) text.font = font; ((Graphic)text).color = color; float fontSize = (text.fontSizeMax = size); text.fontSize = fontSize; text.fontSizeMin = 14f; text.enableAutoSizing = true; text.enableWordWrapping = false; text.overflowMode = (TextOverflowModes)1; text.alignment = (TextAlignmentOptions)4097; ((Graphic)text).raycastTarget = false; } private static void StyleSelectable(Selectable selectable) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) selectable.targetGraphic.color = Color.white; ColorBlock colors = selectable.colors; ((ColorBlock)(ref colors)).normalColor = FieldColor; ((ColorBlock)(ref colors)).highlightedColor = new Color(0.24f, 0.28f, 0.37f); ((ColorBlock)(ref colors)).selectedColor = new Color(0.27f, 0.3f, 0.4f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.31f, 0.34f, 0.43f); selectable.colors = colors; } private static void AddChevronStroke(RectTransform parent, float x, float angle) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = CardCatalogView.NewRect("Chevron", (Transform)(object)parent); obj.sizeDelta = new Vector2(11f, 2.5f); obj.anchoredPosition = new Vector2(x, -1f); ((Transform)obj).localRotation = Quaternion.Euler(0f, 0f, angle); Image obj2 = ((Component)obj).gameObject.AddComponent<Image>(); ((Graphic)obj2).color = Accent; ((Graphic)obj2).raycastTarget = false; } private static void SetOptions(TMP_Dropdown dropdown, string[] labels) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) int value = dropdown.value; dropdown.ClearOptions(); dropdown.AddOptions(new List<string>(labels)); Rect rect = ((RectTransform)dropdown.itemText.transform.parent).rect; float height = ((Rect)(ref rect)).height; dropdown.template.sizeDelta = new Vector2(0f, height * (float)labels.Length + 8f); dropdown.SetValueWithoutNotify(Mathf.Clamp(value, 0, labels.Length - 1)); dropdown.RefreshShownValue(); } private TMP_FontAsset WithCyrillic(TMP_FontAsset primary) { uint[] array = default(uint[]); if (primary.HasCharacters("АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя", ref array, true, false)) { return primary; } TMP_FontAsset val = Array.Find(Resources.FindObjectsOfTypeAll<TMP_FontAsset>(), (TMP_FontAsset asset) => (Object)(object)asset != (Object)null && asset.HasCharacters("АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя")); if ((Object)(object)val == (Object)null) { _systemFont = Font.CreateDynamicFontFromOSFont("Arial", 32); if ((Object)(object)_systemFont != (Object)null) { _generatedFallback = TMP_FontAsset.CreateFontAsset(_systemFont); } val = _generatedFallback; } if ((Object)(object)val == (Object)null) { return primary; } _localFont = Object.Instantiate<TMP_FontAsset>(primary); List<TMP_FontAsset> fallbackFontAssetTable = primary.fallbackFontAssetTable; _localFont.fallbackFontAssetTable = ((fallbackFontAssetTable == null) ? new List<TMP_FontAsset>() : new List<TMP_FontAsset>(fallbackFontAssetTable)); _localFont.fallbackFontAssetTable.Add(val); return _localFont; } public void Dispose() { OnHide(); if ((Object)(object)_localFont != (Object)null) { Object.Destroy((Object)(object)_localFont); } if ((Object)(object)_generatedFallback != (Object)null) { Texture2D[] atlasTextures = _generatedFallback.atlasTextures; foreach (Texture2D val in atlasTextures) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } if ((Object)(object)((TMP_Asset)_generatedFallback).material != (Object)null) { Object.Destroy((Object)(object)((TMP_Asset)_generatedFallback).material); } Object.Destroy((Object)(object)_generatedFallback); } if ((Object)(object)_systemFont != (Object)null) { Object.Destroy((Object)(object)_systemFont); } } } internal enum CardCatalogType { All, Attack, Block, Health, Damage, ProjectileSpeed, AttackSpeed, Bounces, ReloadTime, LifeSteal, Other } internal enum CardCatalogSort { Name, Rarity } internal static class CardCatalogData { internal static IReadOnlyList<CardInfo> Filter(IEnumerable<CardInfo> cards, string search, Rarity? rarity, CardCatalogType type, CardCatalogSort sort, CultureInfo? culture = null) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (culture == null) { Locale selectedLocale = LocalizationSettings.SelectedLocale; object obj; if (selectedLocale == null) { obj = null; } else { LocaleIdentifier identifier = selectedLocale.Identifier; obj = ((LocaleIdentifier)(ref identifier)).CultureInfo; } if (obj == null) { obj = CultureInfo.CurrentCulture; } culture = (CultureInfo?)obj; } string query = search.Trim(); IEnumerable<(CardInfo Card, string Name)> source = (from card in cards where (Object)(object)card != (Object)null && (!rarity.HasValue || card.rarity == rarity.Value) && MatchesType(card, type) select (Card: card, Name: card.CardName)).Where(delegate((CardInfo Card, string Name) entry) { if (query.Length != 0 && !Contains(culture, entry.Name, query)) { LocalizedString localizedCardDescription = entry.Card.LocalizedCardDescription; if (localizedCardDescription != null && !((LocalizedReference)localizedCardDescription).IsEmpty) { return Contains(culture, entry.Card.CardDescription, query); } return false; } return true; }); return (from entry in Enumerable.ThenBy<(CardInfo, string), string>(comparer: StringComparer.Create(culture, ignoreCase: true), source: source.OrderByDescending(((CardInfo Card, string Name) entry) => (sort == CardCatalogSort.Rarity) ? ((int)entry.Card.rarity) : 0), keySelector: ((CardInfo Card, string Name) entry) => entry.Name).ThenBy<(CardInfo, string), string>(((CardInfo Card, string Name) entry) => ((Object)entry.Card).name, StringComparer.Ordinal) select entry.Card).ToArray(); } private static bool Contains(CultureInfo culture, string value, string query) { return culture.CompareInfo.IndexOf(value, query, CompareOptions.IgnoreCase) >= 0; } private static bool MatchesType(CardInfo card, CardCatalogType type) { return type switch { CardCatalogType.Attack => AffectsAttack(card), CardCatalogType.Block => AffectsBlock(card), CardCatalogType.All => true, _ => HasProperty(card, type), }; } private static bool AffectsAttack(CardInfo card) { bool flag = BlocksOnOutOfAmmo(card); CardInfoStat[] array = card.cardStats ?? Array.Empty<CardInfoStat>(); foreach (CardInfoStat val in array) { string statKey = GetStatKey(val); CardCatalogType property = GetProperty(statKey); if (!(property == CardCatalogType.ReloadTime && flag) || val.positive) { bool flag2 = (uint)(property - 4) <= 5u; bool flag3 = flag2; if (!flag3) { bool flag4 = ((statKey == "STAT_AMMO" || statKey == "STAT_BULLETS") ? true : false); flag3 = flag4; } if (flag3) { return true; } } } Gun component = ((Component)card).GetComponent<Gun>(); if ((Object)(object)component == (Object)null) { return false; } bool flag5 = ((!flag) ? (component.reloadTime != 1f || component.reloadTimeAdd != 0f) : (component.reloadTime < 1f || component.reloadTimeAdd < 0f)); if (!(component.damage != 1f || component.bulletDamageMultiplier != 1f || component.percentageDamage != 0f || component.attackSpeed != 1f || flag5) && component.ammo == 0 && component.ammoReg == 0f && component.projectileSpeed == 1f && component.projectielSimulatonSpeed == 1f && component.projectileSize == 0f && component.size == 0f && component.gravity == 1f && component.spread == 0f && component.multiplySpread == 1f && component.evenSpread == 0f && component.drag == 0f && component.reflects == 0 && component.smartBounce == 0 && component.randomBounces == 0 && component.bulletPortal == 0 && component.bursts == 0 && component.numberOfProjectiles == 0 && component.timeBetweenBullets == 0f && component.knockback == 1f && component.recoilMuiltiplier == 1f && component.slow == 0f && component.destroyBulletAfter == 0f && !component.ignoreWalls && !component.unblockable && !component.lockGunToDefault && !component.useCharge && !component.dontAllowAutoFire) { ProjectilesToSpawn[] projectiles = component.projectiles; if (projectiles == null || projectiles.Length <= 0) { ObjectsToSpawn[] objectsToSpawn = component.objectsToSpawn; if (objectsToSpawn != null) { return objectsToSpawn.Length > 0; } return false; } } return true; } private static bool BlocksOnOutOfAmmo(CardInfo card) { GameObject val = ((Component)card).GetComponent<CharacterStatModifiers>()?.AddObjectToPlayer; if ((Object)(object)val == (Object)null) { return false; } ReloadTigger componentInChildren = val.GetComponentInChildren<ReloadTigger>(true); UnityEvent val2 = (((Object)(object)componentInChildren == (Object)null) ? null : componentInChildren.outOfAmmoEvent); if (val2 == null) { return false; } for (int i = 0; i < ((UnityEventBase)val2).GetPersistentEventCount(); i++) { if (((UnityEventBase)val2).GetPersistentTarget(i) is PlayerDoBlock && ((UnityEventBase)val2).GetPersistentMethodName(i) == "DoBlock") { return true; } } return false; } private static bool AffectsBlock(CardInfo card) { if (card.AffectsBlock || (card.cardStats ?? Array.Empty<CardInfoStat>()).Any((CardInfoStat stat) => GetStatKey(stat) == "STAT_BLOCK_COOLDOWN")) { return true; } Block componentInChildren = ((Component)card).GetComponentInChildren<Block>(); if ((Object)(object)componentInChildren != (Object)null) { if (componentInChildren.cdMultiplier == 1f && componentInChildren.cdAdd == 0f && componentInChildren.forceToAdd == 0f && componentInChildren.forceToAddUp == 0f && componentInChildren.additionalBlocks == 0 && componentInChildren.healing == 0f && !componentInChildren.autoBlock) { List<GameObject> objectsToSpawn = componentInChildren.objectsToSpawn; if (objectsToSpawn != null) { return objectsToSpawn.Count > 0; } return false; } return true; } return false; } internal static string? GetStatKey(CardInfoStat? stat) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) LocalizedString val = ((stat != null) ? stat.LocalizedStat : null); if (val == null) { return null; } TableEntryReference tableEntryReference = ((LocalizedReference)val).TableEntryReference; if ((int)((TableEntryReference)(ref tableEntryReference)).ReferenceType != 2) { return ((TableEntryReference)(ref tableEntryReference)).Key; } StringTable table = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(((LocalizedReference)val).TableReference, (Locale)null); if (table == null) { return null; } return ((LocalizationTable)table).SharedData.GetKey(((TableEntryReference)(ref tableEntryReference)).KeyId); } private static CardCatalogType GetProperty(string? key) { switch (key) { case "STAT_HP": return CardCatalogType.Health; case "STAT_DMG": return CardCatalogType.Damage; case "STAT_BULLET_SPEED": return CardCatalogType.ProjectileSpeed; case "STAT_ATKSPD": return CardCatalogType.AttackSpeed; case "STAT_BULLET_BOUNCES": return CardCatalogType.Bounces; case "STAT_RELOAD_SPEED": case "STAT_RELOAD_TIME": return CardCatalogType.ReloadTime; case "STAT_LIFE_STEAL": return CardCatalogType.LifeSteal; default: return CardCatalogType.Other; } } private static bool HasProperty(CardInfo card, CardCatalogType type) { if ((card.cardStats ?? Array.Empty<CardInfoStat>()).Any((CardInfoStat stat) => stat != null && GetProperty(GetStatKey(stat)) == type)) { return true; } if (type == CardCatalogType.LifeSteal) { return HasLifeStealEffect(card); } CardCatalogType cardCatalogType = type; if ((cardCatalogType != CardCatalogType.ProjectileSpeed && cardCatalogType != CardCatalogType.Bounces) || 1 == 0) { return false; } Gun component = ((Component)card).GetComponent<Gun>(); if ((Object)(object)component != (Object)null) { if (type != CardCatalogType.Bounces) { return component.projectileSpeed != 1f; } return component.reflects != 0; } return false; } private static bool HasLifeStealEffect(CardInfo card) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 CharacterStatModifiers component = ((Component)card).GetComponent<CharacterStatModifiers>(); if ((Object)(object)component == (Object)null) { return false; } if (component.lifeSteal != 0f) { return true; } if ((Object)(object)component.AddObjectToPlayer == (Object)null) { return false; } PlayerInRangeTrigger componentInChildren = component.AddObjectToPlayer.GetComponentInChildren<PlayerInRangeTrigger>(true); if (!((Object)(object)componentInChildren == (Object)null) && (int)componentInChildren.targetType == 1) { RegenerateAfterStandStill component2 = ((Component)componentInChildren).GetComponent<RegenerateAfterStandStill>(); if (component2 != null && component2.heal > 0f) { UnityEvent triggerEvent = componentInChildren.triggerEvent; if (triggerEvent == null) { return false; } for (int i = 0; i < ((UnityEventBase)triggerEvent).GetPersistentEventCount(); i++) { Object persistentTarget = ((UnityEventBase)triggerEvent).GetPersistentTarget(i); DealDamageToPlayer val = (DealDamageToPlayer)(object)((persistentTarget is DealDamageToPlayer) ? persistentTarget : null); if (val != null && val.damage > 0f && (int)val.targetPlayer == 1 && ((UnityEventBase)triggerEvent).GetPersistentMethodName(i) == "Go") { return true; } } return false; } } return false; } } internal sealed class CardCatalogMenu : IDisposable { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Predicate<Button> <>9__8_0; public static UnityAction <>9__10_0; internal bool <AddEntry>b__8_0(Button button) { if ((Object)(object)((Component)button).GetComponent<ListMenuButton>() != (Object)null) { return (Object)(object)((Component)button).GetComponentInChildren<UILocalizedString>(true) != (Object)null; } return false; } internal void <CreatePage>b__10_0() { ListMenu.instance.CloseTopPage(); } } private static CardCatalogMenu? _instance; private Button? _entry; private Button? _fallbackBack; private ListMenuPage? _page; private CardCatalogView? _view; internal void Install(Harmony harmony) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown _instance = this; harmony.Patch((MethodBase)AccessTools.Method(typeof(ListMenuPage), "Show", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(CardCatalogMenu), "AfterPageShown", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(EscapeMenuHandler), "ToggleEsc", (Type[])null, (Type[])null), new HarmonyMethod(typeof(CardCatalogMenu), "BeforeToggleEscape", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); LocalizationSettings.SelectedLocaleChanged += OnLocaleChanged; } private static void AfterPageShown(ListMenuPage __instance) { if ((Object)(object)MainMenuHandler.instance != (Object)null && (Object)(object)__instance == (Object)(object)MainMenuHandler.instance.MainMenu) { _instance?.AddEntry(__instance); } } private static bool BeforeToggleEscape() { if ((Object)(object)_instance?._page == (Object)null || !_instance._page.IsOpen) { return true; } CardCatalogView? view = _instance._view; if (view == null || !view.TryCloseControls()) { ListMenu.instance.CloseTopPage(); } return false; } private void AddEntry(ListMenuPage main) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown if ((Object)(object)_entry != (Object)null && ((Component)_entry).transform.IsChildOf(((Component)main).transform)) { return; } try { Button val = Array.Find(((Component)main).GetComponentsInChildren<Button>(true), (Button button) => (Object)(object)((Component)button).GetComponent<ListMenuButton>() != (Object)null && (Object)(object)((Component)button).GetComponentInChildren<UILocalizedString>(true) != (Object)null); if (!((Object)(object)val == (Object)null)) { _entry = CloneButton(val, ((Component)val).transform.parent, "RoundsCardsOverview.MenuButton", CardsLabel(LocalizationSettings.SelectedLocale), (UnityAction)delegate { Open(main); }); ((Component)_entry).transform.SetSiblingIndex(Math.Max(0, ((Component)_entry).transform.GetSiblingIndex() - 1)); } } catch (Exception ex) { Plugin.Instance?.WriteTrace("card_catalog_error", ex.ToString()); } } private void Open(ListMenuPage main) { try { if ((Object)(object)_page == (Object)null) { CardChoice instance = CardChoice.instance; if ((Object)(object)instance == (Object)null || instance.cards == null || instance.cards.Length == 0 || (Object)(object)_entry == (Object)null) { return; } CreatePage(main, instance); } if (!_page.IsOpen) { _page.Open(); } } catch (Exception ex) { DestroyPage(); Plugin.Instance?.WriteTrace("card_catalog_error", ex.ToString()); } } private void CreatePage(ListMenuPage main, CardChoice cardChoice) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0119: Expected O, but got Unknown //IL_0162: Expected O, but got Unknown GameObject val = new GameObject("RoundsCardsOverview.Catalog", new Type[1] { typeof(RectTransform) }); val.SetActive(false); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent(((Component)main).transform.parent, false); CardCatalogView.Fill(val2); try { Button entry = _entry; Locale selectedLocale = LocalizationSettings.SelectedLocale; ListMenuPage val3 = FindSettingsPage(); Button val4 = (((Object)(object)val3 == (Object)null) ? null : FindSettingsBack(val3)); ListMenuPage val5 = val.AddComponent<ListMenuPage>(); val5.barHeight = (((Object)(object)val3 != (Object)null) ? val3.barHeight : main.barHeight); RectTransform val6 = CardCatalogView.NewRect("Catalog", (Transform)(object)val2); CardCatalogView.Fill(val6); CardCatalogView cardCatalogView = ((Component)val6).gameObject.AddComponent<CardCatalogView>(); cardCatalogView.Build(cardChoice, ((Component)entry).GetComponentInChildren<TextMeshProUGUI>(true)); cardCatalogView.RefreshLocale(IsRussian(selectedLocale)); Button template = val4 ?? entry; string label = (((Object)(object)val4 == (Object)null) ? BackLabel(selectedLocale) : null); object obj = <>c.<>9__10_0; if (obj == null) { UnityAction val7 = delegate { ListMenu.instance.CloseTopPage(); }; <>c.<>9__10_0 = val7; obj = (object)val7; } Button val8 = CloneButton(template, (Transform)(object)val6, "Back", label, (UnityAction)obj); ListMenuButton component = ((Component)val8).GetComponent<ListMenuButton>(); component.hideBar = false; cardCatalogView.SetBackButton((RectTransform)((Component)val8).transform, (component.setBarHeight > 0f) ? component.setBarHeight : val5.barHeight); AccessTools.Field(typeof(ListMenuPage), "firstSelected").SetValue(val5, component); val.SetActive(true); val5.Hide(); _fallbackBack = (((Object)(object)val4 == (Object)null) ? val8 : null); _view = cardCatalogView; _page = val5; } catch { Object.Destroy((Object)(object)val); throw; } } private static ListMenuPage? FindSettingsPage() { Optionshandler instance = Optionshandler.instance; if ((Object)(object)instance == (Object)null) { return null; } object? obj = AccessTools.Field(typeof(Optionshandler), "m_optionsRoot")?.GetValue(instance); object? obj2 = ((obj is Transform) ? obj : null); return ((obj2 != null) ? ((Component)obj2).GetComponentInParent<ListMenuPage>(true) : null) ?? ((Component)instance).GetComponentInParent<ListMenuPage>(true); } private static Button? FindSettingsBack(ListMenuPage settings) { Button[] componentsInChildren = ((Component)settings).GetComponentsInChildren<Button>(true); foreach (Button val in componentsInChildren) { if ((Object)(object)((Component)val).GetComponent<ListMenuButton>() == (Object)null || (Object)(object)((Component)val).GetComponentInChildren<UILocalizedString>(true) == (Object)null) { continue; } for (int j = 0; j < ((UnityEventBase)val.onClick).GetPersistentEventCount(); j++) { if (((UnityEventBase)val.onClick).GetPersistentMethodName(j) == "CloseTopPage") { return val; } } } return null; } private static Button CloneButton(Button template, Transform parent, string name, string? label, UnityAction onClick) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("CardCatalogButtonStaging"); val.SetActive(false); try { GameObject val2 = Object.Instantiate<GameObject>(((Component)template).gameObject, val.transform, false); ((Object)val2).name = name; MonoBehaviour[] componentsInChildren = val2.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val3 in componentsInChildren) { if (!((Object)(object)val3 == (Object)null) && !(val3 is ListMenuButton) && !(val3 is UILocalizedString) && (val3 is EventTrigger || ((object)val3).GetType().Assembly == typeof(ListMenuPage).Assembly)) { Object.DestroyImmediate((Object)(object)val3); } } Button[] componentsInChildren2 = val2.GetComponentsInChildren<Button>(true); foreach (Button obj in componentsInChildren2) { obj.onClick = new ButtonClickedEvent(); Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)3; ((Selectable)obj).navigation = navigation; } Button component = val2.GetComponent<Button>(); ((UnityEvent)component.onClick).AddListener(onClick); UILocalizedString componentInChildren = val2.GetComponentInChildren<UILocalizedString>(true); AccessTools.Field(typeof(UILocalizedString), "m_onStringUpdated").SetValue(componentInChildren, (object?)new UnityEvent()); TextMeshProUGUI text = componentInChildren.Text; ((TMP_Text)text).fontStyle = (FontStyles)(((TMP_Text)text).fontStyle & -2); if (label != null) { SetLabel(component, label); } val2.transform.SetParent(parent, false); val2.SetActive(true); return component; } finally { Object.Destroy((Object)(object)val); } } private void OnLocaleChanged(Locale locale) { if ((Object)(object)_entry != (Object)null) { SetLabel(_entry, CardsLabel(locale)); } if ((Object)(object)_fallbackBack != (Object)null) { SetLabel(_fallbackBack, BackLabel(locale)); } _view?.RefreshLocale(IsRussian(locale)); } private static string CardsLabel(Locale? locale) { if (!IsRussian(locale)) { return "Cards"; } return "Карты"; } private static string BackLabel(Locale? locale) { if (!IsRussian(locale)) { return "Back"; } return "Назад"; } private static bool IsRussian(Locale? locale) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)locale != (Object)null) { LocaleIdentifier identifier = locale.Identifier; return ((LocaleIdentifier)(ref identifier)).Code.StartsWith("ru", StringComparison.OrdinalIgnoreCase); } return false; } private static void SetLabel(Button button, string label) { UILocalizedString componentInChildren = ((Component)button).GetComponentInChildren<UILocalizedString>(true); ((TMP_Text)componentInChildren.Text).text = label; componentInChildren.ResetReference(label); ((TMP_Text)((Component)button).GetComponentInChildren<TextMeshProUGUI>(true)).text = label; } private void DestroyPage() { if ((Object)(object)_page != (Object)null) { if (_page.IsOpen && (Object)(object)ListMenu.instance != (Object)null) { ListMenu.instance.CloseTopPage(); } Object.Destroy((Object)(object)((Component)_page).gameObject); } _page = null; _fallbackBack = null; _view = null; } public void Dispose() { LocalizationSettings.SelectedLocaleChanged -= OnLocaleChanged; DestroyPage(); if ((Object)(object)_entry != (Object)null) { Object.Destroy((Object)(object)((Component)_entry).gameObject); } if (_instance == this) { _instance = null; } } } internal sealed class CardCatalogSearchEditing : MonoBehaviour { private enum TextPart { Space, Word, Symbol } private int _backspaceFrame = -1; private bool _translatedBackspace; internal static void Install(Harmony harmony) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown harmony.Patch((MethodBase)AccessTools.Method(typeof(TMP_InputField), "KeyPressed", (Type[])null, (Type[])null), new HarmonyMethod(typeof(CardCatalogSearchEditing), "BeforeKeyPressed", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static bool BeforeKeyPressed(TMP_InputField __instance, Event evt) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0035: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 if ((evt.modifiers & 0xD) != 0) { return true; } bool flag = (int)evt.keyCode == 0 && evt.character == '\u007f'; bool flag2 = flag || (evt.control && (int)evt.keyCode == 8); if (!flag2 && (!evt.control || (int)evt.keyCode != 127)) { return true; } CardCatalogSearchEditing cardCatalogSearchEditing = default(CardCatalogSearchEditing); if ((int)SystemInfo.operatingSystemFamily != 2 || !__instance.isFocused || __instance.readOnly || !((Component)__instance).TryGetComponent<CardCatalogSearchEditing>(ref cardCatalogSearchEditing)) { return true; } EventSystem current = EventSystem.current; object obj; if (current == null) { obj = null; } else { BaseInputModule currentInputModule = current.currentInputModule; obj = ((currentInputModule != null) ? currentInputModule.input.compositionString : null); } if (obj == null) { obj = Input.compositionString; } if (!string.IsNullOrEmpty((string?)obj)) { return true; } if (flag2 && cardCatalogSearchEditing.IsPairedBackspace(flag)) { return false; } if (__instance.selectionStringAnchorPosition != __instance.selectionStringFocusPosition) { if (flag) { evt.keyCode = (KeyCode)8; } return true; } DeleteWord(__instance, flag2); return false; } private bool IsPairedBackspace(bool translated) { int frameCount = Time.frameCount; if (_backspaceFrame == frameCount && _translatedBackspace != translated) { _backspaceFrame = -1; return true; } _backspaceFrame = frameCount; _translatedBackspace = translated; return false; } private static void DeleteWord(TMP_InputField field, bool backward) { string text = field.text; int stringPosition = field.stringPosition; int num = (backward ? PreviousWordStart(text, stringPosition) : stringPosition); int num2 = (backward ? stringPosition : NextWordStart(text, stringPosition)); if (num != num2) { field.SetTextWithoutNotify(text.Remove(num, num2 - num)); field.stringPosition = num; TMP_TextInfo textInfo = field.textComponent.textInfo; int i; for (i = 0; i < textInfo.characterCount - 1 && textInfo.characterInfo[i].index < num; i++) { } field.caretPosition = i; ((UnityEvent<string>)(object)field.onValueChanged).Invoke(field.text); } } private static int PreviousWordStart(string value, int index) { while (index > 0 && PartAt(value, PreviousCharacter(value, index)) == TextPart.Space) { index = PreviousCharacter(value, index); } if (index == 0) { return index; } TextPart textPart = PartAt(value, PreviousCharacter(value, index)); while (index > 0 && PartAt(value, PreviousCharacter(value, index)) == textPart) { index = PreviousCharacter(value, index); } return index; } private static int NextWordStart(string value, int index) { if (index == value.Length) { return index; } TextPart textPart = PartAt(value, index); while (index < value.Length && PartAt(value, index) == textPart) { index = NextCharacter(value, index); } while (index < value.Length && PartAt(value, index) == TextPart.Space) { index = NextCharacter(value, index); } return index; } private static TextPart PartAt(string value, int index) { if (char.IsWhiteSpace(value, index)) { return TextPart.Space; } UnicodeCategory unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(value, index); bool flag = char.IsLetterOrDigit(value, index); if (!flag) { bool flag2 = (((uint)(unicodeCategory - 5) <= 2u || unicodeCategory == UnicodeCategory.ConnectorPunctuation) ? true : false); flag = flag2; } if (!flag) { return TextPart.Symbol; } return TextPart.Word; } private static int PreviousCharacter(string value, int index) { if (index <= 1 || !char.IsSurrogatePair(value, index - 2)) { return index - 1; } return index - 2; } private static int NextCharacter(string value, int index) { if (index + 1 >= value.Length || !char.IsSurrogatePair(value, index)) { return index + 1; } return index + 2; } } internal static class CardCatalogSmoke { private struct DesktopRect { public int Left; public int Top; public int Right; public int Bottom; } private struct NativeWindowInfo { public int Size; public DesktopRect Window; public DesktopRect Client; public uint Style; public uint ExtendedStyle; public uint WindowStatus; public uint BorderWidth; public uint BorderHeight; public ushort WindowType; public ushort CreatorVersion; } private struct NativeMonitorInfo { public int Size; public DesktopRect Monitor; public DesktopRect WorkArea; public uint Flags; } internal static IEnumerator Run(Plugin plugin, string outputDirectory, int holdSeconds) { string screenshotLocale = Environment.GetCommandLineArgs().FirstOrDefault((string argument) => argument.StartsWith("--rounds-cards-overview-screenshot-locale=", StringComparison.Ordinal))?.Substring("--rounds-cards-overview-screenshot-locale=".Length); IEnumerator steps = CheckCatalog(outputDirectory, holdSeconds, screenshotLocale); while (true) { object current; try { if (!steps.MoveNext()) { break; } current = steps.Current; goto IL_00b3; } catch (Exception ex) { plugin.WriteTrace("cards_overview_smoke_failed", ex.ToString()); Application.Quit(2); yield break; } IL_00b3: yield return current; } plugin.WriteTrace("cards_overview_smoke_complete", "main_menu;native_thumbnail_text;localized_hover;search;word_deletion;rarity_arrow;type;property_filters_both_signs;life_steal;sort_full_width;scroll_to_bottom;visible_back_highlight;stat_format_on_reopen;escape"); Application.Quit(0); } private static IEnumerator CheckCatalog(string outputDirectory, int holdSeconds, string? screenshotLocale) { float deadline = Time.realtimeSinceStartup + 30f; while (((Object)(object)MainMenuHandler.instance == (Object)null || (Object)(object)ListMenu.instance == (Object)null || !ListMenu.instance.IsInitialized || (Object)(object)CardChoice.instance == (Object)null) && Time.realtimeSinceStartup < deadline) { yield return null; } MainMenuHandler val = MainMenuHandler.instance ?? throw new InvalidOperationException("Main menu did not initialize."); Require((Object)(object)ListMenu.instance != (Object)null && ListMenu.instance.IsInitialized && (Object)(object)CardChoice.instance != (Object)null, "Game UI did not initialize."); EventSystem events = EventSystem.current ?? throw new InvalidOperationException("The game EventSystem did not initialize."); BaseInputModule[] components = ((Component)events).GetComponents<BaseInputModule>(); for (int i = 0; i < components.Length; i++) { ((Behaviour)components[i]).enabled = false; } CardCatalogSmokeInput smokeInput = ((Component)events).gameObject.AddComponent<CardCatalogSmokeInput>(); ListMenuPage main = val.MainMenu; if (!main.IsOpen) { SkipIntro obj = Object.FindObjectOfType<SkipIntro>(true); if (obj != null) { obj.Skip(); } } yield return null; Require((Object)(object)events.currentInputModule == (Object)(object)smokeInput, "The EventSystem did not switch to the smoke input module."); Button entry = ((Component)Find(((Component)main).transform, "RoundsCardsOverview.MenuButton")).GetComponent<Button>(); Require(main.IsOpen && ((Component)entry).gameObject.activeInHierarchy && ((Selectable)entry).interactable, "The Cards button is unavailable on the main menu."); RaycastResult pointerCurrentRaycast; if (screenshotLocale != null) { LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales.Single(delegate(Locale candidate) { //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) LocaleIdentifier identifier = candidate.Identifier; return string.Equals(((LocaleIdentifier)(ref identifier)).Code, screenshotLocale, StringComparison.OrdinalIgnoreCase); }); yield return null; Canvas.ForceUpdateCanvases(); PointerEventData val2 = Raycast((RectTransform)((Component)entry).transform); pointerCurrentRaycast = val2.pointerCurrentRaycast; Require((Object)(object)ExecuteEvents.ExecuteHierarchy<IPointerEnterHandler>(((RaycastResult)(ref pointerCurrentRaycast)).gameObject, (BaseEventData)(object)val2, ExecuteEvents.pointerEnterHandler) == (Object)(object)((Component)entry).gameObject, "The Cards button could not be highlighted for capture."); } yield return (object)new WaitForSecondsRealtime(0.5f); MethodInfo capture = Type.GetType("UnityEngine.ScreenCapture, UnityEngine.ScreenCaptureModule")?.GetMethod("CaptureScreenshot", new Type[2] { typeof(string), typeof(int) }) ?? throw new InvalidOperationException("Game framebuffer capture is unavailable."); string menuFile = Screenshot(capture, outputDirectory, "menu"); float menuCaptureDeadline = Time.realtimeSinceStartup + 5f; while (!File.Exists(menuFile) && Time.realtimeSinceStartup < menuCaptureDeadline) { yield return null; } Require(File.Exists(menuFile), "Game did not write the main menu framebuffer."); Click(entry); yield return null; ListMenuPage page = ((Component)Find(((Component)main).transform.parent, "RoundsCardsOverview.Catalog")).GetComponent<ListMenuPage>(); Require(page.IsOpen && !main.IsOpen, "Clicking Cards did not open the catalog."); ScrollRect scroll = ((Component)page).GetComponentInChildren<ScrollRect>() ?? throw new InvalidOperationException("Scroll view is missing."); Require(scroll.vertical && (Object)(object)scroll.viewport != (Object)null && ((Object)scroll.viewport).name == "Viewport", "Vertical viewport is missing."); Transform[] thumbnails = VisibleThumbnails(scroll); CardChoice val3 = CardChoice.instance ?? throw new InvalidOperationException("The game's card list is unavailable."); CardInfo[] sourceCards = val3.cards.Where((CardInfo card) => (Object)(object)card != (Object)null).ToArray(); Require(sourceCards.Length != 0 && thumbnails.Length == sourceCards.Length, "Catalog card count differs from CardChoice.cards."); Dictionary<string, CardInfo> sources = sourceCards.ToDictionary((CardInfo card) => "Card: " + ((Object)card).name); Require(thumbnails.All((Transform card) => sources.ContainsKey(((Object)card).name)), "Catalog thumbnails differ from the game's card list."); Transform preview = Find(((Component)page).transform, "Preview"); Require((Object)(object)ActivePreview(preview) == (Object)null, "Preview appears before pointer enter."); if (screenshotLocale != null) { yield return (object)new WaitForSecondsRealtime(0.3f); } string gridFile = Screenshot(capture, outputDirectory, "grid"); yield return (object)new WaitForSecondsRealtime(0.3f); Transform[] array = thumbnails; foreach (Transform val4 in array) { CardInfo val5 = sources[((Object)val4).name]; CardInfoDisplayer componentInChildren = ((Component)val4).GetComponentInChildren<CardInfoDisplayer>(); Require((Object)(object)componentInChildren != (Object)null && HasNativeText((TMP_Text)(object)componentInChildren.nameText, val5.CardName), "Thumbnail did not show its native name: " + ((Object)val5).name); if (!string.IsNullOrWhiteSpace(NativeDescription(val5))) { Require((Object)(object)componentInChildren != (Object)null && HasNativeText((TMP_Text)(object)componentInChildren.m_localizedEffectText.Text, val5.CardDescription), "Thumbnail did not show its native description: " + ((Object)val5).name); } } Canvas.ForceUpdateCanvases(); PointerEventData pointer3; Transform thumbnailToHover = (from thumbnail in thumbnails where !((LocalizedReference)sources[((Object)thumbnail).name].LocalizedCardDescription).IsEmpty && TryRaycast((RectTransform)thumbnail, out pointer3) orderby sources[((Object)thumbnail).name].cardStats.Length descending select thumbnail).FirstOrDefault() ?? throw new InvalidOperationException("No visible thumbnail with a native description can be hovered."); PointerEventData pointer = Raycast((RectTransform)thumbnailToHover); CardInfo source = sources[((Object)thumbnailToHover).name]; pointerCurrentRaycast = pointer.pointerCurrentRaycast; Require((Object)(object)ExecuteEvents.ExecuteHierarchy<IPointerEnterHandler>(((RaycastResult)(ref pointerCurrentRaycast)).gameObject, (BaseEventData)(object)pointer, ExecuteEvents.pointerEnterHandler) == (Object)(object)((Component)thumbnailToHover).gameObject, "The EventSystem did not reach the thumbnail's hover handler."); float localizationDeadline = Time.realtimeSinceStartup + 5f; string sourceDescription = source.CardDescription; CardInfoDisplayer val6 = ActivePreview(preview); while (((Object)(object)val6 == (Object)null || !HasNativeText((TMP_Text)(object)val6.nameText, source.CardName) || !HasNativeText((TMP_Text)(object)val6.m_localizedEffectText.Text, sourceDescription)) && Time.realtimeSinceStartup < localizationDeadline) { yield return null; val6 = ActivePreview(preview); } Require((Object)(object)val6 != (Object)null && HasNativeText((TMP_Text)(object)val6.nameText, source.CardName) && HasNativeText((TMP_Text)(object)val6.m_localizedEffectText.Text, sourceDescription), "Hovered game card did not show its localized name and description: " + ((Object)source).name); string hoverFile = Screenshot(capture, outputDirectory, "hover"); float captureDeadline = Time.realtimeSinceStartup + 5f; while ((!File.Exists(gridFile) || !File.Exists(hoverFile)) && Time.realtimeSinceStartup < captureDeadline) { yield return null; } Require(File.Exists(gridFile) && File.Exists(hoverFile), "Game did not write its framebuffer screenshots."); ExecuteEvents.Execute<IPointerExitHandler>(((Component)thumbnailToHover).gameObject, (BaseEventData)(object)pointer, ExecuteEvents.pointerExitHandler); yield return null; Require((Object)(object)ActivePreview(preview) == (Object)null, "Preview stayed visible after pointer exit."); if (screenshotLocale != null) { foreach (object item in CaptureDropdowns(((Component)page).transform, capture, outputDirectory)) { yield return item; } } float top = scroll.verticalNormalizedPosition; pointer.scrollDelta = new Vector2(0f, -1f); pointerCurrentRaycast = pointer.pointerCurrentRaycast; ExecuteEvents.ExecuteHierarchy<IScrollHandler>(((RaycastResult)(ref pointerCurrentRaycast)).gameObject, (BaseEventData)(object)pointer, ExecuteEvents.scrollHandler); yield return null; Require(scroll.verticalNormalizedPosition < top, "A mouse wheel event did not scroll the catalog down."); scroll.verticalNormalizedPosition = 0f; yield return null; Canvas.ForceUpdateCanvases(); Require(TryRaycast((RectTransform)thumbnails[^1], out PointerEventData _), "The final card cannot be reached by scrolling to the bottom."); foreach (object item2 in CheckControls(((Component)page).transform, scroll, sourceCards)) { yield return item2; } Button back = ((Component)page).GetComponentsInChildren<Button>().Single((Button button) => ((Object)button).name == "Back"); RectTransform val7 = (RectTransform)((Component)back).transform; RectTransform val8 = (RectTransform)((Component)page).transform; Rect rect = val7.rect; float x = ((Transform)val8).InverseTransformPoint(((Transform)val7).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center))).x; rect = val8.rect; Require(Mathf.Abs(x - ((Rect)(ref rect)).center.x) < 2f, "Catalog Back is not centered."); ListMenu listMenu = ListMenu.instance ?? throw new InvalidOperationException("The stock menu was unavailable for Back's highlight."); listMenu.MoveBarOutOfWay(); PointerEventData val9 = Raycast(val7); pointerCurrentRaycast = val9.pointerCurrentRaycast; Require((Object)(object)ExecuteEvents.ExecuteHierarchy<IPointerEnterHandler>(((RaycastResult)(ref pointerCurrentRaycast)).gameObject, (BaseEventData)(object)val9, ExecuteEvents.pointerEnterHandler) == (Object)(object)((Component)back).gameObject, "The EventSystem did not reach Back's hover handler."); yield return (object)new WaitForEndOfFrame(); yield return null; Require((Object)(object)listMenu.selectedButton == (Object)(object)((Component)back).GetComponent<ListMenuButton>() && listMenu.bar.activeInHierarchy && Vector3.Distance(listMenu.bar.transform.position, ((Component)back).transform.position) < 1f, "The stock menu highlight did not follow the hovered Back button."); CheckBackVisibility(back, listMenu.bar, scroll.viewport); string backFile = Screenshot(capture, outputDirectory, "back"); float backCaptureDeadline = Time.realtimeSinceStartup + 5f; while (!File.Exists(backFile) && Time.realtimeSinceStartup < backCaptureDeadline) { yield return null; } Require(File.Exists(backFile), "Game did not write the highlighted Back framebuffer."); Click(back); yield return null; Require(main.IsOpen && !page.IsOpen, "Back did not return to the main menu."); Click(entry); yield return null; Require(page.IsOpen && !main.IsOpen && (Object)(object)ActivePreview(preview) == (Object)null, "The catalog did not reopen in a clean state."); foreach (object item3 in CheckReopenedStatFormat(main, page, entry, sources)) { yield return item3; } page = ((Component)Find(((Component)main).transform.parent, "RoundsCardsOverview.Catalog")).GetComponent<ListMenuPage>(); if (holdSeconds > 0) { yield return (object)new WaitForSecondsRealtime((float)holdSeconds); } Object.FindObjectOfType<EscapeMenuHandler>(true).ToggleEsc(); yield return null; Require(main.IsOpen && !page.IsOpen && !EscapeMenuHandler.isEscMenu, "Escape did not return to the main menu."); } private static CardInfoDisplayer? ActivePreview(Transform root) { return ((IEnumerable<CardInfoDisplayer>)((Component)root).GetComponentsInChildren<CardInfoDisplayer>()).FirstOrDefault((Func<CardInfoDisplayer, bool>)((CardInfoDisplayer card) => ((Component)card).gameObject.activeInHierarchy)); } private static IEnumerable<object?> CheckReopenedStatFormat(ListMenuPage main, ListMenuPage page, Button entry, Dictionary<string, CardInfo> sources) { SettingsData settings = Optionshandler.instance.OptionsData.GetSettingsData("OPTION_SHOWSTATNUMBERS") ?? throw new InvalidOperationException("The game stat number setting is missing."); bool original = settings.CurrentValueToggle; bool persist = settings.m_saveInPlayerprefs; ScrollRect componentInChildren = ((Component)page).GetComponentInChildren<ScrollRect>(); Canvas.ForceUpdateCanvases(); PointerEventData pointer; (string CardName, CardInfoStat Stat, string Description) candidate = (from thumbnail in VisibleThumbnails(componentInChildren) where TryRaycast((RectTransform)thumbnail, out pointer) select thumbnail).SelectMany((Transform thumbnail) => from stat in sources[((Object)thumbnail).name].cardStats where (int)stat.simepleAmount > 0 select (CardName: ((Object)thumbnail).name, Stat: stat, Description: stat.GetLocalizedAmount().GetLocalizedString())).First(((string CardName, CardInfoStat Stat, string Description) match) => !string.IsNullOrWhiteSpace(match.Description) && match.Stat.amount != match.Description); string statKey = NativeStatKey(candidate.Stat) ?? throw new InvalidOperationException("The test stat has no localization key."); foreach (object item in CheckRenderedStat(page, candidate.CardName, statKey, original ? candidate.Stat.amount : candidate.Description)) { yield return item; } Click(((Component)page).GetComponentsInChildren<Button>().Single((Button button) => ((Object)button).name == "Back")); yield return null; Require(main.IsOpen && !page.IsOpen, "The main menu did not open before changing the stat format."); settings.m_saveInPlayerprefs = false; try { settings.CurrentValueToggle = !original; Click(entry); yield return null; page = ((Component)Find(((Component)main).transform.parent, "RoundsCardsOverview.Catalog")).GetComponent<ListMenuPage>(); Require(page.IsOpen && !main.IsOpen, "The catalog did not reopen after changing the stat format."); foreach (object item2 in CheckRenderedStat(page, candidate.CardName, statKey, original ? candidate.Description : candidate.Stat.amount)) { yield return item2; } } finally { try { settings.CurrentValueToggle = original; } finally { settings.m_saveInPlayerprefs = persist; } } } private static IEnumerable<object?> CheckRenderedStat(ListMenuPage page, string cardName, string statKey, string expected) { RectTransform thumbnail = (RectTransform)Find(((Component)page).transform, cardName); Require(VisibleStatAmount(((Component)thumbnail).GetComponentInChildren<CardInfoDisplayer>(), statKey) == expected, "The thumbnail stat did not use the selected native format."); Canvas.ForceUpdateCanvases(); PointerEventData pointer = Raycast(thumbnail); RaycastResult pointerCurrentRaycast = pointer.pointerCurrentRaycast; Require((Object)(object)ExecuteEvents.ExecuteHierarchy<IPointerEnterHandler>(((RaycastResult)(ref pointerCurrentRaycast)).gameObject, (BaseEventData)(object)pointer, ExecuteEvents.pointerEnterHandler) == (Object)(object)((Component)thumbnail).gameObject, "The EventSystem did not reach the stat test card's hover handler."); yield return null; Require(VisibleStatAmount(ActivePreview(Find(((Component)page).transform, "Preview")), statKey) == expected, "The preview stat did not match the thumbnail's native format."); ExecuteEvents.Execute<IPointerExitHandler>(((Component)thumbnail).gameObject, (BaseEventData)(object)pointer, ExecuteEvents.pointerExitHandler); yield return null; } private static string? VisibleStatAmount(CardInfoDisplayer? display, string statKey) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if ((Object)(object)display == (Object)null) { return null; } foreach (Transform item in display.grid.transform) { Transform val = item; if (((Component)val).gameObject.activeInHierarchy && val.childCount >= 2) { UILocalizedString component = ((Component)val.GetChild(0)).GetComponent<UILocalizedString>(); if ((Object)(object)component != (Object)null && NativeStringKey(component.LocalizedText) == statKey) { UILocalizedString component2 = ((Component)val.GetChild(1)).GetComponent<UILocalizedString>(); return (component2 != null) ? ((TMP_Text)component2.Text).text : null; } } } return null; } private static IEnumerable<object?> CheckControls(Transform page, ScrollRect scroll, CardInfo[] sourceCards) { TMP_InputField search = ((Component)Find(page, "Search")).GetComponent<TMP_InputField>(); TMP_Dropdown rarity = ((Component)Find(page, "Rarity")).GetComponent<TMP_Dropdown>(); TMP_Dropdown type = ((Component)Find(page, "Type")).GetComponent<TMP_Dropdown>(); TMP_Dropdown sort = ((Component)Find(page, "Sort")).GetComponent<TMP_Dropdown>(); Require(rarity.options.Count == 4 && type.options.Count == 11 && sort.options.Count == 2, "The catalog did not offer all filters and sort options."); Locale selectedLocale = LocalizationSettings.SelectedLocale; int num; LocaleIdentifier identifier; if (selectedLocale == null) { num = 0; } else { identifier = selectedLocale.Identifier; num = (((LocaleIdentifier)(ref identifier)).Code.StartsWith("ru", StringComparison.OrdinalIgnoreCase) ? 1 : 0); } bool flag = (byte)num != 0; Require(type.options[9].text == (flag ? "Похищение здоровья" : "Life steal") && type.options[10].text == (flag ? "Другие свойства" : "Other properties"), "The localized Life steal option should be immediately before Other properties."); Locale selectedLocale2 = LocalizationSettings.SelectedLocale; object obj; if (selectedLocale2 == null) { obj = null; } else { identifier = selectedLocale2.Identifier; obj = ((LocaleIdentifier)(ref identifier)).CultureInfo; } if (obj == null) { obj = CultureInfo.CurrentCulture; } CultureInfo culture = (CultureInfo)obj; StringComparer byName = StringComparer.Create(culture, ignoreCase: true); Dictionary<string, CardInfo> byObjectName = sourceCards.ToDictionary((CardInfo card) => "Card: " + ((Object)card).name); PointerEventData val = Raycast((RectTransform)((Component)search).transform); RaycastResult pointerCurrentRaycast = val.pointerCurrentRaycast; Require((Object)(object)ExecuteEvents.ExecuteHierarchy<IPointerClickHandler>(((RaycastResult)(ref pointerCurrentRaycast)).gameObject, (BaseEventData)(object)val, ExecuteEvents.pointerClickHandler) == (Object)(object)((Component)search).gameObject, "The EventSystem did not reach the catalog search input."); yield return null; Require(search.isFocused, "Clicking the catalog search did not focus the input."); foreach (object item in CheckWordDeletion(search)) { yield return item; } string[] source = (from card in sourceCards select card.CardName into name where !string.IsNullOrWhiteSpace(name) && !name.Contains('<') select name).ToArray(); string nameQuery = source.First((string query) => sourceCards.Any((CardInfo card) => Contains(card.CardName, query) && !Contains(NativeDescription(card), query))); search.text = " " + culture.TextInfo.ToUpper(nameQuery) + " "; yield return null; CheckVisible(scroll, sourceCards.Where((CardInfo card) => Contains(card.CardName, nameQuery) || Contains(NativeDescription(card), nameQuery)), "Name search selected the wrong cards."); string descriptionQuery = (from match in sourceCards.SelectMany((CardInfo card) => Regex.Matches(NativeDescription(card), "\\p{L}{4,}").Cast<Match>()) select match.Value).First((string query) => sourceCards.All((CardInfo card) => !Contains(card.CardName, query)) && sourceCards.Any((CardInfo card) => Contains(NativeDescription(card), query))); search.text = descriptionQuery; yield return null; CheckVisible(scroll, sourceCards.Where((CardInfo card) => Contains(NativeDescription(card), descriptionQuery)), "Description-only search selected the wrong cards."); search.text = "__cards_overview_smoke_no_match__"; yield return null; TMP_Text emptyResults = ((Component)Find(page, "NoResults")).GetComponent<TMP_Text>(); Require(VisibleThumbnails(scroll).Length == 0 && ((Component)emptyResults).gameObject.activeInHierarchy && !string.IsNullOrWhiteSpace(emptyResults.text), "A search with no matches did not show the empty state."); search.text = string.Empty; search.DeactivateInputField(false); yield return null; CheckVisible(scroll, sourceCards, "Clearing the search did not restore the catalog."); Require(!((Component)emptyResults).gameObject.activeInHierarchy, "The empty state remained visible after clearing the search."); CardInfo toxicCloud = sourceCards.Single((CardInfo card) => ((Object)card).name == "Toxic cloud"); Require(toxicCloud.cardStats.All((CardInfoStat stat) => NativeStatKey(stat) != "STAT_DMG"), "The catalog must leave the original Toxic Cloud stats untouched."); search.text = toxicCloud.CardName; yield return null; bool currentValueToggle = Optionshandler.instance.OptionsData.GetSettingsData("OPTION_SHOWSTATNUMBERS").CurrentValueToggle; CardInfoStat val2 = new CardInfoStat { simepleAmount = (SimpleAmount)5 }; foreach (object item2 in CheckRenderedStat(((Component)page).GetComponent<ListMenuPage>(), "Card: " + ((Object)toxicCloud).name, "STAT_DMG", currentValueToggle ? "-25%" : val2.GetLocalizedAmount().GetLocalizedString())) { yield return item2; } search.text = string.Empty; yield return null; foreach (object item3 in PickDropdownOption(rarity, 3, 0.94f)) { yield return item3; } CheckVisible(scroll, sourceCards.Where((CardInfo card) => (int)card.rarity == 2), "The rare filter selected the wrong cards."); string rareQuery = sourceCards.First((CardInfo card) => (int)card.rarity == 2).CardName; search.text = rareQuery; yield return null; CheckVisible(scroll, sourceCards.Where((CardInfo card) => (int)card.rarity == 2 && (Contains(card.CardName, rareQuery) || Contains(NativeDescription(card), rareQuery))), "The rarity filter and search did not combine."); search.text = string.Empty; rarity.value = 0; CardInfo shieldsUp = sourceCards.Single((CardInfo card) => NativeStringKey(card.LocalizedCardName) == "CARD_SHIELDS_UP"); type.value = 2; yield return null; HashSet<string> blockNames = new HashSet<string>(from tile in VisibleThumbnails(scroll) select ((Object)byObjectName[((Object)tile).name]).name); Require(blockNames.Count < sourceCards.Length && blockNames.Contains("Defender") && blockNames.Contains(((Object)shieldsUp).name) && !blockNames.Contains("Quick Shot") && sourceCards.Where((CardInfo card) => card.AffectsBlock).All((CardInfo card) => blockNames.Contains(((Object)card).name)), "The block filter missed Shields Up or another block-affecting card."); type.value = 1; yield return null; CardInfo[] attack = (from tile in VisibleThumbnails(scroll) select byObjectName[((Object)tile).name]).ToArray(); Require(attack.Length != 0 && attack.Length < sourceCards.Length && attack.Any((CardInfo card) => ((Object)card).name == "Quick Shot") && !attack.Contains(shieldsUp) && sourceCards.Where((CardInfo card) => (Object)(object)card != (Object)(object)shieldsUp && HasPositiveStat(card, (string? key) => key == "STAT_DMG")).All((CardInfo card) => attack.Contains(card)), "The attack filter missed weapon modifiers or included the block-only Shields Up card."); type.value = 0; sort.value = 0; yield return null; string[] expectedByName = (from card in sourceCards.OrderBy<CardInfo, string>((CardInfo card) => card.CardName, byName).ThenBy<CardInfo, string>((CardInfo card) => ((Object)card).name, StringComparer.Ordinal) select "Card: " + ((Object)card).name).ToArray(); Require((from tile in VisibleThumbnails(scroll) select ((Object)tile).name).SequenceEqual(expectedByName), "Name sort did not use the localized card names."); foreach (object item4 in PickDropdownOption(sort, 1, 0.96f)) { yield return item4; } yield return null; Rarity[] array = (from tile in VisibleThumbnails(scroll) select byObjectName[((Object)tile).name].rarity).ToArray(); Require(array.Length == sourceCards.Length && array.SequenceEqual(array.OrderByDescending((Rarity value) => value)), "Rarity sort did not put rarer cards first."); ClickDropdownField(sort, 0.02f); yield return null; Transform sortPopup = Find(((Component)sort).transform, "Dropdown List"); PointerEventData obj2 = PointerAt((RectTransform)((Component)search).transform); pointerCurrentRaycast = obj2.pointerCurrentRaycast; GameObject val3 = ExecuteEvents.GetEventHandler<IPointerClickHandler>(((RaycastResult)(ref pointerCurrentRaycast)).gameObject) ?? throw new InvalidOperationException("The sort dropdown did not intercept a click outside the popup."); Require(((Object)val3).name == "Blocker", "The sort dropdown did not intercept a click outside the popup."); DispatchClick(obj2, val3); foreach (object item5 in WaitForPopupClose(sortPopup)) { yield return item5; } Require(((Object)(object)sortPopup == (Object)null || !((Component)sortPopup).gameObject.activeInHierarchy) && sort.value == 1, "Clicking outside the sort dropdown did not dismiss it without changing the selection."); foreach (object item6 in PickDropdownOption(sort, 0, 0.75f)) { yield return item6; } Require((from tile in VisibleThumbnails(scroll) select ((Object)tile).name).SequenceEqual(expectedByName), "Clicking the blank area of Sort did not restore ordering by name."); string[]?[] propertyKeys = new string[8][] { new string[1] { "STAT_HP" }, new string[1] { "STAT_DMG" }, new string[1] { "STAT_BULLET_SPEED" }, new string[1] { "STAT_ATKSPD" }, new string[1] { "STAT_BULLET_BOUNCES" }, new string[2] { "STAT_RELOAD_TIME", "STAT_RELOAD_SPEED" }, new string[1] { "STAT_LIFE_STEAL" }, null }; string[] namedKeys = propertyKeys.OfType<string[]>().SelectMany((string[] result) => result).ToArray(); for (int option = 3; option < type.options.Count; option++) { if (option == 9) { foreach (object item7 in PickDropdownOption(type, option)) { yield return item7; } } else { type.value = option; } yield return null; string[] keys = propertyKeys[option - 3]; CardInfo[] array2 = sourceCards.Where((CardInfo card) => HasProperty(card, keys, namedKeys)).ToArray(); Require(array2.Length != 0 && array2.Length < sourceCards.Length, "The property fixture needs both matching and non-matching cards: " + type.options[option].text); string[] source2 = (from tile in VisibleThumbnails(scroll) select ((Object)byObjectName[((Object)tile).name]).name).ToArray(); switch (option) { case 3: Require(source2.Contains("Tank") && source2.Contains("Defender") && source2.Contains("Glasscannon"), "The health filter missed health bonuses or Glass Cannon's health penalty."); break; case 5: Require(source2.Contains("Fast ball") && source2.Contains("Remote"), "Bullet speed missed Fast ball's bonus or Remote's penalty."); break; case 7: Require(source2.Contains("Bouncy"), "Bounces missed Bouncy's listed property."); break; case 10: Require(source2.Contains("Buckshot"), "Other properties should include Buckshot's projectile count and ammo modifiers."); break; case 9: Require(source2.Contains("Parasite") && source2.Contains("Lifestealer"), "Life steal missed Parasite's listed property or Lifestealer's nearby health drain."); break; } CheckVisible(scroll, array2, "Property filter returned the wrong cards: " + type.options[option].text); } type.value = 0; sort.value = 0; yield return null; bool Contains(string text, string query) { return culture.CompareInfo.IndexOf(text, query, CompareOptions.IgnoreCase) >= 0; } } private static IEnumerable<object?> CheckWordDeletion(TMP_InputField search) { search.text = "alpha beta gamma"; search.ForceLabelUpdate(); search.stringPosition = "alpha beta gamma".Length; SendKey(search, (KeyCode)8, (EventModifiers)2); Require(search.text == "alpha beta ", "Ctrl+Backspace did not delete the previous word."); SendKey(search, (KeyCode)0, (EventModifiers)0, '\u007f'); Require(search.text == "alpha beta ", "The translated Ctrl+Backspace event deleted a second word."); yield return null; search.text = "альфа бета гамма"; search.ForceLabelUpdate(); search.stringPosition = "альфа бета гамма".Length; SendKey(search, (KeyCode)0, (EventModifiers)0, '\u007f'); Require(search.text == "альфа бета ", "The translated Windows Ctrl+Backspace event did not delete the previous Cyrillic word."); yield return null; search.text = "alpha beta gamma"; search.ForceLabelUpdate(); search.stringPosition = "alpha ".Length; SendKey(search, (KeyCode)127, (EventModifiers)2); Require(search.text == "alpha gamma", "Ctrl+Delete did not delete through the next word boundary."); Require(search.stringPosition == "alpha ".Length, "Ctrl+Delete moved the cursor away from the start of the deleted word."); SendKey(search, (KeyCode)279, (EventModifiers)0); SendKey(search, (KeyCode)8, (EventModifiers)0); Require(search.text == "alpha gamm", "Plain Backspace did not delete exactly one character: " + search.text); SendKey(search, (KeyCode)97, (EventModifiers)2); SendKey(search, (KeyCode)8, (EventModifiers)2); Require(search.text.Length == 0, "Ctrl+A followed by Ctrl+Backspace did not delete the entire selected text."); } private static void SendKey(TMP_InputField field, KeyCode key, EventModifiers modifiers = (EventModifiers)0, char character = '\0') { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown field.ProcessEvent(new Event { type = (EventType)4, keyCode = key, modifiers = modifiers, character = character }); } private static IEnumerable<object?> PickDropdownOption(TMP_Dropdown dropdown, int index, float clickAt = 0.5f) { ClickDropdownField(dropdown, clickAt); yield return null; Canvas.ForceUpdateCanvases(); Transform list = Find(((Component)dropdown).transform, "Dropdown List"); Toggle[] array = (from toggle in ((Component)list).GetComponentsInChildren<Toggle>() where ((Component)toggle).gameObject.activeInHierarchy select toggle).ToArray(); Require(array.Length == dropdown.options.Count, "The dropdown did not show all of its options: " + ((Object)dropdown).name); Toggle val = array[index]; DispatchClick(Raycast((RectTransform)((Component)val).transform), ((Component)val).gameObject); foreach (object item in WaitForPopupClose(list)) { yield return item; } Require(dropdown.value == index && ((Object)(object)list == (Object)null || !((Component)list).gameObject.activeInHierarchy), "Clicking an option did not select it and close the dropdown: " + ((Object)dropdown).name); } private static void ClickDropdownField(TMP_Dropdown dropdown, float horizontal) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown DispatchClick(Raycast((RectTransform)((Component)dropdown).transform, horizontal), ((Component)dropdown).gameObject); } private static IEnumerable<object?> WaitForPopupClose(Transform list) { float deadline = Time.realtimeSinceStartup + 2f; while ((Object)(object)list != (Object)null && ((Component)list).gameObject.activeInHierarchy && Time.realtimeSinceStartup < deadline) { yield return null; } } private static void DispatchClick(PointerEventData pointer, GameObject expected) { //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_003d: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) RaycastResult pointerCurrentRaycast = pointer.pointerCurrentRaycast; GameObject val = ((RaycastResult)(ref pointerCurrentRaycast)).gameObject ?? throw new InvalidOperationException($"There is no click target at {pointer.position} for {((Object)expected).name}."); pointer.eligibleForClick = true; pointer.pressPosition = pointer.position; pointer.pointerPressRaycast = pointer.pointerCurrentRaycast; GameObject val2 = (pointer.pointerPress = ExecuteEvents.ExecuteHierarchy<IPointerDownHandler>(val, (BaseEventData)(object)pointer, ExecuteEvents.pointerDownHandler) ?? ExecuteEvents.GetEventHandler<IPointerClickHandler>(val)); ExecuteEvents.Execute<IPointerUpHandler>(val2, (BaseEventData)(object)pointer, ExecuteEvents.pointerUpHandler); GameObject eventHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(val); Require((Object)(object)val2 == (Object)(object)expected && (Object)(object)eventHandler == (Object)(object)expected && ExecuteEvents.Execute<IPointerClickHandler>(eventHandler, (BaseEventData)(object)pointer, ExecuteEvents.pointerClickHandler), $"Pointer at {pointer.position} did not click {((Object)expected).name}. Hit {((Object)val).name}."); } private static void CheckBackVisibility(Button back, GameObject bar, RectTransform viewport) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0032: Expected O, but got Unknown //IL_002d: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019f: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) Rect framebuffer = new Rect(0f, 0f, (float)Screen.width, (float)Screen.height); Rect val = ScreenBounds((RectTransform)((Component)back).transform); TMP_Text val2 = ((Component)back).GetComponentInChildren<TMP_Text>() ?? throw new InvalidOperationException("The Back label has no rendered text."); Require(!string.IsNullOrWhiteSpace(val2.text), "The Back label has no rendered text."); Bounds textBounds = val2.textBounds; Camera camera = CanvasCamera(val2.rectTransform); Rect val3 = ProjectBounds(val2.transform.TransformPoint(((Bounds)(ref textBounds)).min), val2.transform.TransformPoint(((Bounds)(ref textBounds)).max), camera); Transform transform = bar.transform; RectTransform val4 = (RectTransform)(object)((transform is RectTransform) ? transform : null); Rect val5; if (val4 != null) { val5 = ScreenBounds(val4); } else { Renderer val6 = bar.GetComponentInChildren<Renderer>() ?? throw new InvalidOperationException("The stock menu highlight has no visible geometry."); Bounds bounds = val6.bounds; Vector3 min = ((Bounds)(ref bounds)).min; bounds = val6.bounds; val5 = ProjectBounds(min, ((Bounds)(ref bounds)).max, Camera.main); } Rect val7 = ScreenBounds(viewport); Rect? val8 = VisibleClient(framebuffer); Plugin.Instance?.WriteTrace("cards_overview_footer_geometry", string.Format("framebuffer={0}; desktopVisible={1}; button={2}; ", framebuffer, (val8.HasValue ? ((object)val8.GetValueOrDefault()/*cast due to .constrained prefix*/).ToString() : null) ?? "unknown", val) + $"label={val3}; highlight={val5}; viewport={val7}"); Require(WithinFramebufferHeight(val) && WithinFramebufferHeight(val3) && WithinFramebufferHeight(val5) && ((Rect)(ref val3)).xMin >= ((Rect)(ref framebuffer)).xMin - 2f && ((Rect)(ref val3)).xMax <= ((Rect)(ref framebuffer)).xMax + 2f, "Back, its label, or its highlight extends beyond the rendered game frame."); Require(Mathf.Max(((Rect)(ref val)).yMax, Mathf.Max(((Rect)(ref val5)).yMax, ((Rect)(ref val3)).yMax)) <= ((Rect)(ref val7)).yMin + 2f, "Back or its highlight overlaps the scrolling card viewport."); bool WithinFramebufferHeight(Rect val9) { if (((Rect)(ref val9)).height > 0f && ((Rect)(ref val9)).yMin >= ((Rect)(ref framebuffer)).yMin - 2f) { return ((Rect)(ref val9)).yMax <= ((Rect)(ref framebuffer)).yMax + 2f; } return false; } } private static Rect ScreenBounds(RectTransform target) { //IL_0010: 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_0022: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[4]; target.GetWorldCorners(array); return ProjectBounds(array[0], array[2], CanvasCamera(target)); } private static Rect ProjectBounds(Vector3 bottomLeft, Vector3 topRight, Camera? camera) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0027: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) Vector2 val = RectTransformUtility.WorldToScreenPoint(camera, bottomLeft); Vector2 val2 = RectTransformUtility.WorldToScreenPoint(camera, topRight); return Rect.MinMaxRect(Mathf.Min(val.x, val2.x), Mathf.Min(val.y, val2.y), Mathf.Max(val.x, val2.x), Mathf.Max(val.y, val2.y)); } private static Rect? VisibleClient(Rect framebuffer) { //IL_018e: Unknown result type (might be due to invalid IL or missing references) using Process process = Process.GetCurrentProcess(); IntPtr mainWindowHandle = process.MainWindowHandle; if (mainWindowHandle == IntPtr.Zero) { return null; } NativeWindowInfo info = new NativeWindowInfo { Size = Marshal.SizeOf<NativeWindowInfo>() }; NativeMonitorInfo info2 = new NativeMonitorInfo { Size = Marshal.SizeOf<NativeMonitorInfo>() }; IntPtr intPtr = MonitorFromWindow(mainWindowHandle, 2u); if (!GetWindowInfo(mainWindowHandle, ref info) || intPtr == IntPtr.Zero || !GetMonitorInfo(intPtr, ref info2)) { return null; } DesktopRect client = info.Client; if (client.Right <= client.Left || client.Bottom <= client.Top) { return null; } DesktopRect desktopRect = (Screen.fullScreen ? info2.Monitor : info2.WorkArea); float num = ((Rect)(ref framebuffer)).width / (float)(client.Right - client.Left); float num2 = ((Rect)(ref framebuffer)).height / (float)(client.Bottom - client.Top); return Rect.MinMaxRect((float)Math.Max(0, desktopRect.Left - client.Left) * num, (float)Math.Max(0, client.Bottom - desktopRect.Bottom) * num2, ((Rect)(ref framebuffer)).width - (float)Math.Max(0, client.Right - desktopRect.Right) * num, ((Rect)(ref framebuffer)).height - (float)Math.Max(0, desktopRect.Top - client.Top) * num2); } [DllImport("user32.dll")] private static extern IntPtr MonitorFromWindow(IntPtr window, uint flags); [DllImport("user32.dll")] private static extern bool GetWindowInfo(IntPtr window, ref NativeWindowInfo info); [DllImport("user32.dll", EntryPoint = "GetMonitorInfoW")] private static extern bool GetMonitorInfo(IntPtr monitor, ref NativeMonitorInfo info); private static Transform[] VisibleThumbnails(ScrollRect scroll) { return (from Transform child in (IEnumerable)scroll.content where ((Component)child).gameObject.activeInHierarchy && ((Object)child).name.StartsWith("Card: ", StringComparison.Ordinal) select child).ToArray(); } private static void CheckVisible(ScrollRect scroll, IEnumerable<CardInfo> expected, string failure) { string[] array = expected.Select((CardInfo card) => "Card: " + ((Object)card).name).ToArray(); string[] array2 = (from tile in VisibleThumbnails(scroll) select ((Object)tile).name).ToArray(); Require(array.Length == array2.Length && new HashSet<string>(array).SetEquals(array2), $"{failure} Expected {array.Length}, found {array2.Length}."); } private static string NativeDescription(CardInfo card) { string text; if (!((LocalizedReference)card.LocalizedCardDescription).IsEmpty) { text = card.CardDescription; if (text == null) { return string.Empty; } } else { text = string.Empty; } return text; } private static bool HasPositiveStat(CardInfo card, Func<string?, bool> matches) { return card.cardStats.Any((CardInfoStat stat) => stat.positive && matches(NativeStatKey(stat))); } private static bool HasProperty(CardInfo card, string[]? keys, string[] namedKeys) { string[]? array = keys; if (array != null && array.Contains("STAT_LIFE_STEAL") && ((Object)card).name == "Lifestealer") { return true; } if (keys == null) { return card.cardStats.Any((CardInfoStat stat) => !namedKeys.Contains<string>(NativeStatKey(stat))); } if (card.cardStats.Any((CardInfoStat stat) => keys.Contains<string>(NativeStatKey(stat)))) { return true; } Gun component = ((Component)card).GetComponent<Gun>(); if ((Object)(object)component != (Object)null) { if (!keys.Contains("STAT_BULLET_BOUNCES") || component.reflects == 0) { if (keys.Contains("STAT_BULLET_SPEED")) { return component.projectileSpeed != 1f; } return false; } return true; } return false; } private static string? NativeStatKey(CardInfoStat stat) { return NativeStringKey(stat.LocalizedStat); } private static string? NativeStringKey(LocalizedString? localized) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (localized == null) { return null; } TableEntryReference tableEntryReference = ((LocalizedReference)localized).TableEntryReference; if ((int)((TableEntryReference)(ref tableEntryReference)).ReferenceType == 1) { return ((TableEntryReference)(ref tableEntryReference)).Key; } StringTable table = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(((LocalizedReference)localized).TableReference, (Locale)null); if (table == null) { return null; } SharedTableEntry entry = ((LocalizationTable)table).SharedData.GetEntry(((TableEntryReference)(ref tableEntryReference)).KeyId); if (entry == null) { return null; } return entry.Key; } private static bool HasNativeText(TMP_Text text, string expected) { if ((Object)(object)text != (Object)null && ((Component)text).gameObject.activeInHierarchy && !string.IsNullOrWhiteSpace(text.text)) { return string.Equals(text.text.Trim(), expected.Trim(), StringComparison.OrdinalIgnoreCase); } return false; } private static Transform Find(Transform root, string name) { return ((IEnumerable<Transform>)((Component)root).GetComponentsInChildren<Transform>(true)).F