using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UIElements;
[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("StonewardsTogglerPlus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.2.0")]
[assembly: AssemblyInformationalVersion("0.2.2+8ca189968d0db1619d60b0ff4dc8dce8e14f0c6e")]
[assembly: AssemblyProduct("StonewardsTogglerPlus")]
[assembly: AssemblyTitle("StonewardsTogglerPlus")]
[assembly: AssemblyVersion("0.2.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace StonewardsTogglerPlus
{
[BepInPlugin("com.thereisnouser.stonewards.togglerplus", "Stonewards Toggler Plus", "0.2.2")]
public sealed class TogglerPlusPlugin : BaseUnityPlugin
{
public const string PluginGuid = "com.thereisnouser.stonewards.togglerplus";
private const string AddedClass = "stonewards-tp-default";
private static TogglerPlusPlugin _plugin;
private Harmony _harmony;
private static Type _menuType;
private static Type _buttonType;
private static Type _upgradeCategoryType;
private static FieldInfo _menuManager;
private static FieldInfo _menuTemplate;
private static FieldInfo _menuArchetypes;
private static FieldInfo _buttonUnlockable;
private static FieldInfo _buttonCanClick;
private static MethodInfo _getAvailable;
private static MethodInfo _buttonInit;
private static MethodInfo _buttonSetUpgrade;
private static MethodInfo _buttonEnableToggle;
private static MethodInfo _showUnlockable;
private static MethodInfo _getTogglerLevel;
private static readonly HashSet<string> Warnings = new HashSet<string>();
private void Awake()
{
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Expected O, but got Unknown
_plugin = this;
_menuType = AccessTools.TypeByName("UnlockableMenu");
_buttonType = AccessTools.TypeByName("UnlockUpgradeButton");
_upgradeCategoryType = AccessTools.TypeByName("UpgradeCategory");
Type type = AccessTools.TypeByName("UpgradeManager");
Type type2 = AccessTools.TypeByName("UnlockableManager");
if (_menuType == null || _buttonType == null || _upgradeCategoryType == null || type == null || type2 == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Stonewards upgrade types not found. Toggler Plus disabled for this game build.");
return;
}
_menuManager = AccessTools.Field(_menuType, "upgradeManager");
_menuTemplate = AccessTools.Field(_menuType, "unlockableButtonTemplate");
_menuArchetypes = AccessTools.Field(_menuType, "archetypeDatabaseSo");
_buttonUnlockable = AccessTools.Field(_buttonType, "unlockable");
_buttonCanClick = AccessTools.Field(_buttonType, "canClick");
_getAvailable = AccessTools.Method(type, "GetAvailableUpgrades", (Type[])null, (Type[])null);
_buttonInit = AccessTools.Method(_buttonType, "Init", (Type[])null, (Type[])null);
_buttonSetUpgrade = AccessTools.Method(_buttonType, "SetUpgrade", (Type[])null, (Type[])null);
_buttonEnableToggle = AccessTools.Method(_buttonType, "EnableToggle", (Type[])null, (Type[])null);
_showUnlockable = AccessTools.Method(_menuType, "ShowUnlockable", (Type[])null, (Type[])null);
_getTogglerLevel = AccessTools.Method(type2, "GetUpgradableTogglerLevel", (Type[])null, (Type[])null);
if (_menuManager == null || _menuTemplate == null || _menuArchetypes == null || _buttonUnlockable == null || _buttonCanClick == null || _getAvailable == null || _buttonInit == null || _buttonSetUpgrade == null || _buttonEnableToggle == null || _showUnlockable == null || _getTogglerLevel == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Upgrade UI API has changed; no UI patches installed.");
return;
}
_harmony = new Harmony("com.thereisnouser.stonewards.togglerplus");
Patch("InitUI", "AfterMenuBuilt", null);
Patch("RebuildShopButtons", "AfterMenuBuilt", null);
Patch("Show", "AfterShow", new Type[1] { typeof(bool) });
ClassRingRules.Initialize((BaseUnityPlugin)(object)this, _harmony, _buttonType, _buttonUnlockable, _getTogglerLevel);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Toggler Plus initialized. Per-class ring/tome overrides are enabled.");
}
private void Patch(string methodName, string postfixName, Type[] arguments)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
try
{
MethodInfo methodInfo = ((arguments == null) ? AccessTools.Method(_menuType, methodName, (Type[])null, (Type[])null) : AccessTools.Method(_menuType, methodName, arguments, (Type[])null));
if (methodInfo == null)
{
WarnOnce("patch:" + methodName, "Method not found: UnlockableMenu." + methodName);
return;
}
MethodInfo methodInfo2 = AccessTools.Method(typeof(TogglerPlusPlugin), postfixName, (Type[])null, (Type[])null);
_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)("Patched UnlockableMenu." + methodName));
}
catch (Exception ex)
{
WarnOnce("patch:" + methodName, "Could not patch UnlockableMenu." + methodName + ": " + ex);
}
}
private static void AfterMenuBuilt(object __instance)
{
TryAppendDefaults(__instance);
}
private static void AfterShow(object __instance, bool _Show)
{
if (_Show)
{
TryAppendDefaults(__instance);
}
}
private static void TryAppendDefaults(object menu)
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_plugin == (Object)null || menu == null)
{
return;
}
try
{
Component val = (Component)((menu is Component) ? menu : null);
UIDocument val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<UIDocument>() : null);
VisualElement val3 = (((Object)(object)val2 != (Object)null) ? val2.rootVisualElement : null);
object value = _menuManager.GetValue(menu);
object? value2 = _menuTemplate.GetValue(menu);
VisualTreeAsset val4 = (VisualTreeAsset)((value2 is VisualTreeAsset) ? value2 : null);
if (val3 == null || value == null || (Object)(object)val4 == (Object)null)
{
return;
}
Dictionary<string, VisualElement> dictionary = new Dictionary<string, VisualElement>(StringComparer.Ordinal);
HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal);
foreach (VisualElement item in UQueryExtensions.Query<VisualElement>(val3, (string)null, (string)null).ToList())
{
if (!_buttonType.IsInstanceOfType(item) || item.parent == null)
{
continue;
}
object value3 = _buttonUnlockable.GetValue(item);
string text = ReadString(value3, "ID");
if (!string.IsNullOrEmpty(text))
{
hashSet.Add(text);
}
if (item.ClassListContains("stonewards-tp-default"))
{
RefreshAddedToggle(item);
continue;
}
object value4 = _buttonCanClick.GetValue(item);
if (value4 is bool && (bool)value4)
{
if (value3 != null && ReadString(value3, "UpgradeCategory") != null && !ReadBool(value3, "Unlockable", fallback: true) && !ReadBool(value3, "HiddenUpgrade", fallback: false))
{
RefreshAddedToggle(item);
}
string text2 = ReadString(value3, "UpgradeCategory");
if ((text2 == "LEVELUP" || text2 == "PICKUP") && !dictionary.ContainsKey(text2))
{
dictionary.Add(text2, item.parent);
}
}
}
AppendCategory(menu, value, val4, dictionary, hashSet, 0, "LEVELUP");
AppendCategory(menu, value, val4, dictionary, hashSet, 1, "PICKUP");
ClassRingRules.AttachSelector(menu, val3);
}
catch (Exception ex)
{
WarnOnce("inject", "Failed to add default upgrade buttons: " + ex);
}
}
private static void AppendCategory(object menu, object manager, VisualTreeAsset template, Dictionary<string, VisualElement> categoryParents, HashSet<string> alreadyPresent, int categoryValue, string categoryName)
{
if (!categoryParents.TryGetValue(categoryName, out var value))
{
WarnOnce("missing:" + categoryName, "No existing " + categoryName + " button to locate its vanilla grid. Try opening the unlock shop with some upgrades in this category.");
return;
}
object obj = Enum.ToObject(_upgradeCategoryType, categoryValue);
if (!(_getAvailable.Invoke(manager, new object[1] { obj }) is IEnumerable enumerable))
{
return;
}
object value2 = _menuArchetypes.GetValue(menu);
int num = 0;
foreach (object item in enumerable)
{
if (item == null || ReadBool(item, "Unlockable", fallback: true) || ReadBool(item, "HiddenUpgrade", fallback: false))
{
continue;
}
string text = ReadString(item, "ID");
if (string.IsNullOrEmpty(text) || alreadyPresent.Contains(text))
{
continue;
}
object? obj2 = Activator.CreateInstance(_buttonType, nonPublic: true);
VisualElement val = (VisualElement)((obj2 is VisualElement) ? obj2 : null);
if (val != null)
{
template.CloneTree(val);
_buttonInit.Invoke(val, new object[3] { manager, value2, true });
_buttonSetUpgrade.Invoke(val, new object[1] { item });
val.AddToClassList("stonewards-tp-default");
RefreshAddedToggle(val);
VisualElement currentCard = val;
object currentUpgrade = item;
((CallbackEventHandler)val).RegisterCallback<ClickEvent>((EventCallback<ClickEvent>)delegate
{
ShowDetails(menu, currentUpgrade, currentCard);
}, (TrickleDown)0);
((CallbackEventHandler)val).RegisterCallback<NavigationSubmitEvent>((EventCallback<NavigationSubmitEvent>)delegate
{
ShowDetails(menu, currentUpgrade, currentCard);
}, (TrickleDown)0);
value.Add(val);
alreadyPresent.Add(text);
num++;
}
}
if (num > 0)
{
((BaseUnityPlugin)_plugin).Logger.LogInfo((object)("Added " + num + " default " + categoryName + " upgrades."));
}
}
private static void ShowDetails(object menu, object upgrade, VisualElement card)
{
try
{
_showUnlockable.Invoke(menu, new object[2] { upgrade, card });
}
catch (Exception ex)
{
WarnOnce("details", "Could not select default upgrade: " + ex);
}
}
private static void RefreshAddedToggle(VisualElement card)
{
try
{
object obj = AccessTools.Property(AccessTools.TypeByName("UnlockableManager"), "Instance")?.GetValue(null, null);
object value = _buttonCanClick.GetValue(card);
bool flag = default(bool);
int num;
if (value is bool)
{
flag = (bool)value;
num = 1;
}
else
{
num = 0;
}
bool flag2 = ((uint)num & (flag ? 1u : 0u)) != 0 && obj != null && Convert.ToInt32(_getTogglerLevel.Invoke(obj, null)) > 0;
_buttonEnableToggle.Invoke(card, new object[1] { flag2 });
}
catch (Exception ex)
{
WarnOnce("toggle", "Could not refresh default toggle: " + ex);
}
}
private static string ReadString(object obj, string propertyName)
{
if (obj == null)
{
return null;
}
return AccessTools.Property(obj.GetType(), propertyName)?.GetValue(obj, null)?.ToString();
}
private static bool ReadBool(object obj, string propertyName, bool fallback)
{
if (obj == null)
{
return fallback;
}
object obj2 = AccessTools.Property(obj.GetType(), propertyName)?.GetValue(obj, null);
if (obj2 is bool)
{
return (bool)obj2;
}
return fallback;
}
private static void WarnOnce(string key, string message)
{
if ((Object)(object)_plugin != (Object)null && Warnings.Add(key))
{
((BaseUnityPlugin)_plugin).Logger.LogWarning((object)message);
}
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
_plugin = null;
}
}
internal static class ClassRingRules
{
private sealed class Rules
{
internal ConfigEntry<string> AllowEntry;
internal ConfigEntry<string> DenyEntry;
internal HashSet<string> Allowed;
internal HashSet<string> Denied;
}
private struct DraftState
{
internal UpgradeCategory? PreviousScope;
internal PlayerClass? PreviousPlayerClass;
}
private sealed class PixelTab
{
internal Button Control;
internal readonly List<VisualElement> Frame = new List<VisualElement>();
internal readonly List<VisualElement> Surface = new List<VisualElement>();
internal Label Caption;
}
private sealed class SelectorPanel
{
internal VisualElement Root;
internal VisualElement Grid;
internal readonly Dictionary<string, PixelTab> Tabs = new Dictionary<string, PixelTab>(StringComparer.Ordinal);
}
private const string SelectorName = "stonewards-tp-class-selector";
private static BaseUnityPlugin _plugin;
private static ManualLogSource _log;
private static Type _nativeButtonType;
private static FieldInfo _buttonUpgrade;
private static FieldInfo _buttonCanClick;
private static FieldInfo _buttonManager;
private static MethodInfo _isGloballyBlacklisted;
private static FieldInfo _toggleCheck;
private static MethodInfo _refreshToggle;
private static MethodInfo _getTogglerLevel;
private static MethodInfo _isClassValid;
private static bool _warnedClassValidity;
private static readonly Dictionary<UpgradeCategory, Dictionary<PlayerClass, Rules>> PerClass = new Dictionary<UpgradeCategory, Dictionary<PlayerClass, Rules>>();
private static readonly Dictionary<UpgradeCategory, PlayerClass?> Selected = new Dictionary<UpgradeCategory, PlayerClass?>();
[ThreadStatic]
private static UpgradeCategory? _draftScope;
[ThreadStatic]
private static PlayerClass? _draftPlayerClass;
private static FieldInfo _gameManagerInstance;
private static PropertyInfo _localPlayerProperty;
private static FieldInfo _localPlayerClassField;
private static VisualElement _shopRoot;
private static readonly Dictionary<UpgradeCategory, SelectorPanel> Panels = new Dictionary<UpgradeCategory, SelectorPanel>();
internal static void Initialize(BaseUnityPlugin plugin, Harmony harmony, Type nativeButtonType, FieldInfo buttonUpgrade, MethodInfo getTogglerLevel)
{
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: 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_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: 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_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
_plugin = plugin;
_log = Logger.CreateLogSource("StonewardsTogglerPlus.ClassRingRules");
_nativeButtonType = nativeButtonType;
_buttonUpgrade = buttonUpgrade;
_buttonCanClick = AccessTools.Field(nativeButtonType, "canClick");
_buttonManager = AccessTools.Field(nativeButtonType, "upgradeManager");
_isGloballyBlacklisted = AccessTools.Method(AccessTools.TypeByName("UpgradeManager"), "IsUpgradeBlacklisted", new Type[1] { typeof(string) }, (Type[])null);
_getTogglerLevel = getTogglerLevel;
_isClassValid = AccessTools.Method(typeof(RogueLikeUpgradeSO), "IsClassValid", new Type[1] { typeof(PlayerClass) }, (Type[])null);
Type type = AccessTools.TypeByName("GameManager");
if (type != null)
{
_gameManagerInstance = AccessTools.Field(type, "Instance");
_localPlayerProperty = AccessTools.Property(type, "LocalPlayer");
}
Type type2 = AccessTools.TypeByName("FirstPersonController");
if (type2 != null)
{
_localPlayerClassField = AccessTools.Field(type2, "playerClass");
}
_toggleCheck = AccessTools.Field(nativeButtonType, "toggleCheck");
_refreshToggle = AccessTools.Method(nativeButtonType, "RefreshToggle", (Type[])null, (Type[])null);
UpgradeCategory[] array = (UpgradeCategory[])(object)new UpgradeCategory[2]
{
default(UpgradeCategory),
(UpgradeCategory)1
};
foreach (UpgradeCategory val in array)
{
PerClass[val] = new Dictionary<PlayerClass, Rules>();
Selected[val] = null;
string text = (((int)val == 0) ? "ring" : "tome");
foreach (PlayerClass value in Enum.GetValues(typeof(PlayerClass)))
{
ConfigEntry<string> val2 = plugin.Config.Bind<string>("Per-class " + text + " exclusions", ((object)value/*cast due to .constrained prefix*/).ToString(), "", "IDs disabled specifically for this class.");
ConfigEntry<string> val3 = plugin.Config.Bind<string>("Per-class " + text + " inclusions", ((object)value/*cast due to .constrained prefix*/).ToString(), "", "IDs explicitly enabled despite the global Toggler.");
Rules rules = new Rules
{
DenyEntry = val2,
AllowEntry = val3,
Denied = Deserialize(val2.Value),
Allowed = Deserialize(val3.Value)
};
rules.Denied.ExceptWith(rules.Allowed);
PerClass[val][value] = rules;
}
}
Patch(harmony, AccessTools.Method(nativeButtonType, "OnToggleClick", new Type[1] { typeof(ClickEvent) }, (Type[])null), "BeforeToggleClick", prefix: true);
Patch(harmony, _refreshToggle, "AfterRefreshToggle", prefix: false);
Type type3 = AccessTools.TypeByName("RogueLikeUpgradeManager");
PatchDraft(harmony, AccessTools.Method(type3, "CreateValidLevelupDraftPool", (Type[])null, (Type[])null), "EnterRingDraft");
PatchDraft(harmony, AccessTools.Method(type3, "CreateValidPickupDraftPool", (Type[])null, (Type[])null), "EnterTomeDraft");
Patch(harmony, AccessTools.Method(AccessTools.TypeByName("UpgradeManager"), "IsUpgradeBlacklisted", new Type[1] { typeof(RogueLikeUpgradeSO) }, (Type[])null), "AfterBlacklistedCheck", prefix: false);
_log.LogInfo((object)"Class ring/tome allow/deny overrides initialized.");
}
private static void Patch(Harmony harmony, MethodInfo target, string handler, bool prefix)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
if (target == null)
{
_log.LogWarning((object)("Class-ring patch target missing: " + handler));
return;
}
try
{
HarmonyMethod val = new HarmonyMethod(AccessTools.Method(typeof(ClassRingRules), handler, (Type[])null, (Type[])null));
harmony.Patch((MethodBase)target, prefix ? val : null, prefix ? null : val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
catch (Exception ex)
{
_log.LogError((object)("Could not install " + handler + ": " + ex));
}
}
private static void PatchDraft(Harmony harmony, MethodInfo method, string prefixName)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_005c: Expected O, but got Unknown
if (method == null)
{
_log.LogWarning((object)("Draft method missing: " + prefixName));
return;
}
try
{
harmony.Patch((MethodBase)method, new HarmonyMethod(AccessTools.Method(typeof(ClassRingRules), prefixName, (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ClassRingRules), "ExitDraft", (Type[])null, (Type[])null)), (HarmonyMethod)null);
}
catch (Exception ex)
{
_log.LogError((object)("Draft patch failed: " + ex));
}
}
private static void EnterRingDraft(out DraftState __state)
{
EnterDraft((UpgradeCategory)0, out __state);
}
private static void EnterTomeDraft(out DraftState __state)
{
EnterDraft((UpgradeCategory)1, out __state);
}
private static void EnterDraft(UpgradeCategory category, out DraftState state)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
state = new DraftState
{
PreviousScope = _draftScope,
PreviousPlayerClass = _draftPlayerClass
};
_draftScope = category;
_draftPlayerClass = (TryGetLocalClass(out var cls) ? new PlayerClass?(cls) : ((PlayerClass?)null));
}
private static Exception ExitDraft(Exception __exception, DraftState __state)
{
_draftScope = __state.PreviousScope;
_draftPlayerClass = __state.PreviousPlayerClass;
return __exception;
}
private static void AfterBlacklistedCheck(RogueLikeUpgradeSO upgradeSO, ref bool __result)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)upgradeSO == (Object)null) && _draftScope.HasValue && _draftPlayerClass.HasValue && upgradeSO.UpgradeCategory == _draftScope.Value && PerClass.TryGetValue(_draftScope.Value, out var value) && value.TryGetValue(_draftPlayerClass.Value, out var value2))
{
if (value2.Allowed.Contains(((BaseUpgradeSO)upgradeSO).ID))
{
__result = false;
}
else if (value2.Denied.Contains(((BaseUpgradeSO)upgradeSO).ID))
{
__result = true;
}
}
}
private static HashSet<string> Deserialize(string serialized)
{
HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal);
if (string.IsNullOrEmpty(serialized))
{
return hashSet;
}
string[] array = serialized.Split(',');
foreach (string text in array)
{
if (string.IsNullOrWhiteSpace(text))
{
continue;
}
try
{
string text2 = Uri.UnescapeDataString(text.Trim());
if (!string.IsNullOrEmpty(text2))
{
hashSet.Add(text2);
}
}
catch (UriFormatException)
{
}
}
return hashSet;
}
private static bool FindRules(UpgradeCategory cat, PlayerClass cls, out Rules rules)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
rules = null;
if (PerClass.TryGetValue(cat, out var value))
{
return value.TryGetValue(cls, out rules);
}
return false;
}
private static bool EffectiveAllowed(UpgradeCategory cat, PlayerClass cls, string id, bool globalBlacklisted)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (FindRules(cat, cls, out var rules))
{
if (rules.Allowed.Contains(id))
{
return true;
}
if (rules.Denied.Contains(id))
{
return false;
}
}
return !globalBlacklisted;
}
private static void SetClassRule(UpgradeCategory cat, PlayerClass cls, string id, bool allowed)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (FindRules(cat, cls, out var rules))
{
if (allowed)
{
rules.Denied.Remove(id);
rules.Allowed.Add(id);
}
else
{
rules.Allowed.Remove(id);
rules.Denied.Add(id);
}
rules.AllowEntry.Value = Serialize(rules.Allowed);
rules.DenyEntry.Value = Serialize(rules.Denied);
_plugin.Config.Save();
}
}
private static string Serialize(HashSet<string> ids)
{
return string.Join(",", ids.OrderBy<string, string>((string id) => id, StringComparer.Ordinal).Select(Uri.EscapeDataString));
}
private static bool IsUpgradeButton(object button, out RogueLikeUpgradeSO upgrade)
{
//IL_0025: 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_0034: Invalid comparison between Unknown and I4
object? obj = _buttonUpgrade?.GetValue(button);
upgrade = (RogueLikeUpgradeSO)((obj is RogueLikeUpgradeSO) ? obj : null);
if ((Object)(object)upgrade != (Object)null)
{
if ((int)upgrade.UpgradeCategory != 0)
{
return (int)upgrade.UpgradeCategory == 1;
}
return true;
}
return false;
}
private static bool BeforeToggleClick(object __instance)
{
//IL_0014: 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
if (!IsUpgradeButton(__instance, out var upgrade) || !HasPurchasedToggler())
{
return true;
}
UpgradeCategory upgradeCategory = upgrade.UpgradeCategory;
if (!Selected.TryGetValue(upgradeCategory, out var value) || !value.HasValue)
{
return true;
}
string iD = ((BaseUpgradeSO)upgrade).ID;
if (string.IsNullOrEmpty(iD))
{
return false;
}
bool flag = EffectiveAllowed(upgradeCategory, value.Value, iD, IsGloballyBlacklisted(__instance, iD));
SetClassRule(upgradeCategory, value.Value, iD, !flag);
_refreshToggle?.Invoke(__instance, null);
return false;
}
private static void AfterRefreshToggle(object __instance)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
if (_toggleCheck == null || !IsUpgradeButton(__instance, out var upgrade))
{
return;
}
UpgradeCategory upgradeCategory = upgrade.UpgradeCategory;
if (Selected.TryGetValue(upgradeCategory, out var value) && value.HasValue)
{
object? value2 = _toggleCheck.GetValue(__instance);
VisualElement val = (VisualElement)((value2 is VisualElement) ? value2 : null);
if (val != null)
{
bool flag = EffectiveAllowed(upgradeCategory, value.Value, ((BaseUpgradeSO)upgrade).ID, IsGloballyBlacklisted(__instance, ((BaseUpgradeSO)upgrade).ID));
val.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)(!flag));
}
}
}
private static bool IsGloballyBlacklisted(object button, string id)
{
if (button == null || string.IsNullOrEmpty(id) || _buttonManager == null || _isGloballyBlacklisted == null)
{
return false;
}
try
{
object value = _buttonManager.GetValue(button);
return value != null && Convert.ToBoolean(_isGloballyBlacklisted.Invoke(value, new object[1] { id }));
}
catch
{
return false;
}
}
private static bool TryGetLocalClass(out PlayerClass cls)
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected I4, but got Unknown
cls = (PlayerClass)0;
if (_gameManagerInstance == null || _localPlayerProperty == null || _localPlayerClassField == null)
{
return false;
}
try
{
object value = _gameManagerInstance.GetValue(null);
if (value == null)
{
return false;
}
object value2 = _localPlayerProperty.GetValue(value, null);
if (value2 == null)
{
return false;
}
if (!(_localPlayerClassField.GetValue(value2) is PlayerClass val))
{
return false;
}
cls = (PlayerClass)(int)val;
return true;
}
catch
{
return false;
}
}
private static bool HasPurchasedToggler()
{
try
{
object obj = AccessTools.Property(AccessTools.TypeByName("UnlockableManager"), "Instance")?.GetValue(null, null);
return obj != null && Convert.ToInt32(_getTogglerLevel.Invoke(obj, null)) > 0;
}
catch
{
return false;
}
}
internal unsafe static void AttachSelector(object menu, VisualElement root)
{
//IL_0368: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
//IL_03ed: Expected O, but got Unknown
//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
//IL_041e: Unknown result type (might be due to invalid IL or missing references)
//IL_0423: Unknown result type (might be due to invalid IL or missing references)
//IL_0439: Unknown result type (might be due to invalid IL or missing references)
//IL_0467: Unknown result type (might be due to invalid IL or missing references)
//IL_046f: Unknown result type (might be due to invalid IL or missing references)
//IL_0476: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: 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_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Expected O, but got Unknown
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: 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_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Expected O, but got Unknown
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b7: Expected O, but got Unknown
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Unknown result type (might be due to invalid IL or missing references)
if (root == null || !HasPurchasedToggler())
{
return;
}
if (_shopRoot != root)
{
_shopRoot = root;
Panels.Clear();
Selected[(UpgradeCategory)0] = null;
Selected[(UpgradeCategory)1] = null;
}
UpgradeCategory[] array = (UpgradeCategory[])(object)new UpgradeCategory[2]
{
default(UpgradeCategory),
(UpgradeCategory)1
};
for (int i = 0; i < array.Length; i++)
{
UpgradeCategory val = array[i];
VisualElement val2 = FindCategoryGrid(root, val);
if (val2 == null || val2.parent == null)
{
continue;
}
if (Panels.TryGetValue(val, out var value) && value.Root.parent == val2.parent && value.Grid == val2)
{
RefreshCategoryChecks(root, val);
continue;
}
if (value != null && value.Root.parent != null)
{
value.Root.RemoveFromHierarchy();
}
VisualElement val3 = UQueryExtensions.Q<VisualElement>(root, "stonewards-tp-class-selector-" + ((object)(*(UpgradeCategory*)(&val))/*cast due to .constrained prefix*/).ToString(), (string)null);
if (val3 != null)
{
val3.RemoveFromHierarchy();
}
SelectorPanel selectorPanel = new SelectorPanel
{
Grid = val2
};
VisualElement val4 = (selectorPanel.Root = new VisualElement
{
name = "stonewards-tp-class-selector-" + ((object)(*(UpgradeCategory*)(&val))/*cast due to .constrained prefix*/).ToString()
});
val4.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)0);
val4.style.marginTop = StyleLength.op_Implicit(9f);
val4.style.marginBottom = StyleLength.op_Implicit(13f);
val4.style.paddingTop = StyleLength.op_Implicit(8f);
val4.style.paddingBottom = StyleLength.op_Implicit(11f);
val4.style.paddingLeft = StyleLength.op_Implicit(3f);
val4.style.paddingRight = StyleLength.op_Implicit(3f);
val4.style.backgroundColor = StyleColor.op_Implicit(Color.clear);
val4.style.borderBottomWidth = StyleFloat.op_Implicit(2f);
val4.style.borderBottomColor = StyleColor.op_Implicit(new Color(0.55f, 0.48f, 0.34f, 1f));
Label val5 = new Label(((int)val == 0) ? "RINGS - CLASS FILTER" : "TOMES - CLASS FILTER");
((VisualElement)val5).style.color = StyleColor.op_Implicit(new Color(0.99f, 0.84f, 0.55f, 1f));
((VisualElement)val5).style.fontSize = StyleLength.op_Implicit(23f);
((VisualElement)val5).style.unityFontStyleAndWeight = StyleEnum<FontStyle>.op_Implicit((FontStyle)1);
((VisualElement)val5).style.marginBottom = StyleLength.op_Implicit(10f);
val4.Add((VisualElement)(object)val5);
VisualElement val6 = new VisualElement();
val6.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
val6.style.flexWrap = StyleEnum<Wrap>.op_Implicit((Wrap)1);
val6.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
val6.style.marginBottom = StyleLength.op_Implicit(4f);
val4.Add(val6);
AddModeButton(selectorPanel, val6, val, "ALL", null);
object? obj = AccessTools.Field(menu.GetType(), "archetypeDatabaseSo")?.GetValue(menu);
PlayerArchetypeDatabaseSO val7 = (PlayerArchetypeDatabaseSO)((obj is PlayerArchetypeDatabaseSO) ? obj : null);
foreach (PlayerClass value2 in Enum.GetValues(typeof(PlayerClass)))
{
Sprite icon = null;
if ((Object)(object)val7 != (Object)null)
{
try
{
PlayerArchetypeSO playerArchetype = val7.GetPlayerArchetype(value2);
if ((Object)(object)playerArchetype == (Object)null)
{
continue;
}
icon = playerArchetype.Icon;
goto IL_03a1;
}
catch
{
}
continue;
}
goto IL_03a1;
IL_03a1:
AddModeButton(selectorPanel, val6, val, ((object)value2/*cast due to .constrained prefix*/).ToString(), (PlayerClass?)value2, icon);
}
Label val9 = new Label("ALL: default | Class: override");
((VisualElement)val9).style.fontSize = StyleLength.op_Implicit(15f);
((VisualElement)val9).style.color = StyleColor.op_Implicit(new Color(0.85f, 0.85f, 0.85f, 1f));
((VisualElement)val9).style.marginTop = StyleLength.op_Implicit(6f);
val4.Add((VisualElement)(object)val9);
VisualElement parent = val2.parent;
parent.Insert(parent.IndexOf(val2), val4);
Panels[val] = selectorPanel;
RefreshModeButtons(val);
RefreshCategoryChecks(root, val);
}
}
private static VisualElement FindCategoryGrid(VisualElement root, UpgradeCategory category)
{
//IL_0003: 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_004d: 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)
foreach (VisualElement item in UQueryExtensions.Query<VisualElement>(root, (string)null, (string)null).ToList())
{
if (_nativeButtonType == null || !_nativeButtonType.IsInstanceOfType(item) || item.parent == null || !IsUpgradeButton(item, out var upgrade) || upgrade.UpgradeCategory != category)
{
continue;
}
if (_buttonCanClick != null)
{
object value = _buttonCanClick.GetValue(item);
if (value is bool && !(bool)value)
{
continue;
}
}
return item.parent;
}
return null;
}
private static void AddModeButton(SelectorPanel panel, VisualElement row, UpgradeCategory category, string text, PlayerClass? cls, Sprite icon = null)
{
//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_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: 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_00db: 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_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
//IL_0343: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Expected O, but got Unknown
//IL_0352: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_037c: Unknown result type (might be due to invalid IL or missing references)
//IL_0391: Unknown result type (might be due to invalid IL or missing references)
//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
//IL_0489: Unknown result type (might be due to invalid IL or missing references)
//IL_0490: Expected O, but got Unknown
//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
//IL_04de: Unknown result type (might be due to invalid IL or missing references)
//IL_0407: Unknown result type (might be due to invalid IL or missing references)
//IL_040c: Unknown result type (might be due to invalid IL or missing references)
//IL_0415: Expected O, but got Unknown
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
//IL_0437: Unknown result type (might be due to invalid IL or missing references)
//IL_044d: Unknown result type (might be due to invalid IL or missing references)
//IL_0463: Unknown result type (might be due to invalid IL or missing references)
//IL_0476: Unknown result type (might be due to invalid IL or missing references)
Button val = new Button((Action)delegate
{
//IL_0006: 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_0027: Unknown result type (might be due to invalid IL or missing references)
Selected[category] = cls;
RefreshModeButtons(category);
RefreshCategoryChecks(_shopRoot, category);
});
((TextElement)val).text = string.Empty;
((VisualElement)val).RemoveFromClassList("unity-button");
((VisualElement)val).style.position = StyleEnum<Position>.op_Implicit((Position)0);
((VisualElement)val).style.height = StyleLength.op_Implicit(46f);
((VisualElement)val).style.width = StyleLength.op_Implicit((float)(cls.HasValue ? Math.Max(104, text.Length * 11 + (((Object)(object)icon != (Object)null) ? 49 : 26)) : 86));
((VisualElement)val).style.marginRight = StyleLength.op_Implicit(6f);
((VisualElement)val).style.marginBottom = StyleLength.op_Implicit(6f);
((VisualElement)val).style.paddingLeft = StyleLength.op_Implicit(0f);
((VisualElement)val).style.paddingRight = StyleLength.op_Implicit(0f);
((VisualElement)val).style.paddingTop = StyleLength.op_Implicit(0f);
((VisualElement)val).style.paddingBottom = StyleLength.op_Implicit(0f);
((VisualElement)val).style.backgroundColor = StyleColor.op_Implicit(Color.clear);
((VisualElement)val).style.borderTopWidth = StyleFloat.op_Implicit(0f);
((VisualElement)val).style.borderBottomWidth = StyleFloat.op_Implicit(0f);
((VisualElement)val).style.borderLeftWidth = StyleFloat.op_Implicit(0f);
((VisualElement)val).style.borderRightWidth = StyleFloat.op_Implicit(0f);
PixelTab pixelTab = new PixelTab
{
Control = val
};
pixelTab.Frame.Add(Slice((VisualElement)(object)val, 12f, 12f, 0f, -1f, 4f));
pixelTab.Frame.Add(Slice((VisualElement)(object)val, 6f, 6f, 4f, -1f, 5f));
pixelTab.Frame.Add(Slice((VisualElement)(object)val, 0f, 0f, 9f, 9f, -1f));
pixelTab.Frame.Add(Slice((VisualElement)(object)val, 6f, 6f, -1f, 4f, 5f));
pixelTab.Frame.Add(Slice((VisualElement)(object)val, 12f, 12f, -1f, 0f, 4f));
pixelTab.Surface.Add(Slice((VisualElement)(object)val, 13f, 13f, 2f, -1f, 4f));
pixelTab.Surface.Add(Slice((VisualElement)(object)val, 8f, 8f, 6f, -1f, 5f));
pixelTab.Surface.Add(Slice((VisualElement)(object)val, 2f, 2f, 11f, 11f, -1f));
pixelTab.Surface.Add(Slice((VisualElement)(object)val, 8f, 8f, -1f, 6f, 5f));
pixelTab.Surface.Add(Slice((VisualElement)(object)val, 13f, 13f, -1f, 2f, 4f));
VisualElement val2 = new VisualElement
{
pickingMode = (PickingMode)1
};
val2.style.position = StyleEnum<Position>.op_Implicit((Position)1);
val2.style.left = StyleLength.op_Implicit(7f);
val2.style.right = StyleLength.op_Implicit(7f);
val2.style.top = StyleLength.op_Implicit(0f);
val2.style.bottom = StyleLength.op_Implicit(0f);
val2.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
val2.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
val2.style.justifyContent = StyleEnum<Justify>.op_Implicit((Justify)1);
((VisualElement)val).Add(val2);
if (cls.HasValue && (Object)(object)icon != (Object)null)
{
VisualElement val3 = new VisualElement
{
pickingMode = (PickingMode)1
};
val3.style.width = StyleLength.op_Implicit(26f);
val3.style.height = StyleLength.op_Implicit(26f);
val3.style.flexShrink = StyleFloat.op_Implicit(0f);
val3.style.marginRight = StyleLength.op_Implicit(5f);
val3.style.backgroundImage = new StyleBackground(icon);
val2.Add(val3);
}
Label val4 = new Label(text);
((VisualElement)val4).pickingMode = (PickingMode)1;
((VisualElement)val4).style.fontSize = StyleLength.op_Implicit(19f);
((VisualElement)val4).style.unityFontStyleAndWeight = StyleEnum<FontStyle>.op_Implicit((FontStyle)1);
((VisualElement)val4).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)4);
((VisualElement)val4).style.flexShrink = StyleFloat.op_Implicit(0f);
val2.Add((VisualElement)(object)val4);
pixelTab.Caption = val4;
row.Add((VisualElement)(object)val);
panel.Tabs[text] = pixelTab;
}
private static VisualElement Slice(VisualElement parent, float left, float right, float top, float bottom, float height)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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_0085: Unknown result type (might be due to invalid IL or missing references)
VisualElement val = new VisualElement
{
pickingMode = (PickingMode)1
};
val.style.position = StyleEnum<Position>.op_Implicit((Position)1);
val.style.left = StyleLength.op_Implicit(left);
val.style.right = StyleLength.op_Implicit(right);
if (top >= 0f)
{
val.style.top = StyleLength.op_Implicit(top);
}
if (bottom >= 0f)
{
val.style.bottom = StyleLength.op_Implicit(bottom);
}
if (height >= 0f)
{
val.style.height = StyleLength.op_Implicit(height);
}
parent.Add(val);
return val;
}
private static void RefreshModeButtons(UpgradeCategory category)
{
//IL_0005: 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_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
if (!Panels.TryGetValue(category, out var value))
{
return;
}
Selected.TryGetValue(category, out var value2);
foreach (KeyValuePair<string, PixelTab> tab in value.Tabs)
{
bool flag = (value2.HasValue ? (tab.Key == ((object)value2.Value/*cast due to .constrained prefix*/).ToString()) : (tab.Key == "ALL"));
PixelTab value3 = tab.Value;
Color val = (flag ? new Color(0.95f, 0.73f, 0.36f, 1f) : new Color(0.54f, 0.47f, 0.34f, 1f));
Color val2 = (flag ? new Color(0.13f, 0.17f, 0.22f, 1f) : new Color(0.28f, 0.32f, 0.37f, 1f));
foreach (VisualElement item in value3.Frame)
{
item.style.backgroundColor = StyleColor.op_Implicit(val);
}
foreach (VisualElement item2 in value3.Surface)
{
item2.style.backgroundColor = StyleColor.op_Implicit(val2);
}
((VisualElement)value3.Caption).style.color = StyleColor.op_Implicit(flag ? new Color(1f, 0.87f, 0.59f, 1f) : new Color(0.96f, 0.96f, 0.93f, 1f));
}
}
private static bool IsAvailableToClass(RogueLikeUpgradeSO upgrade, PlayerClass cls)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
if (_isClassValid == null)
{
if (!_warnedClassValidity)
{
_log.LogWarning((object)"RogueLikeUpgradeSO.IsClassValid missing; class ring visibility unchanged.");
_warnedClassValidity = true;
}
return true;
}
try
{
return Convert.ToBoolean(_isClassValid.Invoke(upgrade, new object[1] { cls }));
}
catch (Exception ex)
{
if (!_warnedClassValidity)
{
_log.LogWarning((object)("Could not check class ring eligibility: " + ex));
_warnedClassValidity = true;
}
return true;
}
}
private static void RefreshCategoryChecks(VisualElement root, UpgradeCategory category)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
if (root == null || _nativeButtonType == null || _refreshToggle == null)
{
return;
}
if ((int)category == 0 && Panels.TryGetValue(category, out var value) && value.Grid != null)
{
Selected.TryGetValue(category, out var value2);
foreach (VisualElement item in value.Grid.Children())
{
if (_nativeButtonType.IsInstanceOfType(item) && IsUpgradeButton(item, out var upgrade) && (int)upgrade.UpgradeCategory == 0)
{
bool flag = !value2.HasValue || IsAvailableToClass(upgrade, value2.Value);
item.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)(!flag));
}
}
}
foreach (VisualElement item2 in UQueryExtensions.Query<VisualElement>(root, (string)null, (string)null).ToList())
{
if (_nativeButtonType.IsInstanceOfType(item2) && IsUpgradeButton(item2, out var upgrade2) && upgrade2.UpgradeCategory == category)
{
try
{
_refreshToggle.Invoke(item2, null);
}
catch
{
}
}
}
}
}
}