using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BetterStatsMenu;
using BrigadeModMenu;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization;
using UnityEngine.Localization.Components;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(BetterStatsMenuMod), "Better Stats Menu", "2.0.1", "Better Stats Menu", null)]
[assembly: MelonGame("BoltBlasterGames", "TheSpellBrigade")]
[assembly: MelonOptionalDependencies(new string[] { "BrigadeModMenu" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BetterStatsMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1")]
[assembly: AssemblyProduct("BetterStatsMenu")]
[assembly: AssemblyTitle("BetterStatsMenu")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BrigadeModMenu
{
public static class ModMenuCompat
{
public static Page Entry(this Page page, MelonPreferences_Entry entry, Func<string> label = null)
{
if (entry != null)
{
return page.Entry(entry.Raw, label ?? ((Func<string>)(() => entry.DisplayName)));
}
return page;
}
public static Page Category(this Page page, MelonPreferences_Category category)
{
if (category == null)
{
return page;
}
Menu.HideCategory(category.Identifier);
foreach (MelonPreferences_Entry e in category.Entries)
{
if (e != null && !e.IsHidden)
{
page.Entry(e.Raw, (Func<string>)(() => e.DisplayName));
}
}
return page;
}
}
}
namespace BetterStatsMenu
{
public class BetterStatsMenuMod : MelonMod
{
internal static MelonLogger.Instance Log;
internal static MelonPreferences_Entry<bool> SoftCaps;
internal static MelonPreferences_Entry<float> RedTint;
internal static MelonPreferences_Entry<bool> DpsRow;
internal static MelonPreferences_Entry<bool> SpellLines;
internal static MelonPreferences_Entry<bool> UpgradeBonuses;
internal static MelonPreferences_Entry<bool> StatIcons;
internal static MelonPreferences_Entry<bool> SpellAugments;
internal static MelonPreferences_Entry<bool> ScrollsPage;
internal static MelonPreferences_Entry<bool> PartyPage;
internal static MelonPreferences_Entry<int> OrderYourStats;
internal static MelonPreferences_Entry<int> OrderSpells;
internal static MelonPreferences_Entry<int> OrderScrolls;
internal static MelonPreferences_Entry<int> OrderParty;
private float _retryAt;
private string _lastError;
public override void OnInitializeMelon()
{
Log = base.LoggerInstance;
MelonPreferences_Category melonPreferences_Category = MelonPreferences.CreateCategory("BetterStatsMenu", "Better Stats Menu");
SoftCaps = melonPreferences_Category.CreateEntry("SoftCaps", default_value: true, "Show Soft Caps", "Show soft caps next to wizard stats");
RedTint = melonPreferences_Category.CreateEntry("RedTint", 0.6f, "Red Tint at Cap", "How red the value turns at or above the cap (0 = no tint, 1 = fully red)", is_hidden: false, dont_save_default: false, new ValueRange<float>(0f, 1f));
DpsRow = melonPreferences_Category.CreateEntry("DpsRow", default_value: true, "Show DPS", "A DPS row (all your spells together) at the top of Your Stats");
SpellLines = melonPreferences_Category.CreateEntry("SpellStatLines", default_value: true, "Show Spell Stats", "Every stat of each spell (damage, cast speed, size, ...) under its DPS / Damage / Time");
UpgradeBonuses = melonPreferences_Category.CreateEntry("UpgradeBonuses", default_value: true, "Upgrade Bonuses", "After each spell stat, how much your upgrades for that spell added, e.g. (+15%)");
StatIcons = melonPreferences_Category.CreateEntry("StatIcons", default_value: true, "Stat Icons", "The pause menu's icons next to each spell stat");
SpellAugments = melonPreferences_Category.CreateEntry("SpellAugments", default_value: true, "Show Spell Augments", "Each spell's augments (and how many of each) under its stats, as in the pause menu");
ScrollsPage = melonPreferences_Category.CreateEntry("ScrollsPage", default_value: true, "Show Scrolls Page", "A page listing your scrolls with their pictures and descriptions");
PartyPage = melonPreferences_Category.CreateEntry("PartyPage", default_value: true, "Show Party Page", "In multiplayer, a page comparing everyone's stats side by side");
OrderYourStats = melonPreferences_Category.CreateEntry("OrderYourStats", 1, "Your Stats Position", null, is_hidden: true);
OrderSpells = melonPreferences_Category.CreateEntry("OrderSpellStats", 2, "Spell Stats Position", null, is_hidden: true);
OrderScrolls = melonPreferences_Category.CreateEntry("OrderScrolls", 3, "Scrolls Position", null, is_hidden: true);
OrderParty = melonPreferences_Category.CreateEntry("OrderParty", 4, "Party Position", null, is_hidden: true);
MigrateOldSettings(melonPreferences_Category);
SoftCapsFeature.Install(base.HarmonyInstance);
if (Array.Exists(AppDomain.CurrentDomain.GetAssemblies(), (Assembly a) => a.GetName().Name == "BrigadeModMenu"))
{
try
{
RegisterMenu();
}
catch (Exception ex)
{
Log.Warning("Mod List page: " + ex.Message);
}
}
Log.Msg("ready");
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static void RegisterMenu()
{
MenuPage.Register();
}
private static void MigrateOldSettings(MelonPreferences_Category category)
{
try
{
MelonPreferences_Entry<bool> melonPreferences_Entry = category.CreateEntry("MigratedFromStatSoftCaps", default_value: false, null, null, is_hidden: true);
MelonPreferences_Category melonPreferences_Category = MelonPreferences.CreateCategory("StatSoftCaps", "Stat Soft Caps (old)", is_hidden: true);
MelonPreferences_Entry<bool> melonPreferences_Entry2 = melonPreferences_Category.CreateEntry("Enabled", default_value: true);
MelonPreferences_Entry<float> melonPreferences_Entry3 = melonPreferences_Category.CreateEntry("RedTint", 0.6f);
if (!melonPreferences_Entry.Value)
{
SoftCaps.Value = melonPreferences_Entry2.Value;
RedTint.Value = melonPreferences_Entry3.Value;
melonPreferences_Entry.Value = true;
category.SaveToFile(printmsg: false);
Log.Msg("moved the Stat Soft Caps settings over");
}
}
catch (Exception ex)
{
Log.Warning("old settings: " + ex.Message);
}
}
public override void OnUpdate()
{
if (Time.unscaledTime < _retryAt)
{
return;
}
try
{
Pages.Tick();
}
catch (Exception ex)
{
string name = ex.GetType().Name;
string? stackTrace = ex.StackTrace;
string text = name + ((stackTrace != null) ? stackTrace.Split('\n')[0] : null);
if (_lastError != text)
{
_lastError = text;
Log.Error($"stats pages: {ex}");
}
_retryAt = Time.unscaledTime + 2f;
}
}
}
internal static class MenuPage
{
private const string Indent = " ";
private static readonly List<string> Positions = new List<string> { "1st", "2nd", "3rd", "4th" };
[MethodImpl(MethodImplOptions.NoInlining)]
internal static void Register()
{
Menu.AddPage("BetterStatsMenu", "Better Stats Menu").Header((Func<string>)(() => "Your Stats")).Entry(BetterStatsMenuMod.DpsRow, () => "Show DPS")
.Entry(BetterStatsMenuMod.SoftCaps, () => "Show Soft Caps")
.Entry(BetterStatsMenuMod.RedTint, () => " Red Tint at Cap")
.Header((Func<string>)(() => "Spell Stats"))
.Entry(BetterStatsMenuMod.SpellLines, () => "Show Spell Stats")
.Entry(BetterStatsMenuMod.UpgradeBonuses, () => " Upgrade Bonuses")
.Entry(BetterStatsMenuMod.StatIcons, () => " Stat Icons")
.Entry(BetterStatsMenuMod.SpellAugments, () => "Show Spell Augments")
.Header((Func<string>)(() => "Scrolls"))
.Entry(BetterStatsMenuMod.ScrollsPage, () => "Show Scrolls Page")
.Header((Func<string>)(() => "Party Stats"))
.Entry(BetterStatsMenuMod.PartyPage, () => "Show Party Stats Page")
.Header((Func<string>)(() => "Page Order"))
.Note((Func<string>)(() => "The 1st page is the one the stats menu opens on."))
.Choice("Your Stats", (IList<string>)Positions, (Func<int>)(() => Get(BetterStatsMenuMod.OrderYourStats)), (Action<int>)delegate(int i)
{
Set(BetterStatsMenuMod.OrderYourStats, i);
}, (int?)0)
.Choice("Spell Stats", (IList<string>)Positions, (Func<int>)(() => Get(BetterStatsMenuMod.OrderSpells)), (Action<int>)delegate(int i)
{
Set(BetterStatsMenuMod.OrderSpells, i);
}, (int?)1)
.Choice("Scrolls", (IList<string>)Positions, (Func<int>)(() => Get(BetterStatsMenuMod.OrderScrolls)), (Action<int>)delegate(int i)
{
Set(BetterStatsMenuMod.OrderScrolls, i);
}, (int?)2)
.Choice("Party Stats", (IList<string>)Positions, (Func<int>)(() => Get(BetterStatsMenuMod.OrderParty)), (Action<int>)delegate(int i)
{
Set(BetterStatsMenuMod.OrderParty, i);
}, (int?)3);
}
private static int Get(MelonPreferences_Entry<int> entry)
{
return Math.Clamp(entry.Value - 1, 0, Positions.Count - 1);
}
private static void Set(MelonPreferences_Entry<int> entry, int index)
{
int num = index + 1;
int value = entry.Value;
if (num == value)
{
return;
}
MelonPreferences_Entry<int>[] array = new MelonPreferences_Entry<int>[4]
{
BetterStatsMenuMod.OrderYourStats,
BetterStatsMenuMod.OrderSpells,
BetterStatsMenuMod.OrderScrolls,
BetterStatsMenuMod.OrderParty
};
foreach (MelonPreferences_Entry<int> melonPreferences_Entry in array)
{
if (melonPreferences_Entry != entry && melonPreferences_Entry.Value == num)
{
melonPreferences_Entry.Value = value;
}
}
entry.Value = num;
entry.Category.SaveToFile(printmsg: false);
Menu.Refresh();
}
}
internal static class Pages
{
private sealed class CatalogRow
{
public StatType Type;
public Sprite Icon;
public string Title;
public BaseSpellStatEntry Entry;
public string Format(float value)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)Entry != (Object)null && !((Il2CppObjectBase)Entry).WasCollected && (Object)(object)Entry.statValue != (Object)null)
{
Entry.SetStatValue(value);
return Entry.statValue.text;
}
}
catch
{
}
return FormatValue(Type, value);
}
}
private const float PageHeight = 1270f;
private const float BlockGap = 40f;
private const float LineStep = 40f;
private const float LineFont = 36f;
private const float RefreshEvery = 0.5f;
private const float IconSize = 36f;
private static StatPanelShower _shower;
private static StatPanelsNavigator _navigator;
private static StatPanel_Spells _spellsPanel;
private static StatPanel_Player _playerPanel;
private static readonly List<StatPanel> SpellPages = new List<StatPanel>();
private static readonly List<StatPanel> RelicPages = new List<StatPanel>();
private static RectTransform _totalDpsRow;
private static float _nextRefresh;
private static float _nextSearch;
private static bool _titleOverridden;
private static readonly (StatType type, string name)[] SpellStatNames = new(StatType, string)[10]
{
((StatType)0, "Damage"),
((StatType)2, "Cast Speed"),
((StatType)6, "Spell Size"),
((StatType)1, "Range"),
((StatType)3, "Projectile Speed"),
((StatType)4, "Duration"),
((StatType)5, "Tick Rate"),
((StatType)20, "Projectiles"),
((StatType)12, "Critical Chance"),
((StatType)13, "Critical Damage")
};
private static FontStyles? _titleStyle;
private static Sprite _augmentIcon;
private static float _nextAugmentIconTry;
private static List<CatalogRow> _catalog;
private static float _nextCatalogTry;
private const float RelicGap = 24f;
private static readonly List<RectTransform> RelicRows = new List<RectTransform>();
private const string Table = "Localization_Strings";
private static readonly Regex Placeholder = new Regex("\\{(?:[A-Za-z_]+\\.)*(?:Parameter)?(\\d)(?::[^}]*)?\\}", RegexOptions.Compiled);
private static Transform _holder;
private const float RowStep = 72f;
private const float PortraitSize = 72f;
private const float NameHeight = 90f;
private const float HeaderHeight = 170f;
private const float LabelWidth = 330f;
private const float MaxColumn = 200f;
private static readonly List<StatPanel> PartyPages = new List<StatPanel>();
private static readonly List<RectTransform> PartyRows = new List<RectTransform>();
private static int _partyColumns = -1;
internal static void Tick()
{
if (!FindOverlay())
{
return;
}
bool num = (Object)(object)_shower.canvasGroup != (Object)null && _shower.canvasGroup.alpha > 0.01f;
UpdateTitle();
if (!num)
{
if (Time.unscaledTime >= _nextRefresh)
{
_nextRefresh = Time.unscaledTime + 1f;
SyncNavigator();
}
}
else if (!(Time.unscaledTime < _nextRefresh))
{
_nextRefresh = Time.unscaledTime + 0.5f;
IPlayerStats playerStats = _shower.playerStats;
if (playerStats != null)
{
Dictionary<SpellType, CachedSpellStat> dictionary = SpellStatsBySpell(playerStats);
UpdateTotalDps(dictionary);
UpdateSpellPages(dictionary, playerStats);
UpdateRelicPages();
UpdatePartyPage();
}
}
}
private static bool FindOverlay()
{
if ((Object)(object)_shower != (Object)null && !((Il2CppObjectBase)_shower).WasCollected && (Object)(object)_navigator != (Object)null && (Object)(object)_spellsPanel != (Object)null && (Object)(object)_playerPanel != (Object)null)
{
return true;
}
_shower = null;
if (Time.unscaledTime < _nextSearch)
{
return false;
}
_nextSearch = Time.unscaledTime + 2f;
using (IEnumerator<StatPanelShower> enumerator = Object.FindObjectsOfType<StatPanelShower>().GetEnumerator())
{
if (enumerator.MoveNext())
{
_shower = enumerator.Current;
}
}
if ((Object)(object)_shower == (Object)null)
{
return false;
}
_navigator = _shower.navigator;
_spellsPanel = _shower.spellStatsPanel;
_playerPanel = _shower.playerStatsPanel;
SpellPages.Clear();
RelicPages.Clear();
RelicRows.Clear();
_holder = null;
PartyPages.Clear();
PartyRows.Clear();
_partyColumns = -1;
_totalDpsRow = null;
if ((Object)(object)_navigator != (Object)null && (Object)(object)_spellsPanel != (Object)null)
{
return (Object)(object)_playerPanel != (Object)null;
}
return false;
}
private static Dictionary<SpellType, CachedSpellStat> SpellStatsBySpell(IPlayerStats stats)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
Dictionary<SpellType, CachedSpellStat> dictionary = new Dictionary<SpellType, CachedSpellStat>();
IReadOnlyList<CachedSpellStat> val = stats.CreateCachedSpellStats();
if (val == null)
{
return dictionary;
}
int count = ((Il2CppObjectBase)val).Cast<IReadOnlyCollection<CachedSpellStat>>().Count;
for (int i = 0; i < count; i++)
{
CachedSpellStat val2 = val[i];
if (val2 != (CachedSpellStat)null)
{
dictionary[val2.Spell] = val2;
}
}
return dictionary;
}
private static void UpdateTotalDps(Dictionary<SpellType, CachedSpellStat> spells)
{
if ((Object)(object)_totalDpsRow == (Object)null)
{
Transform val = LastActiveRow(((Component)_playerPanel).transform);
if ((Object)(object)val == (Object)null)
{
return;
}
GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)_playerPanel).transform, false);
((Object)val2).name = "BSM_TotalDps";
foreach (PlayerStatEntry component in val2.GetComponents<PlayerStatEntry>())
{
Object.DestroyImmediate((Object)(object)component);
}
foreach (LocalizeStringEvent componentsInChild in val2.GetComponentsInChildren<LocalizeStringEvent>(true))
{
Object.DestroyImmediate((Object)(object)componentsInChild);
}
val2.transform.SetAsFirstSibling();
_totalDpsRow = val2.GetComponent<RectTransform>();
TMP_Text val3 = FindText(val2.transform, "Stat_Text");
if ((Object)(object)val3 != (Object)null)
{
val3.text = "DPS";
}
Transform obj = val2.transform.Find("Image");
Image val4 = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
Sprite val5 = FindDamageIcon();
if ((Object)(object)val4 != (Object)null && (Object)(object)val5 != (Object)null)
{
val4.sprite = val5;
}
}
bool value = BetterStatsMenuMod.DpsRow.Value;
if (((Component)_totalDpsRow).gameObject.activeSelf != value)
{
((Component)_totalDpsRow).gameObject.SetActive(value);
}
if (!value)
{
return;
}
float num = 0f;
foreach (CachedSpellStat value2 in spells.Values)
{
num += value2.Dps;
}
TMP_Text val6 = FindText((Transform)(object)_totalDpsRow, "Value_Text");
if ((Object)(object)val6 != (Object)null)
{
val6.text = num.ToString("#,0", CultureInfo.InvariantCulture);
}
}
private static Transform LastActiveRow(Transform panel)
{
Transform result = null;
for (int i = 0; i < panel.childCount; i++)
{
Transform child = panel.GetChild(i);
if (((Component)child).gameObject.activeSelf && (Object)(object)((Component)child).GetComponent<PlayerStatEntry>() != (Object)null)
{
result = child;
}
}
return result;
}
private static Sprite FindDamageIcon()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
foreach (PlayerStatEntry componentsInChild in ((Component)_playerPanel).GetComponentsInChildren<PlayerStatEntry>(true))
{
if ((Object)(object)componentsInChild != (Object)null && (int)componentsInChild.GetStat() == 0)
{
Image statIcon = componentsInChild.statIcon;
return (statIcon != null) ? statIcon.sprite : null;
}
}
return null;
}
private static void UpdateSpellPages(Dictionary<SpellType, CachedSpellStat> cached, IPlayerStats stats)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
List<SpellStatsEntry> entries = _spellsPanel.entries;
Dictionary<SpellType, SpellAttributes> spellStats = _spellsPanel.spellStats;
if (entries == null || spellStats == null)
{
return;
}
List<SpellType> list = new List<SpellType>();
Enumerator<SpellType, SpellAttributes> enumerator = spellStats.GetEnumerator();
while (enumerator.MoveNext())
{
KeyValuePair<SpellType, SpellAttributes> current = enumerator.Current;
list.Add(current.Key);
}
List<(RectTransform, float)> list2 = new List<(RectTransform, float)>();
for (int i = 0; i < entries.Count; i++)
{
SpellStatsEntry val = entries[i];
if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeSelf && i < list.Count)
{
cached.TryGetValue(list[i], out var value);
int num = FillStatLines(val, list[i], value, stats);
float item = ((num > 0) ? (260f + (float)(num + 1) * 40f) : 250f);
list2.Add((((Component)val).GetComponent<RectTransform>(), item));
}
}
List<List<(RectTransform, float)>> list3 = new List<List<(RectTransform, float)>>();
List<(RectTransform, float)> list4 = new List<(RectTransform, float)>();
float num2 = 0f;
foreach (var item2 in list2)
{
float num3 = ((list4.Count > 0) ? 40f : 0f) + item2.Item2;
if (list4.Count > 0 && num2 + num3 > 1270f)
{
list3.Add(list4);
list4 = new List<(RectTransform, float)>();
num2 = 0f;
num3 = item2.Item2;
}
list4.Add(item2);
num2 += num3;
}
if (list4.Count > 0)
{
list3.Add(list4);
}
EnsurePageCount(SpellPages, Math.Max(0, list3.Count - 1), (StatPanelType)2, "BSM_SpellStats");
for (int j = 0; j < list3.Count; j++)
{
StatPanel val2 = ((j == 0) ? ((Il2CppObjectBase)_spellsPanel).Cast<StatPanel>() : SpellPages[j - 1]);
float num4 = 0f;
foreach (var (val3, num5) in list3[j])
{
if (((Il2CppObjectBase)((Transform)val3).parent).Pointer != ((Il2CppObjectBase)((Component)val2).transform).Pointer)
{
((Transform)val3).SetParent(((Component)val2).transform, false);
}
val3.anchoredPosition = new Vector2(val3.anchoredPosition.x, 0f - num4 - 125f);
num4 += num5 + 40f;
}
}
SyncNavigator();
}
private static int FillStatLines(SpellStatsEntry entry, SpellType spellType, CachedSpellStat spell, IPlayerStats stats)
{
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: 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_010d: 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_011e: Invalid comparison between Unknown and I4
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: 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)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_0333: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_0348: Unknown result type (might be due to invalid IL or missing references)
//IL_034d: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_0366: Unknown result type (might be due to invalid IL or missing references)
Transform obj = ((Component)entry).transform.Find("Time");
RectTransform val = ((obj != null) ? ((Component)obj).GetComponent<RectTransform>() : null);
if ((Object)(object)val == (Object)null)
{
return 0;
}
SpellAttributes attributes = null;
try
{
_spellsPanel.spellStats?.TryGetValue(spellType, ref attributes);
}
catch
{
}
List<(Sprite, string, string)> list = new List<(Sprite, string, string)>();
List<CatalogRow> list2 = Catalog();
if (BetterStatsMenuMod.SpellLines.Value)
{
if (list2.Count > 0)
{
foreach (CatalogRow item5 in list2)
{
CachedStat val2 = FindStat(spell, item5.Type);
if (val2 != null)
{
list.Add((item5.Icon, item5.Title, item5.Format(val2.Value) + Bonus(attributes, spellType, item5.Type)));
}
}
}
else
{
(StatType, string)[] spellStatNames = SpellStatNames;
for (int i = 0; i < spellStatNames.Length; i++)
{
(StatType, string) tuple = spellStatNames[i];
StatType item = tuple.Item1;
string item2 = tuple.Item2;
CachedStat val3 = FindStat(spell, item);
if (val3 != null && ((int)item != 20 || !(val3.Value <= 0f)))
{
list.Add((null, item2, FormatValue(item, val3.Value) + Bonus(attributes, spellType, item)));
}
}
}
}
int count = list.Count;
if (BetterStatsMenuMod.SpellAugments.Value)
{
Sprite item3 = AugmentIcon();
foreach (var (item4, num) in Augments(spellType, spell))
{
list.Add((item3, item4, (num > 1) ? $"{num}x" : ""));
}
}
int num2 = ((count > 0 && list.Count > count) ? 1 : 0);
for (int j = 0; j < Math.Max(list.Count, CountLines(entry)); j++)
{
Transform obj3 = ((Component)entry).transform.Find($"BSM_Stat_{j}");
RectTransform val4 = ((obj3 != null) ? ((Component)obj3).GetComponent<RectTransform>() : null);
if (j >= list.Count)
{
if ((Object)(object)val4 != (Object)null)
{
((Component)val4).gameObject.SetActive(false);
}
continue;
}
if ((Object)(object)val4 == (Object)null)
{
val4 = MakeLine(((Component)entry).transform, val, j);
}
((Component)val4).gameObject.SetActive(true);
val4.anchoredPosition = new Vector2(val.anchoredPosition.x, val.anchoredPosition.y - (float)(j + 2 + ((j >= count) ? num2 : 0)) * 40f);
TMP_Text val5 = FindText((Transform)(object)val4, "Title");
TMP_Text val6 = FindText((Transform)(object)val4, "Value_Text");
bool flag = j >= count;
if ((Object)(object)val5 != (Object)null)
{
val5.text = list[j].Item2;
FontStyles valueOrDefault = _titleStyle.GetValueOrDefault();
if (!_titleStyle.HasValue)
{
valueOrDefault = val5.fontStyle;
_titleStyle = valueOrDefault;
}
val5.fontStyle = (FontStyles)(flag ? (_titleStyle.Value & -57) : _titleStyle.Value);
}
if ((Object)(object)val6 != (Object)null)
{
val6.text = list[j].Item3;
}
Transform obj4 = ((Transform)val4).Find("BSM_Icon");
Image val7 = ((obj4 != null) ? ((Component)obj4).GetComponent<Image>() : null);
if ((Object)(object)val7 != (Object)null)
{
val7.sprite = list[j].Item1;
((Behaviour)val7).enabled = (Object)(object)list[j].Item1 != (Object)null && (flag || BetterStatsMenuMod.StatIcons.Value);
}
}
return list.Count + num2;
}
private static Sprite AugmentIcon()
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_augmentIcon != (Object)null && !((Il2CppObjectBase)_augmentIcon).WasCollected)
{
return _augmentIcon;
}
if (Time.unscaledTime < _nextAugmentIconTry)
{
return null;
}
_nextAugmentIconTry = Time.unscaledTime + 5f;
foreach (SpellVariantEntry item in Resources.FindObjectsOfTypeAll<SpellVariantEntry>())
{
if ((Object)(object)item == (Object)null)
{
continue;
}
Scene scene = ((Component)item).gameObject.scene;
if (!((Scene)(ref scene)).IsValid())
{
continue;
}
Image val = null;
foreach (Image componentsInChild in ((Component)item).GetComponentsInChildren<Image>(true))
{
if (!((Object)(object)componentsInChild.sprite == (Object)null))
{
string text = (((Object)componentsInChild.sprite).name + " " + ((Object)componentsInChild).name).ToLowerInvariant();
bool flag = text.Contains("icon") || text.Contains("augment") || text.Contains("variant");
if ((Object)(object)val == (Object)null || flag)
{
val = componentsInChild;
}
if (flag)
{
break;
}
}
}
if (!((Object)(object)val == (Object)null))
{
_augmentIcon = val.sprite;
BetterStatsMenuMod.Log.Msg($"augment icon from the pause menu: {((Object)val.sprite).name} ({((Object)val).name})");
return _augmentIcon;
}
}
return null;
}
private unsafe static List<(string name, int stacks)> Augments(SpellType spellType, CachedSpellStat spell)
{
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: 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)
List<(string, int)> list = new List<(string, int)>();
try
{
IReadOnlyDictionary<SpellVariant, int> val = ((spell != null) ? spell.StacksPerVariant : null);
if (val == null)
{
return list;
}
List<(SpellVariant, int)> list2 = new List<(SpellVariant, int)>();
Dictionary<SpellVariant, int> val2 = ((Il2CppObjectBase)val).TryCast<Dictionary<SpellVariant, int>>();
if (val2 != null)
{
Enumerator<SpellVariant, int> enumerator = val2.GetEnumerator();
while (enumerator.MoveNext())
{
KeyValuePair<SpellVariant, int> current = enumerator.Current;
list2.Add((current.Key, current.Value));
}
}
else
{
int item = default(int);
foreach (SpellVariant value in Enum.GetValues(typeof(SpellVariant)))
{
if (val.TryGetValue(value, ref item))
{
list2.Add((value, item));
}
}
}
foreach (var (val4, num) in list2)
{
if (num <= 0)
{
continue;
}
string text = null;
try
{
SpellVariantData val5 = StoreItemDataRepository.Get(spellType, val4);
if ((Object)(object)val5 != (Object)null)
{
text = Localize(((StoreItemData)val5).TitleEntry);
}
}
catch
{
}
list.Add((string.IsNullOrEmpty(text) ? ((object)(*(SpellVariant*)(&val4))/*cast due to .constrained prefix*/).ToString() : text, num));
}
}
catch
{
}
return list;
}
private static string Bonus(SpellAttributes attributes, SpellType spell, StatType type)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Invalid comparison between Unknown and I4
if (attributes == null || !BetterStatsMenuMod.UpgradeBonuses.Value)
{
return "";
}
try
{
float sumOfNonStartingModifiers = attributes.GetSumOfNonStartingModifiers(type);
if (Mathf.Abs(sumOfNonStartingModifiers) < 0.0001f)
{
return "";
}
string value = ((sumOfNonStartingModifiers > 0f) ? "+" : "");
string text = (((int)attributes.GetStatCalculationType(spell, type) == 1) ? $"{value}{sumOfNonStartingModifiers:0.##}" : $"{value}{sumOfNonStartingModifiers:0.#}%");
return " <alpha=#99>(" + text + ")";
}
catch
{
return "";
}
}
private static List<CatalogRow> Catalog()
{
//IL_00b7: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
if (_catalog != null && _catalog.Count > 0 && (Object)(object)_catalog[0].Entry != (Object)null && !((Il2CppObjectBase)_catalog[0].Entry).WasCollected)
{
return _catalog;
}
if (_catalog != null && Time.unscaledTime < _nextCatalogTry)
{
return _catalog;
}
_nextCatalogTry = Time.unscaledTime + 5f;
_catalog = new List<CatalogRow>();
foreach (SpellStatDetailsPanel item in Resources.FindObjectsOfTypeAll<SpellStatDetailsPanel>())
{
List<BaseSpellStatEntry> val = ((item != null) ? item.baseSpellStatEntries : null);
if (val == null || val.Count == 0)
{
continue;
}
Scene scene = ((Component)item).gameObject.scene;
if (!((Scene)(ref scene)).IsValid())
{
continue;
}
for (int i = 0; i < val.Count; i++)
{
BaseSpellStatEntry val2 = val[i];
if ((Object)(object)val2 == (Object)null)
{
continue;
}
CatalogRow catalogRow = new CatalogRow
{
Type = val2.GetStatType(),
Entry = val2
};
foreach (Image componentsInChild in ((Component)val2).GetComponentsInChildren<Image>(true))
{
if (!((Object)(object)componentsInChild.sprite == (Object)null))
{
if ((Object)(object)catalogRow.Icon == (Object)null || ((Object)componentsInChild.sprite).name.Contains("icon"))
{
catalogRow.Icon = componentsInChild.sprite;
}
if (((Object)componentsInChild.sprite).name.Contains("icon"))
{
break;
}
}
}
foreach (TMP_Text componentsInChild2 in ((Component)val2).GetComponentsInChildren<TMP_Text>(true))
{
if (((Object)(object)val2.statValue == (Object)null || ((Il2CppObjectBase)componentsInChild2).Pointer != ((Il2CppObjectBase)val2.statValue).Pointer) && !string.IsNullOrWhiteSpace(componentsInChild2.text))
{
catalogRow.Title = componentsInChild2.text;
break;
}
}
CatalogRow catalogRow2 = catalogRow;
if (catalogRow2.Title == null)
{
catalogRow2.Title = ((object)Unsafe.As<StatType, StatType>(ref catalogRow.Type)/*cast due to .constrained prefix*/).ToString();
}
_catalog.Add(catalogRow);
}
if (_catalog.Count > 0)
{
BetterStatsMenuMod.Log.Msg("spell stat rows from the pause menu: " + string.Join(", ", _catalog.ConvertAll(delegate(CatalogRow r)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(3, 3);
defaultInterpolatedStringHandler.AppendFormatted<StatType>(r.Type);
defaultInterpolatedStringHandler.AppendLiteral("=");
defaultInterpolatedStringHandler.AppendFormatted(r.Title);
defaultInterpolatedStringHandler.AppendLiteral("(");
Sprite icon = r.Icon;
defaultInterpolatedStringHandler.AppendFormatted((icon != null) ? ((Object)icon).name : null);
defaultInterpolatedStringHandler.AppendLiteral(")");
return defaultInterpolatedStringHandler.ToStringAndClear();
})));
break;
}
}
return _catalog;
}
private static int CountLines(SpellStatsEntry entry)
{
int num = 0;
while ((Object)(object)((Component)entry).transform.Find($"BSM_Stat_{num}") != (Object)null)
{
num++;
}
return num;
}
private static RectTransform MakeLine(Transform entry, RectTransform template, int index)
{
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: 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_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: 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_0101: 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)
GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, entry, false);
((Object)val).name = $"BSM_Stat_{index}";
foreach (LocalizeStringEvent componentsInChild in val.GetComponentsInChildren<LocalizeStringEvent>(true))
{
Object.DestroyImmediate((Object)(object)componentsInChild);
}
foreach (TMP_Text componentsInChild2 in val.GetComponentsInChildren<TMP_Text>(true))
{
componentsInChild2.fontSize = 36f;
if (((Object)componentsInChild2).name == "Value_Text")
{
componentsInChild2.fontStyle = (FontStyles)(componentsInChild2.fontStyle & -49);
}
if (((Object)componentsInChild2).name == "Title")
{
componentsInChild2.rectTransform.sizeDelta = new Vector2(420f, componentsInChild2.rectTransform.sizeDelta.y);
RectTransform rectTransform = componentsInChild2.rectTransform;
rectTransform.anchoredPosition += new Vector2(46f, 0f);
}
}
RectTransform obj = new GameObject("BSM_Icon").AddComponent<RectTransform>();
((Transform)obj).SetParent(val.transform, false);
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0f, 0.5f);
obj.anchorMax = val2;
obj.anchorMin = val2;
obj.pivot = new Vector2(0f, 0.5f);
obj.sizeDelta = new Vector2(36f, 36f);
obj.anchoredPosition = Vector2.zero;
Image obj2 = ((Component)obj).gameObject.AddComponent<Image>();
obj2.preserveAspect = true;
((Graphic)obj2).raycastTarget = false;
((Behaviour)obj2).enabled = false;
return val.GetComponent<RectTransform>();
}
private static CachedStat FindStat(CachedSpellStat spell, StatType type)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
IReadOnlyList<CachedStat> val = ((spell != null) ? spell.Stats : null);
if (val == null)
{
return null;
}
int count = ((Il2CppObjectBase)val).Cast<IReadOnlyCollection<CachedStat>>().Count;
for (int i = 0; i < count; i++)
{
if (val[i] != null && val[i].StatType == type)
{
return val[i];
}
}
return null;
}
private static string FormatValue(StatType type, float v)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Invalid comparison between Unknown and I4
//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_000b: Invalid comparison between Unknown and I4
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
if ((int)type <= 5)
{
if ((int)type == 0)
{
return v.ToString("#,0", CultureInfo.InvariantCulture);
}
if (type - 4 <= 1)
{
return $"{v:0.##}s";
}
}
else
{
if ((int)type == 12)
{
return $"{v * ((v <= 1.5f) ? 100f : 1f):0}%";
}
if ((int)type == 13)
{
return $"{v * ((v <= 10f) ? 100f : 1f):0}%";
}
if ((int)type == 20)
{
return Mathf.RoundToInt(v).ToString(CultureInfo.InvariantCulture);
}
}
return v.ToString("0.##", CultureInfo.InvariantCulture);
}
private static string FormatBonus(StatType type, float sum)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
if (Mathf.Abs(sum) < 0.0001f)
{
return "";
}
string text = (((int)type == 20) ? $"{((sum > 0f) ? "+" : "")}{Mathf.RoundToInt(sum)}" : $"{((sum > 0f) ? "+" : "")}{sum * 100f:0}%");
return " <alpha=#99>(" + text + ")";
}
private static void UpdateRelicPages()
{
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
if (!BetterStatsMenuMod.ScrollsPage.Value)
{
HideRelicRowsFrom(0);
EnsurePageCount(RelicPages, 0, (StatPanelType)2, "BSM_Relics");
SyncNavigator();
return;
}
List<CachedArtifactStat> list = LocalRelics();
Transform val = LastActiveRow(((Component)_playerPanel).transform);
if ((Object)(object)val == (Object)null)
{
return;
}
List<(RectTransform, float)> list2 = new List<(RectTransform, float)>();
if (list.Count == 0)
{
list2.Add(RelicRow(0, val, null, "No scrolls yet", "Scrolls you pick up during the mission show here."));
}
else
{
for (int i = 0; i < list.Count; i++)
{
CachedArtifactStat val2 = list[i];
int index = i;
object obj = val2.DisplayIcon;
if (obj == null)
{
ArtifactData artifactData = val2.artifactData;
obj = ((artifactData != null) ? artifactData.Icon : null);
}
list2.Add(RelicRow(index, val, (Sprite)obj, Localize(val2.ArtifactName), Describe(val2)));
}
}
HideRelicRowsFrom(list2.Count);
List<List<(RectTransform, float)>> list3 = new List<List<(RectTransform, float)>>();
List<(RectTransform, float)> list4 = new List<(RectTransform, float)>();
float num = 0f;
foreach (var item in list2)
{
float num2 = ((list4.Count > 0) ? 24f : 0f) + item.Item2;
if (list4.Count > 0 && num + num2 > 1270f)
{
list3.Add(list4);
list4 = new List<(RectTransform, float)>();
num = 0f;
num2 = item.Item2;
}
list4.Add(item);
num += num2;
}
if (list4.Count > 0)
{
list3.Add(list4);
}
EnsurePageCount(RelicPages, list3.Count, (StatPanelType)2, "BSM_Relics");
for (int j = 0; j < list3.Count; j++)
{
float num3 = 0f;
foreach (var (val3, num4) in list3[j])
{
if (((Il2CppObjectBase)((Transform)val3).parent).Pointer != ((Il2CppObjectBase)((Component)RelicPages[j]).transform).Pointer)
{
((Transform)val3).SetParent(((Component)RelicPages[j]).transform, false);
}
Vector2 anchorMin = (val3.anchorMax = new Vector2(0f, 1f));
val3.anchorMin = anchorMin;
val3.pivot = new Vector2(0f, 1f);
val3.anchoredPosition = new Vector2(0f, 0f - num3);
num3 += num4 + 24f;
}
}
SyncNavigator();
}
private static (RectTransform, float) RelicRow(int index, Transform template, Sprite icon, string name, string description)
{
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
while (RelicRows.Count <= index)
{
RelicRows.Add(null);
}
RectTransform val = RelicRows[index];
if ((Object)(object)val == (Object)null || ((Il2CppObjectBase)val).WasCollected)
{
GameObject val2 = Object.Instantiate<GameObject>(((Component)template).gameObject, Holder(), false);
((Object)val2).name = $"BSM_Relic_{index}";
foreach (PlayerStatEntry component2 in val2.GetComponents<PlayerStatEntry>())
{
Object.DestroyImmediate((Object)(object)component2);
}
foreach (LocalizeStringEvent componentsInChild in val2.GetComponentsInChildren<LocalizeStringEvent>(true))
{
Object.DestroyImmediate((Object)(object)componentsInChild);
}
val2.SetActive(false);
val = val2.GetComponent<RectTransform>();
TMP_Text val3 = FindText((Transform)(object)val, "Value_Text");
if ((Object)(object)val3 != (Object)null)
{
((Component)val3).gameObject.SetActive(false);
}
TMP_Text val4 = FindText((Transform)(object)val, "Stat_Text");
if ((Object)(object)val4 != (Object)null)
{
TMP_Text component = Object.Instantiate<GameObject>(((Component)val4).gameObject, (Transform)(object)val, false).GetComponent<TMP_Text>();
((Object)component).name = "BSM_Description";
component.fontSize = val4.fontSize * 0.78f;
component.fontStyle = (FontStyles)0;
((Graphic)component).color = new Color(0.8f, 0.8f, 0.8f, 1f);
component.textWrappingMode = (TextWrappingModes)1;
component.alignment = (TextAlignmentOptions)257;
RectTransform rectTransform = component.rectTransform;
rectTransform.anchorMin = new Vector2(0f, 1f);
rectTransform.anchorMax = new Vector2(1f, 1f);
rectTransform.pivot = new Vector2(0f, 1f);
rectTransform.anchoredPosition = new Vector2(val4.rectTransform.anchoredPosition.x, 0f - val.sizeDelta.y);
rectTransform.sizeDelta = new Vector2(0f - val4.rectTransform.anchoredPosition.x - 10f, 200f);
}
RelicRows[index] = val;
}
((Component)val).gameObject.SetActive(true);
TMP_Text val5 = FindText((Transform)(object)val, "Stat_Text");
if ((Object)(object)val5 != (Object)null)
{
val5.text = name;
}
Transform obj = ((Transform)val).Find("Image");
Image val6 = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
if ((Object)(object)val6 != (Object)null)
{
val6.sprite = icon;
((Behaviour)val6).enabled = (Object)(object)icon != (Object)null;
val6.preserveAspect = true;
((Graphic)val6).rectTransform.sizeDelta = new Vector2(80f, 80f);
}
TMP_Text val7 = FindText((Transform)(object)val, "BSM_Description");
float num = 0f;
if ((Object)(object)val7 != (Object)null)
{
val7.text = description ?? "";
Rect rect = val.rect;
float num2 = Mathf.Max(200f, ((Rect)(ref rect)).width - val7.rectTransform.anchoredPosition.x - 10f);
num = val7.GetPreferredValues(val7.text, num2, 0f).y;
val7.rectTransform.sizeDelta = new Vector2(val7.rectTransform.sizeDelta.x, num + 4f);
}
return (val, val.sizeDelta.y + num);
}
private static void HideRelicRowsFrom(int count)
{
for (int i = count; i < RelicRows.Count; i++)
{
if ((Object)(object)RelicRows[i] != (Object)null && !((Il2CppObjectBase)RelicRows[i]).WasCollected)
{
((Component)RelicRows[i]).gameObject.SetActive(false);
}
}
}
private static List<CachedArtifactStat> LocalRelics()
{
List<CachedArtifactStat> list = new List<CachedArtifactStat>();
foreach (GameplayPlayerIdentity item in Object.FindObjectsOfType<GameplayPlayerIdentity>())
{
if ((Object)(object)item == (Object)null || !((NetworkBehaviour)item).IsOwner)
{
continue;
}
IPlayerArtifacts artifacts = item.Artifacts;
List<CachedArtifactStat> val = ((artifacts != null) ? artifacts.CreateCachedArtifactStats() : null);
int num = 0;
while (val != null && num < val.Count)
{
if (val[num] != (CachedArtifactStat)null)
{
list.Add(val[num]);
}
num++;
}
break;
}
return list;
}
private static string RawEntry(string key)
{
try
{
StringTable table = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("Localization_Strings"), (Locale)null);
object result;
if (table == null)
{
result = null;
}
else
{
StringTableEntry entry = ((DetailedLocalizationTable<StringTableEntry>)(object)table).GetEntry(key);
result = ((entry != null) ? entry.Value : null);
}
return (string)result;
}
catch
{
return null;
}
}
private static string Localize(string key)
{
if (string.IsNullOrEmpty(key))
{
return "";
}
try
{
return LocalizationSettings.StringDatabase.GetLocalizedString(TableReference.op_Implicit("Localization_Strings"), TableEntryReference.op_Implicit(key), (Locale)null, (FallbackBehavior)0, (Il2CppReferenceArray<Object>)null) ?? key;
}
catch
{
return key;
}
}
private static string Describe(CachedArtifactStat relic)
{
string text = RawEntry(relic.ArtifactDescription) ?? Localize(relic.ArtifactDescription);
try
{
IReadOnlyList<float> artifactParameters = relic.ArtifactParameters;
StringBuilder stringBuilder = new StringBuilder();
int num = 0;
foreach (Match item in Placeholder.Matches(text))
{
stringBuilder.Append(text, num, item.Index - num);
int num2 = item.Groups[1].Value[0] - 48;
string value;
try
{
value = ParameterFormatter.Format(artifactParameters, num2) ?? item.Value;
}
catch
{
value = item.Value;
}
stringBuilder.Append(value);
num = item.Index + item.Length;
}
stringBuilder.Append(text, num, text.Length - num);
text = stringBuilder.ToString();
}
catch
{
}
if (relic.Stacks > 0.001f)
{
text += $" <alpha=#99>(now: {relic.Stacks:0.#})";
}
return text;
}
private static Transform Holder()
{
//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_0030: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_holder != (Object)null && !((Il2CppObjectBase)_holder).WasCollected)
{
return _holder;
}
GameObject val = new GameObject("BSM_Holder");
val.SetActive(false);
((Transform)val.AddComponent<RectTransform>()).SetParent(((Component)_playerPanel).transform.parent, false);
_holder = val.transform;
return _holder;
}
private static void EnsurePageCount(List<StatPanel> pages, int count, StatPanelType type, string name)
{
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
while (pages.Count < count)
{
GameObject gameObject = ((Component)_playerPanel).gameObject;
bool activeSelf = gameObject.activeSelf;
if (activeSelf)
{
gameObject.SetActive(false);
}
GameObject val = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent, false);
if (activeSelf)
{
gameObject.SetActive(true);
}
((Object)val).name = $"{name}_{pages.Count + 2}";
for (int num = val.transform.childCount - 1; num >= 0; num--)
{
Object.DestroyImmediate((Object)(object)((Component)val.transform.GetChild(num)).gameObject);
}
foreach (HorizontalOrVerticalLayoutGroup component4 in val.GetComponents<HorizontalOrVerticalLayoutGroup>())
{
Object.DestroyImmediate((Object)(object)component4);
}
RectTransform component = val.GetComponent<RectTransform>();
RectTransform component2 = ((Component)_spellsPanel).GetComponent<RectTransform>();
component.anchoredPosition = component2.anchoredPosition;
((Transform)component).SetSiblingIndex(((Transform)component2).GetSiblingIndex() + 1);
StatPanel component3 = val.GetComponent<StatPanel>();
component3.statPanelType = type;
pages.Add(component3);
}
while (pages.Count > count)
{
StatPanel val2 = pages[pages.Count - 1];
pages.RemoveAt(pages.Count - 1);
if (!((Object)(object)val2 != (Object)null) || ((Il2CppObjectBase)val2).WasCollected)
{
continue;
}
for (int num2 = ((Component)val2).transform.childCount - 1; num2 >= 0; num2--)
{
Transform child = ((Component)val2).transform.GetChild(num2);
if ((Object)(object)((Component)child).GetComponent<SpellStatsEntry>() != (Object)null)
{
child.SetParent(((Component)_spellsPanel).transform, false);
}
else
{
child.SetParent(Holder(), false);
}
}
if ((Object)(object)_navigator.currentPanel != (Object)null && ((Il2CppObjectBase)_navigator.currentPanel).Pointer == ((Il2CppObjectBase)val2).Pointer)
{
_navigator.ShowPanel((StatPanel)(object)_spellsPanel);
}
Object.Destroy((Object)(object)((Component)val2).gameObject);
}
}
private static void SyncNavigator()
{
List<StatPanel> statPanels = _navigator.statPanels;
List<(int, int, List<StatPanel>)> list = new List<(int, int, List<StatPanel>)>();
for (int i = 0; i < statPanels.Count; i++)
{
StatPanel val = statPanels[i];
if (!((Object)(object)val == (Object)null) && !IsOurs(val))
{
if (((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)_playerPanel).Pointer)
{
list.Add((BetterStatsMenuMod.OrderYourStats.Value, 0, new List<StatPanel> { val }));
}
else if (((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)_spellsPanel).Pointer)
{
List<StatPanel> list2 = new List<StatPanel> { val };
list2.AddRange(SpellPages);
list.Add((BetterStatsMenuMod.OrderSpells.Value, 1, list2));
}
else
{
list.Add((100 + i, 10 + i, new List<StatPanel> { val }));
}
}
}
if (RelicPages.Count > 0)
{
list.Add((BetterStatsMenuMod.OrderScrolls.Value, 2, new List<StatPanel>(RelicPages)));
}
if (PartyPages.Count > 0)
{
list.Add((BetterStatsMenuMod.OrderParty.Value, 3, new List<StatPanel>(PartyPages)));
}
list.Sort(((int order, int tiebreak, List<StatPanel> pages) a, (int order, int tiebreak, List<StatPanel> pages) b) => (a.order == b.order) ? a.tiebreak.CompareTo(b.tiebreak) : a.order.CompareTo(b.order));
List<StatPanel> list3 = new List<StatPanel>();
foreach (var item in list)
{
list3.AddRange(item.Item3);
}
bool flag = list3.Count == statPanels.Count;
int num = 0;
while (flag && num < list3.Count)
{
flag = (Object)(object)statPanels[num] != (Object)null && ((Il2CppObjectBase)statPanels[num]).Pointer == ((Il2CppObjectBase)list3[num]).Pointer;
num++;
}
if (flag)
{
return;
}
statPanels.Clear();
foreach (StatPanel item2 in list3)
{
statPanels.Add(item2);
}
}
private static bool IsOurs(StatPanel p)
{
foreach (StatPanel spellPage in SpellPages)
{
if ((Object)(object)spellPage != (Object)null && ((Il2CppObjectBase)spellPage).Pointer == ((Il2CppObjectBase)p).Pointer)
{
return true;
}
}
foreach (StatPanel relicPage in RelicPages)
{
if ((Object)(object)relicPage != (Object)null && ((Il2CppObjectBase)relicPage).Pointer == ((Il2CppObjectBase)p).Pointer)
{
return true;
}
}
foreach (StatPanel partyPage in PartyPages)
{
if ((Object)(object)partyPage != (Object)null && ((Il2CppObjectBase)partyPage).Pointer == ((Il2CppObjectBase)p).Pointer)
{
return true;
}
}
return false;
}
private static void UpdateTitle()
{
LocalizeStringEvent panelTitleLocalizer = _navigator.panelTitleLocalizer;
TMP_Text val = ((panelTitleLocalizer != null) ? ((Component)panelTitleLocalizer).GetComponent<TMP_Text>() : null);
if ((Object)(object)val == (Object)null)
{
return;
}
StatPanel currentPanel = _navigator.currentPanel;
int num = -1;
int num2 = -1;
int num3 = 0;
while ((Object)(object)currentPanel != (Object)null && num3 < RelicPages.Count)
{
if ((Object)(object)RelicPages[num3] != (Object)null && ((Il2CppObjectBase)RelicPages[num3]).Pointer == ((Il2CppObjectBase)currentPanel).Pointer)
{
num = num3;
}
num3++;
}
if ((Object)(object)currentPanel != (Object)null && ((Il2CppObjectBase)currentPanel).Pointer == ((Il2CppObjectBase)_spellsPanel).Pointer)
{
num2 = 0;
}
int num4 = 0;
while ((Object)(object)currentPanel != (Object)null && num4 < SpellPages.Count)
{
if ((Object)(object)SpellPages[num4] != (Object)null && ((Il2CppObjectBase)SpellPages[num4]).Pointer == ((Il2CppObjectBase)currentPanel).Pointer)
{
num2 = num4 + 1;
}
num4++;
}
int num5 = SpellPages.Count + 1;
if (num >= 0)
{
((Behaviour)panelTitleLocalizer).enabled = false;
val.text = ((RelicPages.Count > 1) ? $"Scrolls {num + 1}/{RelicPages.Count}" : "Scrolls");
_titleOverridden = true;
}
else if ((Object)(object)currentPanel != (Object)null && PartyPages.Count > 0 && (Object)(object)PartyPages[0] != (Object)null && ((Il2CppObjectBase)PartyPages[0]).Pointer == ((Il2CppObjectBase)currentPanel).Pointer)
{
((Behaviour)panelTitleLocalizer).enabled = false;
val.text = "Party Stats";
_titleOverridden = true;
}
else if (num2 >= 0 && num5 > 1)
{
((Behaviour)panelTitleLocalizer).enabled = false;
val.text = $"Spell Stats {num2 + 1}/{num5}";
_titleOverridden = true;
}
else if (_titleOverridden)
{
_titleOverridden = false;
((Behaviour)panelTitleLocalizer).enabled = true;
panelTitleLocalizer.RefreshString();
}
}
private static TMP_Text FindText(Transform root, string name)
{
foreach (TMP_Text componentsInChild in ((Component)root).GetComponentsInChildren<TMP_Text>(true))
{
if (((Object)componentsInChild).name == name)
{
return componentsInChild;
}
}
return null;
}
private static void UpdatePartyPage()
{
//IL_047a: Unknown result type (might be due to invalid IL or missing references)
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
//IL_039a: Unknown result type (might be due to invalid IL or missing references)
//IL_039e: 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_03ac: Unknown result type (might be due to invalid IL or missing references)
//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
//IL_0438: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: 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_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0667: Unknown result type (might be due to invalid IL or missing references)
List<GameplayPlayerIdentity> list = PartyPlayers();
bool flag = BetterStatsMenuMod.PartyPage.Value && list.Count > 1;
EnsurePageCount(PartyPages, flag ? 1 : 0, (StatPanelType)2, "BSM_Party");
SyncNavigator();
if (!flag)
{
_partyColumns = -1;
return;
}
StatPanel val = PartyPages[0];
Transform val2 = LastActiveRow(((Component)_playerPanel).transform);
if ((Object)(object)val2 == (Object)null)
{
return;
}
List<(StatType?, Sprite, string)> list2 = new List<(StatType?, Sprite, string)>();
list2.Add((null, FindDamageIcon(), "DPS"));
for (int i = 0; i < ((Component)_playerPanel).transform.childCount; i++)
{
Transform child = ((Component)_playerPanel).transform.GetChild(i);
PlayerStatEntry component = ((Component)child).GetComponent<PlayerStatEntry>();
if (!((Object)(object)component == (Object)null) && ((Component)child).gameObject.activeSelf)
{
StatType? item = component.GetStat();
Image statIcon = component.statIcon;
Sprite item2 = ((statIcon != null) ? statIcon.sprite : null);
TMP_Text obj = FindText(child, "Stat_Text");
list2.Add((item, item2, ((obj != null) ? obj.text : null) ?? ((object)component.GetStat()/*cast due to .constrained prefix*/).ToString()));
}
}
if (PartyRows.Count == 0 || (Object)(object)PartyRows[0] == (Object)null || ((Il2CppObjectBase)PartyRows[0]).WasCollected || (Object)(object)((Transform)PartyRows[0]).parent == (Object)null || ((Il2CppObjectBase)((Transform)PartyRows[0]).parent).Pointer != ((Il2CppObjectBase)((Component)val).transform).Pointer || _partyColumns != list.Count || PartyRows.Count != list2.Count + 1)
{
foreach (RectTransform partyRow in PartyRows)
{
if ((Object)(object)partyRow != (Object)null && !((Il2CppObjectBase)partyRow).WasCollected)
{
Object.Destroy((Object)(object)((Component)partyRow).gameObject);
}
}
PartyRows.Clear();
_partyColumns = list.Count;
for (int j = 0; j <= list2.Count; j++)
{
PartyRows.Add(MakePartyRow(((Component)val).transform, val2, list.Count, j));
}
}
Mathf.Min(200f, 610f / (float)list.Count);
RectTransform val3 = PartyRows[0];
for (int k = 0; k < list.Count; k++)
{
TMP_Text val4 = FindText((Transform)(object)val3, $"BSM_Col_{k}");
if ((Object)(object)val4 == (Object)null)
{
continue;
}
val4.text = list[k].GetDisplayName();
Transform obj2 = ((Transform)val3).Find($"BSM_Portrait_{k}");
Image val5 = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null);
if ((Object)(object)val5 != (Object)null)
{
Sprite val6 = null;
try
{
CharacterSkinResource skinResource = list[k].SkinResource;
object obj3 = ((skinResource != null) ? skinResource.GameplayPortrait : null);
if (obj3 == null)
{
CharacterResource character = list[k].Character;
obj3 = ((character != null) ? character.miniIcon : null);
}
val6 = (Sprite)obj3;
}
catch
{
}
val5.sprite = val6;
((Behaviour)val5).enabled = (Object)(object)val6 != (Object)null;
}
Color playerColor = list[k].PlayerColor;
((Graphic)val4).color = new Color(playerColor.r, playerColor.g, playerColor.b, 1f);
}
List<Dictionary<StatType, string>> list3 = new List<Dictionary<StatType, string>>();
List<float> list4 = new List<float>();
foreach (GameplayPlayerIdentity item3 in list)
{
Dictionary<StatType, string> dictionary = new Dictionary<StatType, string>();
float num = 0f;
try
{
IPlayerStats stats = item3.Stats;
List<Stat> val7 = ((stats != null) ? stats.GetPlayerStats() : null);
int num2 = 0;
while (val7 != null && num2 < val7.Count)
{
Stat val8 = val7[num2];
if (val8 != null)
{
try
{
StatType statType = val8.StatType;
CachedStat obj5 = val8.ToCachedStat();
dictionary[statType] = ((obj5 != null) ? obj5.DisplayText : null) ?? val8.GetDisplayValue().ToString("0.#", CultureInfo.InvariantCulture);
}
catch
{
dictionary[val8.StatType] = val8.GetDisplayValue().ToString("0.#", CultureInfo.InvariantCulture);
}
}
num2++;
}
foreach (CachedSpellStat value2 in SpellStatsBySpell(item3.Stats).Values)
{
num += value2.Dps;
}
}
catch
{
}
list3.Add(dictionary);
list4.Add(num);
}
for (int l = 0; l < list2.Count; l++)
{
RectTransform val9 = PartyRows[l + 1];
TMP_Text val10 = FindText((Transform)(object)val9, "Stat_Text");
if ((Object)(object)val10 != (Object)null)
{
val10.text = list2[l].Item3;
}
Transform obj8 = ((Transform)val9).Find("Image");
Image val11 = ((obj8 != null) ? ((Component)obj8).GetComponent<Image>() : null);
if ((Object)(object)val11 != (Object)null)
{
val11.sprite = list2[l].Item2;
((Behaviour)val11).enabled = (Object)(object)list2[l].Item2 != (Object)null;
}
for (int m = 0; m < list.Count; m++)
{
TMP_Text val12 = FindText((Transform)(object)val9, $"BSM_Col_{m}");
if (!((Object)(object)val12 == (Object)null))
{
if (!list2[l].Item1.HasValue)
{
val12.text = list4[m].ToString("#,0", CultureInfo.InvariantCulture);
}
else
{
val12.text = (list3[m].TryGetValue(list2[l].Item1.Value, out var value) ? value : "–");
}
}
}
}
}
private static List<GameplayPlayerIdentity> PartyPlayers()
{
List<GameplayPlayerIdentity> list = new List<GameplayPlayerIdentity>();
foreach (GameplayPlayerIdentity item in Object.FindObjectsOfType<GameplayPlayerIdentity>())
{
if ((Object)(object)item != (Object)null && item.Stats != null)
{
list.Add(item);
}
}
list.Sort((GameplayPlayerIdentity a, GameplayPlayerIdentity b) => (((NetworkBehaviour)a).IsOwner != ((NetworkBehaviour)b).IsOwner) ? ((!((NetworkBehaviour)a).IsOwner) ? 1 : (-1)) : ((NetworkBehaviour)a).OwnerClientId.CompareTo(((NetworkBehaviour)b).OwnerClientId));
return list;
}
private static RectTransform MakePartyRow(Transform page, Transform template, int players, int index)
{
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_0106: 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_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: 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_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Unknown result type (might be due to invalid IL or missing references)
//IL_0387: 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_03e1: Unknown result type (might be due to invalid IL or missing references)
//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
//IL_040f: 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)
GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, page, false);
((Object)val).name = ((index == 0) ? "BSM_PartyHeader" : $"BSM_PartyRow_{index}");
foreach (PlayerStatEntry component3 in val.GetComponents<PlayerStatEntry>())
{
Object.DestroyImmediate((Object)(object)component3);
}
foreach (LocalizeStringEvent componentsInChild in val.GetComponentsInChildren<LocalizeStringEvent>(true))
{
Object.DestroyImmediate((Object)(object)componentsInChild);
}
RectTransform component = val.GetComponent<RectTransform>();
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0f, 1f);
component.anchorMax = val2;
component.anchorMin = val2;
component.pivot = new Vector2(0f, 1f);
component.anchoredPosition = new Vector2(0f, (index == 0) ? 0f : (0f - (170f + (float)(index - 1) * 72f)));
if (index == 0)
{
component.sizeDelta = new Vector2(component.sizeDelta.x, 170f);
}
TMP_Text val3 = FindText(val.transform, "Stat_Text");
if ((Object)(object)val3 != (Object)null)
{
val3.rectTransform.anchorMax = val3.rectTransform.anchorMin;
val3.rectTransform.sizeDelta = new Vector2(330f, val3.rectTransform.sizeDelta.y);
val3.overflowMode = (TextOverflowModes)1;
val3.textWrappingMode = (TextWrappingModes)0;
if (index == 0)
{
val3.text = "";
}
}
if (index == 0)
{
Transform obj = val.transform.Find("Image");
if (obj != null)
{
((Component)obj).gameObject.SetActive(false);
}
}
float num = Mathf.Min(200f, 610f / (float)players);
TMP_Text val4 = FindText(val.transform, "Value_Text");
if ((Object)(object)val4 != (Object)null)
{
for (int i = 0; i < players; i++)
{
TMP_Text component2 = Object.Instantiate<GameObject>(((Component)val4).gameObject, val.transform, false).GetComponent<TMP_Text>();
((Object)component2).name = $"BSM_Col_{i}";
RectTransform rectTransform = component2.rectTransform;
rectTransform.sizeDelta = new Vector2(num - 8f, rectTransform.sizeDelta.y);
rectTransform.anchoredPosition = new Vector2((float)(-(players - 1 - i)) * num, rectTransform.anchoredPosition.y);
component2.overflowMode = (TextOverflowModes)1;
component2.textWrappingMode = (TextWrappingModes)0;
component2.enableAutoSizing = true;
component2.fontSizeMax = val4.fontSize;
component2.fontSizeMin = val4.fontSize * 0.6f;
component2.alignment = (TextAlignmentOptions)514;
if (index == 0)
{
component2.fontStyle = (FontStyles)(component2.fontStyle & -17);
component2.textWrappingMode = (TextWrappingModes)1;
component2.alignment = (TextAlignmentOptions)1026;
component2.fontSizeMax = val4.fontSize * 0.8f;
component2.fontSizeMin = val4.fontSize * 0.45f;
((Vector2)(ref val2))..ctor(1f, 0f);
rectTransform.anchorMax = val2;
rectTransform.anchorMin = val2;
rectTransform.pivot = new Vector2(1f, 0f);
rectTransform.sizeDelta = new Vector2(num - 8f, 90f);
rectTransform.anchoredPosition = new Vector2((float)(-(players - 1 - i)) * num, 0f);
RectTransform obj2 = new GameObject($"BSM_Portrait_{i}").AddComponent<RectTransform>();
((Transform)obj2).SetParent(val.transform, false);
((Vector2)(ref val2))..ctor(1f, 1f);
obj2.anchorMax = val2;
obj2.anchorMin = val2;
obj2.pivot = new Vector2(0.5f, 1f);
obj2.sizeDelta = new Vector2(72f, 72f);
obj2.anchoredPosition = new Vector2((float)(-(players - 1 - i)) * num - (num - 8f) / 2f, -4f);
Image obj3 = ((Component)obj2).gameObject.AddComponent<Image>();
obj3.preserveAspect = true;
((Graphic)obj3).raycastTarget = false;
((Behaviour)obj3).enabled = false;
}
}
((Component)val4).gameObject.SetActive(false);
}
val.SetActive(true);
return component;
}
}
internal static class SoftCapsFeature
{
private static readonly Color CapRed = new Color(1f, 0.42f, 0.38f);
private static readonly Regex Number = new Regex("[-+]?\\d+(?:[.,]\\d+)?", RegexOptions.Compiled);
private static readonly Dictionary<StatType, int> Caps = new Dictionary<StatType, int>
{
[(StatType)9] = 25,
[(StatType)12] = 80,
[(StatType)15] = 75,
[(StatType)10] = 200
};
private static readonly Dictionary<IntPtr, Color> OriginalColors = new Dictionary<IntPtr, Color>();
internal static void Install(Harmony harmony)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Expected O, but got Unknown
try
{
MethodInfo methodInfo = AccessTools.Method(typeof(PlayerStatEntry), "Set", new Type[3]
{
typeof(StatType),
typeof(string),
typeof(Sprite)
}, (Type[])null) ?? throw new MissingMethodException("PlayerStatEntry.Set(StatType, string, Sprite) not found");
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(SoftCapsFeature), "SetPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
catch (Exception ex)
{
BetterStatsMenuMod.Log.Error("soft caps unavailable: " + ex.Message);
}
}
private static void SetPostfix(PlayerStatEntry __instance, StatType statType, string displayText)
{
//IL_0045: 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_003d: 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)
//IL_005c: 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_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
try
{
TMP_Text val = ((__instance != null) ? __instance.valueText : null);
if ((Object)(object)val == (Object)null)
{
return;
}
IntPtr pointer = ((Il2CppObjectBase)val).Pointer;
if (!OriginalColors.TryGetValue(pointer, out var value))
{
value = (OriginalColors[pointer] = ((Graphic)val).color);
}
((Graphic)val).color = value;
if (!BetterStatsMenuMod.SoftCaps.Value || !Caps.TryGetValue(statType, out var value2))
{
return;
}
Match match = Number.Match(displayText ?? "");
if (match.Success && float.TryParse(match.Value.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
{
string value3 = (displayText.Contains('%') ? "%" : "");
val.text = $"{displayText}<alpha=#99>/{value2}{value3}";
if (result >= (float)value2 - 0.001f)
{
((Graphic)val).color = Color.Lerp(value, CapRed, BetterStatsMenuMod.RedTint.Value);
}
}
}
catch (Exception ex)
{
BetterStatsMenuMod.Log.Warning("stat entry: " + ex.Message);
}
}
}
}
namespace BetterStatsMenu.BepInExPlugin
{
[BepInPlugin("SpellBrigade.BetterStatsMenu", "Better Stats Menu", "2.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
public const string Guid = "SpellBrigade.BetterStatsMenu";
public override void Load()
{
MelonCompat.Start<BetterStatsMenuMod, Runner>((BasePlugin)(object)this, "SpellBrigade.BetterStatsMenu");
}
}
public class Runner : MonoBehaviour
{
public Runner(IntPtr ptr)
: base(ptr)
{
}
private void Update()
{
MelonCompat.Update();
}
}
}
namespace MelonLoader
{
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class MelonInfoAttribute : Attribute
{
public MelonInfoAttribute(Type type, string name, string version, string author, string downloadLink = null)
{
}
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class MelonGameAttribute : Attribute
{
public MelonGameAttribute(string developer = null, string name = null)
{
}
}
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class MelonOptionalDependenciesAttribute : Attribute
{
public MelonOptionalDependenciesAttribute(params string[] names)
{
}
}
public abstract class MelonBase
{
public MelonLogger.Instance LoggerInstance { get; internal set; }
public Harmony HarmonyInstance { get; internal set; }
public static object FindMelon(string name, string author)
{
try
{
foreach (PluginInfo value in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values)
{
if (((value != null) ? value.Metadata : null) != null && string.Equals(value.Metadata.Name, name, StringComparison.OrdinalIgnoreCase) && value.Instance != null)
{
return value;
}
}
}
catch
{
}
return null;
}
}
public abstract class MelonMod : MelonBase
{
public virtual void OnInitializeMelon()
{
}
public virtual void OnLateInitializeMelon()
{
}
public virtual void OnUpdate()
{
}
public virtual void OnLateUpdate()
{
}
public virtual void OnFixedUpdate()
{
}
public virtual void OnGUI()
{
}
public virtual void OnApplicationQuit()
{
}
public virtual void OnSceneWasLoaded(int buildIndex, string sceneName)
{
}
public virtual void OnSceneWasInitialized(int buildIndex, string sceneName)
{
}
public virtual void OnSceneWasUnloaded(int buildIndex, string sceneName)
{
}
}
public static class MelonLogger
{
public sealed class Instance
{
private readonly ManualLogSource _log;
public Instance(ManualLogSource log)
{
_log = log;
}
public void Msg(string text)
{
_log.LogInfo((object)text);
}
public void Msg(object value)
{
_log.LogInfo(value);
}
public void Msg(string format, params object[] args)
{
_log.LogInfo((object)string.Format(format, args));
}
public void Warning(string text)
{
_log.LogWarning((object)text);
}
public void Warning(object value)
{
_log.LogWarning(value);
}
public void Error(string text)
{
_log.LogError((object)text);
}
public void Error(object value)
{
_log.LogError(value);
}
public void Error(string text, Exception e)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
ManualLogSource log = _log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(1, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(e);
}
log.LogError(val);
}
}
}
public static class MelonCompat
{
internal static ConfigFile Config;
private static MelonMod _mod;
private static bool _lateInit;
public static void Start<TMod, TRunner>(BasePlugin plugin, string harmonyId) where TMod : MelonMod, new() where TRunner : MonoBehaviour
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
Config = plugin.Config;
_mod = new TMod
{
LoggerInstance = new MelonLogger.Instance(plugin.Log),
HarmonyInstance = new Harmony(harmonyId)
};
try
{
_mod.HarmonyInstance.PatchAll(typeof(TMod).Assembly);
}
catch (Exception ex)
{
ManualLogSource log = plugin.Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(17, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Harmony patches: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
log.LogError(val);
}
_mod.OnInitializeMelon();
HookScenes();
ClassInjector.RegisterTypeInIl2Cpp<TRunner>();
plugin.AddComponent<TRunner>();
}
private static void HookScenes()
{
SceneManager.sceneLoaded += DelegateSupport.ConvertDelegate<UnityAction<Scene, LoadSceneMode>>((Delegate)new Action<Scene, LoadSceneMode>(OnSceneLoaded));
SceneManager.sceneUnloaded += DelegateSupport.ConvertDelegate<UnityAction<Scene>>((Delegate)new Action<Scene>(OnSceneUnloaded));
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_0006: 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)
Guard(delegate
{
_mod.OnSceneWasLoaded(((Scene)(ref scene)).buildIndex, ((Scene)(ref scene)).name);
});
Guard(delegate
{
_mod.OnSceneWasInitialized(((Scene)(ref scene)).buildIndex, ((Scene)(ref scene)).name);
});
}
private static void OnSceneUnloaded(Scene scene)
{
//IL_0006: 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)
Guard(delegate
{
_mod.OnSceneWasUnloaded(((Scene)(ref scene)).buildIndex, ((Scene)(ref scene)).name);
});
}
public static void Update()
{
if (_mod != null)
{
if (!_lateInit)
{
_lateInit = true;
Guard(_mod.OnLateInitializeMelon);
}
_mod.OnUpdate();
}
}
public static void LateUpdate()
{
_mod?.OnLateUpdate();
}
public static void FixedUpdate()
{
_mod?.OnFixedUpdate();
}
public static void OnGUI()
{
_mod?.OnGUI();
}
public static void Quit()
{
_mod?.OnApplicationQuit();
}
private static void Guard(Action a)
{
try
{
a();
}
catch (Exception ex)
{
_mod.LoggerInstance.Error(ex.ToString());
}
}
}
public static class MelonPreferences
{
private static readonly Dictionary<string, MelonPreferences_Category> Categories = new Dictionary<string, MelonPreferences_Category>();
public static MelonPreferences_Category CreateCategory(string identifier, string displayName = null, bool is_hidden = false, bool is_inlined = false)
{
if (!Categories.TryGetValue(identifier, out var value))
{
value = (Categories[identifier] = new MelonPreferences_Category(identifier, displayName ?? identifier)
{
IsHidden = is_hidden
});
}
return value;
}
public static MelonPreferences_Category GetCategory(string identifier)
{
if (!Categories.TryGetValue(identifier, out var value))
{
return null;
}
return value;
}
public static void Save()
{
ConfigFile config = MelonCompat.Config;
if (config != null)
{
config.Save();
}
}
}
public sealed class MelonPreferences_Category
{
public readonly List<MelonPreferences_Entry> Entries = new List<MelonPreferences_Entry>();
public string Identifier { get; }
public string DisplayName { get; }
public bool IsHidden { get; internal set; }
internal MelonPreferences_Category(string identifier, string displayName)
{
Identifier = identifier;
DisplayName = displayName;
}
public MelonPreferences_Entry<T> CreateEntry<T>(string identifier, T default_value, string display_name = null, string description = null, bool is_hidden = false, bool dont_save_default = false, ValueValidator validator = null, string oldIdentifier = null)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
{
DispName = (display_name ?? identifier),
Browsable = (!is_hidden && !IsHidden),
Order = -Entries.Count,
Category = DisplayName
};
AcceptableValueBase val = validator?.ToAcceptable(typeof(T));
ConfigEntry<T> cfg = MelonCompat.Config.Bind<T>(Identifier, identifier, default_value, new ConfigDescription(description ?? "", val, new object[1] { configurationManagerAttributes }));
MelonPreferences_Entry<T> melonPreferences_Entry = new MelonPreferences_Entry<T>(this, cfg, identifier, display_name ?? identifier, description, is_hidden);
Entries.Add(melonPreferences_Entry);
return melonPreferences_Entry;
}
public MelonPreferences_Entry GetEntry(string identifier)
{
return Entries.Find((MelonPreferences_Entry e) => e.Identifier == identifier);
}
public MelonPreferences_Entry<T> GetEntry<T>(string identifier)
{
return GetEntry(identifier) as MelonPreferences_Entry<T>;
}
public bool HasEntry(string identifier)
{
return GetEntry(identifier) != null;
}
public void SaveToFile(bool printmsg = true)
{
ConfigFile config = MelonCompat.Config;
if (config != null)
{
config.Save();
}
}
public void LoadFromFile(bool printmsg = true)
{
ConfigFile config = MelonCompat.Config;
if (config != null)
{
config.Reload();
}
}
}
public abstract class MelonPreferences_Entry
{
public readonly MelonEvent<object, object> OnEntryValueChangedUntyped = new MelonEvent<object, object>();
public MelonPreferences_Category Category { get; protected set; }
public string Identifier { get; protected set; }
public string DisplayName { get; protected set; }
public string Description { get; protected set; }
public bool IsHidden { get; protected set; }
public abstract ConfigEntryBase Raw { get; }
public abstract object BoxedValue { get; set; }
public abstract void ResetToDefault();
}
public sealed class MelonPreferences_Entry<T> : MelonPreferences_Entry
{
private readonly ConfigEntry<T> _cfg;
private T _last;
public readonly MelonEvent<T, T> OnEntryValueChanged = new MelonEvent<T, T>();
public readonly MelonEvent<T, T> OnValueChanged;
public T Value
{
get
{
return _cfg.Value;
}
set
{
_cfg.Value = value;
}
}
public T DefaultValue => (T)((ConfigEntryBase)_cfg).DefaultValue;
public override ConfigEntryBase Raw => (ConfigEntryBase)(object)_cfg;
public override object BoxedValue
{
get
{
return ((ConfigEntryBase)_cfg).BoxedValue;
}
set
{
((ConfigEntryBase)_cfg).BoxedValue = value;
}
}
internal MelonPreferences_Entry(MelonPreferences_Category category, ConfigEntry<T> cfg, string identifier, string displayName, string description, bool hidden)
{
base.Category = category;
_cfg = cfg;
base.Identifier = identifier;
base.DisplayName = displayName;
base.Description = description;
base.IsHidden = hidden;
OnValueChanged = OnEntryValueChanged;
_last = cfg.Value;
cfg.SettingChanged += OnSettingChanged;
}
private void OnSettingChanged(object sender, EventArgs e)
{
T last = _last;
_last = _cfg.Value;
if (!EqualityComparer<T>.Default.Equals(last, _last))
{
OnEntryValueChanged.Invoke(last, _last);
OnEntryValueChangedUntyped.Invoke(last, _last);
}
}
public override void ResetToDefault()
{
_cfg.Value = DefaultValue;
}
}
public sealed class MelonEvent<T1, T2>
{
private readonly List<Action<T1, T2>> _handlers = new List<Action<T1, T2>>();
public void Subscribe(Action<T1, T2> handler, int priority = 0, bool unsubscribeOnFirstInvocation = false)
{
_handlers.Add(handler);
}
public void Unsubscribe(Action<T1, T2> handler)
{
_handlers.Remove(handler);
}
internal void Invoke(T1 a, T2 b)
{
Action<T1, T2>[] array = _handlers.ToArray();
foreach (Action<T1, T2> action in array)
{
try
{
action(a, b);
}
catch (Exception ex)
{
Debug.LogError(Object.op_Implicit(ex.ToString()));
}
}
}
}
public sealed class ConfigurationManagerAttributes
{
public string DispName;
public bool? Browsable;
public int? Order;
public string Category;
}
}
namespace MelonLoader.Preferences
{
public abstract class ValueValidator
{
public abstract AcceptableValueBase ToAcceptable(Type type);
}
public sealed class ValueRange<T> : ValueValidator where T : IComparable
{
public T MinValue { get; }
public T MaxValue { get; }
public ValueRange(T min, T max)
{
MinValue = min;
MaxValue = max;
}
public override AcceptableValueBase ToAcceptable(Type type)
{
if (!(type == typeof(T)))
{
return null;
}
return (AcceptableValueBase)(object)new AcceptableValueRange<T>(MinValue, MaxValue);
}
}
}
namespace Il2CppTMPro
{
internal static class NamespaceStandIn
{
}
}
namespace Il2Cpp
{
internal static class NamespaceStandIn
{
}
}