using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Pigeon; using Sparroh.UI; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("UpgradeFiltering")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("UpgradeFiltering")] [assembly: AssemblyTitle("UpgradeFiltering")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public class FilterPanelUI { private UIWindow _window; private bool isExpanded; private bool isInitialized; private readonly Dictionary _rarityButtons = new Dictionary(); private UIButton _favShowAll; private UIButton _favOnly; private UIButton _favHide; private UIScrollView _statScroll; public bool IsExpanded => isExpanded; public void Toggle() { if (!isInitialized) { CreateFilterPanel(); if (!isInitialized) { return; } } isExpanded = !isExpanded; if (isExpanded) { RegenerateStatFilters(); _window.Show(); } else { _window.Hide(false); } } public void RegenerateStatFilters() { try { if (isInitialized && _statScroll != null) { UpgradeFilteringPlugin.CurrentFilters.StatIncludeList.Clear(); UpgradeFilteringPlugin.CurrentFilters.FilterStats = false; RebuildStatToggles(); } } catch { } } public void RebuildFilterPanel() { try { bool num = isExpanded; if (_window != null) { _window.Destroy(); _window = null; } _rarityButtons.Clear(); isInitialized = false; isExpanded = false; CreateFilterPanel(); if (num && isInitialized) { isExpanded = true; _window.Show(); } } catch { } } private void CreateFilterPanel() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) if (isInitialized) { return; } try { UITheme.Initialize(); _window = UIWindow.Create("UpgradeFilter", (Vector2?)new Vector2(280f, 480f), "Upgrade Filters", true, true, (int?)(UITheme.WindowSortingOrder + 7)); _window.OnClose((Action)delegate { isExpanded = false; }); Transform content = _window.Content; UIFactory.AddVerticalLayout(((Component)content).gameObject, UITheme.S(6f), UITheme.ScaledPadding(6, 6, 6, 6), (TextAnchor)0, true, false, true, true); UIButton.Create(content, "Clear All Filters", (Action)ClearAllFilters, (UIButtonStyle)2, (string)null, (float?)UITheme.S(28f)); UIText.Create(content, "RarityLbl", "Hide Rarities", UITheme.ScaledFontSmall, (Color?)UIColors.TextSecondary, (TextAlignmentOptions)513, false); (string, Rarity)[] obj = new(string, Rarity)[5] { ("Standard", (Rarity)0), ("Rare", (Rarity)1), ("Epic", (Rarity)2), ("Exotic", (Rarity)3), ("Oddity", (Rarity)4) }; UpgradeFilteringPlugin.CurrentFilters.HiddenRarities.Clear(); (string, Rarity)[] array = obj; for (int num = 0; num < array.Length; num++) { (string, Rarity) tuple = array[num]; Rarity rarity = tuple.Item2; UIButton value = UIButton.Create(content, tuple.Item1, (Action)delegate { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (UpgradeFilteringPlugin.CurrentFilters.HiddenRarities.Contains(rarity)) { UpgradeFilteringPlugin.CurrentFilters.HiddenRarities.Remove(rarity); _rarityButtons[rarity].SetStyle((UIButtonStyle)0); } else { UpgradeFilteringPlugin.CurrentFilters.HiddenRarities.Add(rarity); _rarityButtons[rarity].SetStyle((UIButtonStyle)2); } RefreshUpgrades(); }, (UIButtonStyle)0, (string)null, (float?)UITheme.S(24f)); _rarityButtons[rarity] = value; } UIText.Create(content, "FavLbl", "Favorites", UITheme.ScaledFontSmall, (Color?)UIColors.TextSecondary, (TextAlignmentOptions)513, false); _favShowAll = UIButton.Create(content, "Show All", (Action)delegate { UpgradeFilteringPlugin.CurrentFilters.FavoriteSetting = SortHandlingMod.FavoriteFilter.ShowAll; UpdateFavoriteHighlights(); RefreshUpgrades(); }, (UIButtonStyle)3, (string)null, (float?)UITheme.S(24f)); _favOnly = UIButton.Create(content, "Only Favorite", (Action)delegate { UpgradeFilteringPlugin.CurrentFilters.FavoriteSetting = SortHandlingMod.FavoriteFilter.ShowOnlyFavorited; UpdateFavoriteHighlights(); RefreshUpgrades(); }, (UIButtonStyle)0, (string)null, (float?)UITheme.S(24f)); _favHide = UIButton.Create(content, "Hide Favorite", (Action)delegate { UpgradeFilteringPlugin.CurrentFilters.FavoriteSetting = SortHandlingMod.FavoriteFilter.HideFavorited; UpdateFavoriteHighlights(); RefreshUpgrades(); }, (UIButtonStyle)0, (string)null, (float?)UITheme.S(24f)); UIText.Create(content, "StatLbl", "Show Only With", UITheme.ScaledFontSmall, (Color?)UIColors.TextSecondary, (TextAlignmentOptions)513, false); _statScroll = UIScrollView.Create(content, "StatScroll", true, false); GameObject gameObject = _statScroll.GameObject; float? num2 = UITheme.S(160f); float? num3 = UITheme.S(120f); UIHelpers.EnsureLayoutElement(gameObject, (float?)null, num2, num3); RebuildStatToggles(); _window.Hide(false); isInitialized = true; isExpanded = false; } catch (Exception) { isInitialized = false; } } private void UpdateFavoriteHighlights() { SortHandlingMod.FavoriteFilter favoriteSetting = UpgradeFilteringPlugin.CurrentFilters.FavoriteSetting; if (_favShowAll != null) { _favShowAll.SetStyle((UIButtonStyle)((favoriteSetting == SortHandlingMod.FavoriteFilter.ShowAll) ? 3 : 0)); } if (_favOnly != null) { _favOnly.SetStyle((UIButtonStyle)((favoriteSetting == SortHandlingMod.FavoriteFilter.ShowOnlyFavorited) ? 3 : 0)); } if (_favHide != null) { _favHide.SetStyle((UIButtonStyle)((favoriteSetting == SortHandlingMod.FavoriteFilter.HideFavorited) ? 3 : 0)); } } private void ClearAllFilters() { UpgradeFilteringPlugin.CurrentFilters.HiddenRarities.Clear(); UpgradeFilteringPlugin.CurrentFilters.FavoriteSetting = SortHandlingMod.FavoriteFilter.ShowAll; UpgradeFilteringPlugin.CurrentFilters.FilterStats = false; UpgradeFilteringPlugin.CurrentFilters.StatIncludeList.Clear(); foreach (KeyValuePair rarityButton in _rarityButtons) { rarityButton.Value.SetStyle((UIButtonStyle)0); } UpdateFavoriteHighlights(); RebuildStatToggles(); RefreshUpgrades(); } private void RebuildStatToggles() { if (_statScroll == null) { return; } UIHelpers.DestroyChildren((Transform)(object)_statScroll.Content); foreach (string item in from p in GetContextAwareProperties() orderby p select p) { string text = item.Replace("_", " "); string prop = item; GameObject gameObject = UIToggle.Create((Transform)(object)_statScroll.Content, text, false, (Action)delegate(bool value) { if (value) { UpgradeFilteringPlugin.CurrentFilters.FilterStats = true; if (!UpgradeFilteringPlugin.CurrentFilters.StatIncludeList.Contains(prop)) { UpgradeFilteringPlugin.CurrentFilters.StatIncludeList.Add(prop); } } else { UpgradeFilteringPlugin.CurrentFilters.StatIncludeList.Remove(prop); if (UpgradeFilteringPlugin.CurrentFilters.StatIncludeList.Count == 0) { UpgradeFilteringPlugin.CurrentFilters.FilterStats = false; } } RefreshUpgrades(); }, (string)null).GameObject; float? num = UITheme.S(22f); UIHelpers.EnsureLayoutElement(gameObject, (float?)null, num, (float?)null); } } private List GetContextAwareProperties() { try { GameObject obj = GameObject.Find("Gear Details"); GearDetailsWindow val = ((obj != null) ? obj.GetComponent() : null); bool flag = false; if ((Object)(object)val != (Object)null) { FieldInfo fieldInfo = AccessTools.Field(typeof(GearDetailsWindow), "inSkinMode"); if (fieldInfo != null) { try { flag = (bool)fieldInfo.GetValue(val); } catch { } } } return flag ? DiscoverSkinProperties() : GetCuratedUpgradeProperties(); } catch { return GetCuratedUpgradeProperties(); } } private static List GetCuratedUpgradeProperties() { return new List { "AmmoCapacity", "AutomaticFire", "BatteryCapacity", "BulletsPerShot", "BurstFire", "Carver_Blood", "Charge", "Damage", "FireInterval", "Globbler_Globblometer", "Health", "HealthRegenDelay", "HitForce", "MagazineSize", "MaxBounces", "MeleeDamage", "Range", "Recoil", "Reload", "Speed" }; } private static List DiscoverSkinProperties() { List list = new List(); try { Type skinUpgradePropertyType = typeof(GearUpgradeUI).Assembly.GetType("SkinUpgradeProperty"); if (skinUpgradePropertyType == null) { return list; } foreach (Type item in (from t in skinUpgradePropertyType.Assembly.GetTypes() where t.IsClass && !t.IsAbstract && skinUpgradePropertyType.IsAssignableFrom(t) && t.FullName != null && t.FullName.StartsWith("SkinUpgradeProperty_") select t).ToList()) { string text = item.Name; if (text.StartsWith("SkinUpgradeProperty_")) { text = text.Substring("SkinUpgradeProperty_".Length); } list.Add(text); } return (from p in list.Distinct() orderby p select p).ToList(); } catch { return list; } } private void RefreshUpgrades() { //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.Find("Gear Details"); GearDetailsWindow val = ((obj != null) ? obj.GetComponent() : null); if ((Object)(object)val == (Object)null) { return; } try { FieldInfo fieldInfo = AccessTools.Field(typeof(GearDetailsWindow), "inSkinMode"); bool flag = false; if (fieldInfo != null) { flag = (bool)fieldInfo.GetValue(val); } FieldInfo fieldInfo2 = (flag ? AccessTools.Field(typeof(GearDetailsWindow), "currentSortingMethodSkins") : AccessTools.Field(typeof(GearDetailsWindow), "currentSortingMethodUpgrades")); SortingMethod val2 = (SortingMethod)0; if (fieldInfo2 != null) { try { val2 = (SortingMethod)fieldInfo2.GetValue(val); } catch { } } FieldInfo fieldInfo3 = AccessTools.Field(typeof(GearDetailsWindow), "upgradeUIs") ?? AccessTools.Field(typeof(GearDetailsWindow), "k__BackingField") ?? AccessTools.Field(typeof(GearDetailsWindow), "upgrades"); if (fieldInfo3 != null) { List list = (List)fieldInfo3.GetValue(val); if (list != null) { int num = 0; foreach (GearUpgradeUI item in list) { bool flag2 = true; if (UpgradeFilteringPlugin.CurrentFilters.HiddenRarities.Any()) { flag2 &= !UpgradeFilteringPlugin.CurrentFilters.HiddenRarities.Contains(((HoverInfoUpgrade)item).Upgrade.Upgrade.Rarity); } switch (UpgradeFilteringPlugin.CurrentFilters.FavoriteSetting) { case SortHandlingMod.FavoriteFilter.ShowOnlyFavorited: flag2 &= ((HoverInfoUpgrade)item).Upgrade.Favorite; break; case SortHandlingMod.FavoriteFilter.HideFavorited: flag2 &= !((HoverInfoUpgrade)item).Upgrade.Favorite; break; } if (UpgradeFilteringPlugin.CurrentFilters.FilterStats && UpgradeFilteringPlugin.CurrentFilters.StatIncludeList.Any()) { bool flag3 = true; foreach (string statInclude in UpgradeFilteringPlugin.CurrentFilters.StatIncludeList) { bool flag4 = false; Enumerator properties = ((HoverInfoUpgrade)item).Upgrade.Upgrade.GetProperties(); while (((Enumerator)(ref properties)).MoveNext()) { string text = ((object)((Enumerator)(ref properties)).Current).GetType().Name; if (text.StartsWith("UpgradeProperty_")) { text = text.Substring("UpgradeProperty_".Length); } else if (text.StartsWith("SkinUpgradeProperty_")) { text = text.Substring("SkinUpgradeProperty_".Length); } if (text == statInclude) { flag4 = true; break; } } if (!flag4) { flag3 = false; break; } } flag2 = flag2 && flag3; } ((Component)item).gameObject.SetActive(flag2); if (flag2) { num++; ((Component)item).transform.SetSiblingIndex(num - 1); } } FieldInfo fieldInfo4 = AccessTools.Field(typeof(GearDetailsWindow), "upgradeUICount"); if (fieldInfo4 != null) { fieldInfo4.SetValue(val, num); } } } AccessTools.Method(typeof(GearDetailsWindow), "SortUpgrades", new Type[2] { typeof(SortingMethod), typeof(bool) }, (Type[])null)?.Invoke(val, new object[2] { val2, false }); try { AccessTools.Method(typeof(GearDetailsWindow), "SwitchUpgradeView", (Type[])null, (Type[])null)?.Invoke(val, new object[0]); AccessTools.Method(typeof(GearDetailsWindow), "SwitchUpgradeView", (Type[])null, (Type[])null)?.Invoke(val, new object[0]); } catch { } } catch { } } } public static class SortHandlingMod { public struct FilterSettings { public List HiddenRarities; public bool FilterStats; public List StatIncludeList; public FavoriteFilter FavoriteSetting; } public enum FavoriteFilter { ShowAll, ShowOnlyFavorited, HideFavorited } } public static class UpgradeFilteringPlugin { private class FilterPanelUI_LegacyRemoved { private GameObject filterPanel; private bool isExpanded; private bool isInitialized; public bool IsExpanded => isExpanded; private void CreateFilterPanel() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) if (isInitialized) { return; } GameObject val = GameObject.Find("Gear Details/UpgradeList"); Transform val2 = null; if ((Object)(object)val != (Object)null) { val2 = val.transform; } else { GameObject val3 = GameObject.Find("Gear Details"); if (!((Object)(object)val3 != (Object)null)) { return; } val2 = val3.transform; } filterPanel = new GameObject("UpgradeFilterPanel"); filterPanel.transform.SetParent(val2, false); ((Graphic)filterPanel.AddComponent()).color = new Color(0.1f, 0.1f, 0.1f, 0.9f); VerticalLayoutGroup obj = filterPanel.AddComponent(); ((LayoutGroup)obj).padding = new RectOffset(5, 5, 5, 5); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 3f; ((LayoutGroup)obj).childAlignment = (TextAnchor)0; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false; RectTransform component = filterPanel.GetComponent(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); component.pivot = new Vector2(0f, 1f); component.sizeDelta = new Vector2(200f, 300f); component.anchoredPosition = new Vector2(-200f, -80f); if (!((Object)(object)filterPanel == (Object)null) && !((Object)(object)filterPanel.transform == (Object)null)) { try { CreateClearAllFiltersButton(); CreateRarityFilter(); CreateFavoriteFilter(); CreateStatFilters(); } catch (Exception) { return; } filterPanel.SetActive(false); isInitialized = true; } } private void CreateRarityFilter() { //IL_002f: 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) CreateUITextObject("RarityFilterLabel", "Hide Rarities:", 12f, filterPanel.transform).GetComponent().sizeDelta = new Vector2(180f, 20f); var obj = new[] { new { Name = "Standard", Rarity = (Rarity)0 }, new { Name = "Rare", Rarity = (Rarity)1 }, new { Name = "Epic", Rarity = (Rarity)2 }, new { Name = "Exotic", Rarity = (Rarity)3 }, new { Name = "Oddity", Rarity = (Rarity)4 } }; CurrentFilters.HiddenRarities.Clear(); var array = obj; foreach (var anon in array) { CreateRarityToggleButton(anon.Name, anon.Rarity); } FixRarityButtonTextPosition(); } private GameObject CreateRarityToggleButton(string text, Rarity rarity) { //IL_0007: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_009f: 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_00cc: Expected O, but got Unknown //IL_0107: 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) //IL_0133: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)filterPanel == (Object)null) { return null; } GameObject val = new GameObject("FilterButton_" + text.Replace(" ", "_")); if ((Object)(object)val == (Object)null) { return null; } val.AddComponent(); val.transform.SetParent(filterPanel.transform, false); Image buttonImage = val.AddComponent(); ((Graphic)buttonImage).color = new Color(0.3f, 0.3f, 0.3f, 1f); Button val2 = val.AddComponent