using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.Skills; using RoR2.Stats; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: UnverifiableCode] 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 RunCard { internal class CardItem { public Sprite icon; public Texture background; public int count; public Color border; public int order; } internal class CardEnemy { public string name; public Texture portrait; public ulong value; } internal class CardTier { public Color color; public int count; public int order; } internal class CardPlayer { public string name; public ulong damage; public bool self; } internal class CardData { public string survivor = ""; public string player = ""; public Texture portrait; public Color accent = new Color(0.3f, 0.49f, 0.94f); public readonly List skills = new List(); public string difficulty = ""; public Sprite difficultyIcon; public Color difficultyColor = Color.white; public readonly List artifacts = new List(); public string title = ""; public string titleReason = ""; public bool win; public string result = ""; public string flavor = ""; public bool hasEndingColor; public Color endingColor; public bool dead; public string killer = ""; public Texture killerPortrait; public string deathPlace = ""; public string time = ""; public ulong stagesCleared; public ulong level; public string kills = "0"; public string damage = "0"; public string gold = "0"; public int itemTotal; public readonly List items = new List(); public readonly List tiers = new List(); public List stages = new List(); public int multikill; public string peakDifficulty = ""; public Color peakColor = Color.white; public readonly List topKills = new List(); public readonly List nemeses = new List(); public readonly List> numbers = new List>(); public readonly List> gameStats = new List>(); public readonly List squad = new List(); public readonly List> highlights = new List>(); public readonly List topStacks = new List(); public string seed = ""; public string date = ""; public TMP_FontAsset font; public bool showCredit = true; private double seconds; private ulong rawKills; private ulong rawDamage; private ulong rawMinionDamage; private ulong rawDamageTaken; private ulong rawPurchases; private ulong rawHealed; private StatSheet sheet; private int enemyTypes; private int lunarCount; private int voidCount; private int biggestStack; private string biggestStackName = ""; private bool hasStats; private static readonly HashSet AlreadyShown = new HashSet { "totalTimeAlive", "totalStagesCompleted", "highestLevel", "totalDeaths", "totalKills", "totalDamageDealt", "goldCollected", "totalGoldCollected", "highestDamageDealt", "totalDamageTaken", "totalHealthHealed", "totalEliteKills", "totalMinionDamageDealt", "totalPurchases" }; public static CardData From(RunReport report, int playerIndex, GameEndReportPanelController panel) { PlayerInfo info = report.GetPlayerInfoSafe(playerIndex) ?? report.FindFirstPlayerInfo(); if (info == null) { return null; } CardData card = new CardData(); card.font = (((Object)(object)panel != (Object)null && (Object)(object)panel.resultLabel != (Object)null) ? ((TMP_Text)panel.resultLabel).font : null); if ((Object)(object)card.font == (Object)null) { card.font = TMP_Settings.defaultFontAsset; } Try("survivor", delegate { card.ReadSurvivor(info); }); Try("skills", delegate { card.ReadSkills(info); }); Try("rules", delegate { card.ReadRules(report); }); Try("stats", delegate { card.ReadStats(report, info, panel); }); Try("ending", delegate { card.ReadEnding(report, info, panel); }); Try("items", delegate { card.ReadItems(info); }); Try("tracking", delegate { card.ReadTracking(report, info); }); Try("enemies", delegate { card.ReadEnemies(info); }); Try("squad", delegate { card.ReadSquad(report, info); }); Try("title", card.PickTitle); Try("highlights", card.PickHighlights); Try("footer", delegate { card.seed = report.seed.ToString("X16", CultureInfo.InvariantCulture); if (report.snapshotTimeUtc.Year > 2000) { card.date = report.snapshotTimeUtc.ToLocalTime().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture); } }); return card; } private static void Try(string what, Action action) { try { action(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not read " + what + ": " + ex)); } } private void ReadSurvivor(PlayerInfo info) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) player = info.name ?? ""; GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(info.bodyIndex); CharacterBody bodyPrefabBodyComponent = BodyCatalog.GetBodyPrefabBodyComponent(info.bodyIndex); if (!((Object)(object)bodyPrefabBodyComponent == (Object)null)) { survivor = Clean(Language.GetString(bodyPrefabBodyComponent.baseNameToken)); portrait = bodyPrefabBodyComponent.portraitIcon; Color val = bodyPrefabBodyComponent.bodyColor; SurvivorDef val2 = (((Object)(object)bodyPrefab != (Object)null) ? SurvivorCatalog.FindSurvivorDefFromBody(bodyPrefab) : null); if ((Object)(object)val2 != (Object)null) { val = val2.primaryColor; } if (((Color)(ref val)).maxColorComponent > 0.05f) { accent = val; } } } private void ReadSkills(PlayerInfo info) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) GameObject bodyPrefab = BodyCatalog.GetBodyPrefab(info.bodyIndex); if ((Object)(object)bodyPrefab == (Object)null || (Object)(object)info.master == (Object)null || info.master.loadout == null) { return; } GenericSkill[] components = bodyPrefab.GetComponents(); for (int i = 0; i < components.Length; i++) { if (skills.Count >= 5) { break; } SkillFamily val = (((Object)(object)components[i] != (Object)null) ? components[i].skillFamily : null); if (!((Object)(object)val == (Object)null) && val.variants != null && val.variants.Length != 0 && !components[i].hideInCharacterSelect) { uint skillVariant = info.master.loadout.bodyLoadoutManager.GetSkillVariant(info.bodyIndex, i); SkillDef skillDef = val.variants[Mathf.Min((int)skillVariant, val.variants.Length - 1)].skillDef; Sprite val2 = (((Object)(object)skillDef != (Object)null) ? ResolveIcon(skillDef, skillDef.icon) : null); if ((Object)(object)val2 != (Object)null) { skills.Add(val2); } } } } private unsafe void ReadRules(RunReport report) { //IL_000f: 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_0056: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (report.ruleBook == null) { return; } DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(report.ruleBook.FindDifficulty()); if (difficultyDef != null) { difficulty = Clean(Language.GetString(difficultyDef.nameToken)); difficultyIcon = difficultyDef.GetIconSprite(); difficultyColor = difficultyDef.color; } ChoicesEnumerable choices = report.ruleBook.choices; Enumerator enumerator = ((ChoicesEnumerable)(ref choices)).GetEnumerator(); try { while (((Enumerator)(ref enumerator)).MoveNext()) { RuleChoiceDef current = ((Enumerator)(ref enumerator)).Current; if (current != null && (int)current.artifactIndex != -1 && !(current.localName != "On")) { ArtifactDef artifactDef = ArtifactCatalog.GetArtifactDef(current.artifactIndex); Sprite val = (((Object)(object)artifactDef != (Object)null) ? (artifactDef.smallIconSelectedSprite ?? Load(artifactDef.smallIconSelectedReference)) : null); if ((Object)(object)val != (Object)null) { artifacts.Add(val); } } } } finally { ((IDisposable)(*(Enumerator*)(&enumerator))/*cast due to .constrained prefix*/).Dispose(); } } private static ulong Stat(StatSheet stats, string name) { StatDef val = StatDef.Find(name); if (val == null) { return 0uL; } return stats.GetStatValueULong(val); } private void ReadStats(RunReport report, PlayerInfo info, GameEndReportPanelController panel) { StatSheet stats = info.statSheet; seconds = report.runStopwatchValue; if (stats != null) { hasStats = true; if (seconds <= 0.0) { seconds = stats.GetStatValueDouble(StatDef.totalTimeAlive); } stagesCleared = Stat(stats, "totalStagesCompleted"); level = Stat(stats, "highestLevel"); rawKills = Stat(stats, "totalKills"); rawDamage = Stat(stats, "totalDamageDealt"); rawMinionDamage = Stat(stats, "totalMinionDamageDealt"); rawDamageTaken = Stat(stats, "totalDamageTaken"); rawPurchases = Stat(stats, "totalPurchases"); rawHealed = Stat(stats, "totalHealthHealed"); sheet = stats; kills = Compact(rawKills); damage = Compact(rawDamage); ulong num = Stat(stats, "totalGoldCollected"); gold = Compact((num != 0) ? num : Stat(stats, "goldCollected")); numbers.Add(new KeyValuePair("Biggest hit", Compact(Stat(stats, "highestDamageDealt")))); numbers.Add(new KeyValuePair("Damage taken", Compact(rawDamageTaken))); numbers.Add(new KeyValuePair("Healed", Compact(rawHealed))); numbers.Add(new KeyValuePair("Elites killed", Compact(Stat(stats, "totalEliteKills")))); numbers.Add(new KeyValuePair("Minion damage", Compact(rawMinionDamage))); numbers.Add(new KeyValuePair("Purchases", Compact(rawPurchases))); Try("game stats", delegate { ReadGameStats(stats, panel); }); } time = FormatTime(seconds); } private void ReadGameStats(StatSheet stats, GameEndReportPanelController panel) { string[] array = (((Object)(object)panel != (Object)null) ? panel.statsToDisplay : null); if (array == null) { return; } string[] array2 = array; foreach (string text in array2) { if (AlreadyShown.Contains(text)) { continue; } StatDef val = StatDef.Find(text); if (val != null) { string text2 = Clean(Language.GetString(val.displayToken)); if (text2.EndsWith(":")) { text2 = text2.Substring(0, text2.Length - 1); } gameStats.Add(new KeyValuePair(text2, Clean(stats.GetStatDisplayValue(val)))); if (gameStats.Count >= 8) { break; } } } } private void ReadEnding(RunReport report, PlayerInfo info, GameEndReportPanelController panel) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Invalid comparison between Unknown and I4 //IL_0136: Unknown result type (might be due to invalid IL or missing references) GameEndingDef gameEnding = report.gameEnding; win = (Object)(object)gameEnding != (Object)null && gameEnding.isWin; result = (win ? "VICTORY" : "DEFEAT"); if ((Object)(object)gameEnding != (Object)null) { if (!string.IsNullOrEmpty(gameEnding.endingTextToken)) { string text = Clean(Language.GetString(gameEnding.endingTextToken)); if (!string.IsNullOrEmpty(text) && text != gameEnding.endingTextToken && text.Length <= 18) { result = text.ToUpperInvariant(); } } hasEndingColor = true; endingColor = gameEnding.foregroundColor; } if (!string.IsNullOrEmpty(info.finalMessageToken)) { string text2 = Clean(Language.GetString(info.finalMessageToken)); if (!string.IsNullOrEmpty(text2) && text2 != info.finalMessageToken) { flavor = text2.Replace("{0}", info.name ?? ""); } } dead = info.isDead; if (!dead) { return; } deathPlace = "Stage " + (stagesCleared + 1); CharacterBody val = null; if ((int)info.killerBodyIndex != -1) { val = BodyCatalog.GetBodyPrefabBodyComponent(info.killerBodyIndex); } if ((Object)(object)val == (Object)null && (Object)(object)gameEnding != (Object)null && (Object)(object)gameEnding.defaultKillerOverride != (Object)null) { val = gameEnding.defaultKillerOverride.GetComponent(); } if ((Object)(object)val != (Object)null) { killer = Clean(Language.GetString(val.baseNameToken)); killerPortrait = val.portraitIcon; } else if ((Object)(object)panel != (Object)null && (Object)(object)panel.killerBodyLabel != (Object)null && ((Object)(object)panel.killerPanelObject == (Object)null || panel.killerPanelObject.activeInHierarchy)) { string text3 = Clean(((TMP_Text)panel.killerBodyLabel).text); int num = text3.IndexOf(':'); killer = ((num >= 0) ? text3.Substring(num + 1).Trim() : text3); if ((Object)(object)panel.killerBodyPortraitImage != (Object)null) { killerPortrait = panel.killerBodyPortraitImage.texture; } } } internal static bool IsVisibleItem(ItemIndex index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) ItemDef itemDef = ItemCatalog.GetItemDef(index); if ((Object)(object)itemDef == (Object)null || itemDef.hidden) { return false; } if ((int)itemDef.tier == 5) { return (Object)(object)ItemTierCatalog.GetItemTierDef(itemDef.tier) != (Object)null; } return true; } private void ReadItems(PlayerInfo info) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected I4, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) int order = 0; if (info.itemAcquisitionOrder != null && info.itemStacks != null) { ItemIndex[] itemAcquisitionOrder = info.itemAcquisitionOrder; foreach (ItemIndex val in itemAcquisitionOrder) { int num = (int)val; if (num >= 0 && num < info.itemStacks.Length) { AddItem(val, info.itemStacks[num], ref order); } } } if (items.Count == 0 && (Object)(object)info.master != (Object)null && (Object)(object)info.master.inventory != (Object)null) { Inventory inventory = info.master.inventory; foreach (ItemIndex item in inventory.itemAcquisitionOrder) { AddItem(item, inventory.GetItemCountPermanent(item), ref order); } } items.Sort((CardItem a, CardItem b) => a.order.CompareTo(b.order)); tiers.Sort((CardTier a, CardTier b) => a.order.CompareTo(b.order)); if (info.equipment == null) { return; } Color border = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)5)); border.a = 1f; int num2 = 0; EquipmentIndex[] equipment = info.equipment; for (int i = 0; i < equipment.Length; i++) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(equipment[i]); if (!((Object)(object)equipmentDef == (Object)null)) { items.Insert(num2++, new CardItem { icon = ResolveIcon(equipmentDef, equipmentDef.pickupIconSprite), background = equipmentDef.bgIconTexture, count = 1, border = border }); } } } private void AddItem(ItemIndex index, int count, ref int order) { //IL_000a: 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) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Invalid comparison between Unknown and I4 //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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Invalid comparison between Unknown and I4 //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Invalid comparison between Unknown and I4 //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Invalid comparison between Unknown and I4 //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Invalid comparison between Unknown and I4 if (count > 0 && IsVisibleItem(index)) { ItemDef itemDef = ItemCatalog.GetItemDef(index); Color val = default(Color); ((Color)(ref val))..ctor(0.6f, 0.64f, 0.71f); Texture background = null; ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(itemDef.tier); if ((Object)(object)itemTierDef != (Object)null) { val = Color32.op_Implicit(ColorCatalog.GetColor(itemTierDef.colorIndex)); background = itemTierDef.bgIconTexture; } val.a = 1f; int tierOrder = TierOrder(itemDef.tier); items.Add(new CardItem { icon = ResolveIcon(itemDef, itemDef.pickupIconSprite), background = background, count = count, border = val, order = tierOrder * 10000 + order++ }); itemTotal += count; CardTier cardTier = tiers.Find((CardTier t) => t.order == tierOrder); if (cardTier == null) { cardTier = new CardTier { order = tierOrder, color = val }; tiers.Add(cardTier); } cardTier.count += count; if ((int)itemDef.tier == 3) { lunarCount += count; } if ((int)itemDef.tier == 6 || (int)itemDef.tier == 7 || (int)itemDef.tier == 8 || (int)itemDef.tier == 9) { voidCount += count; } if (count > biggestStack) { biggestStack = count; biggestStackName = Clean(Language.GetString(itemDef.nameToken)); } } } private static Sprite Load(AssetReferenceT reference) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) try { if (reference != null && ((AssetReference)reference).RuntimeKeyIsValid()) { return Addressables.LoadAssetAsync(((AssetReference)reference).RuntimeKey).WaitForCompletion(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not load an icon: " + ex.Message)); } return null; } private static Sprite ResolveIcon(object def, Sprite direct) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)direct != (Object)null) { return direct; } try { MethodInfo method = def.GetType().GetMethod("GetIcon", Type.EmptyTypes); if (method != null) { object? obj = method.Invoke(def, null); Sprite val = (Sprite)((obj is Sprite) ? obj : null); if ((Object)(object)val != (Object)null) { return val; } } MethodInfo method2 = def.GetType().GetMethod("GetIconReference", Type.EmptyTypes); if (method2 != null && method2.Invoke(def, null) is AssetReferenceT val2 && ((AssetReference)val2).RuntimeKeyIsValid()) { return Addressables.LoadAssetAsync(((AssetReference)val2).RuntimeKey).WaitForCompletion(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not load an icon: " + ex.Message)); } return null; } private static int TierOrder(ItemTier tier) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected I4, but got Unknown return (int)tier switch { 2 => 0, 4 => 1, 3 => 2, 8 => 3, 9 => 4, 7 => 5, 6 => 6, 1 => 8, 0 => 9, _ => 7, }; } private void ReadTracking(RunReport report, PlayerInfo info) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) stages = RunTracker.Stages(report, info.master, itemTotal, rawKills); multikill = RunTracker.BestMultikill(report, info.master); if (RunTracker.PeakDifficulty(report, out var token, out var color)) { peakDifficulty = Clean(Language.GetString(token)).ToUpperInvariant(); peakColor = color; } if (dead && stages.Count > 0 && !string.IsNullOrEmpty(stages[stages.Count - 1].name)) { deathPlace = deathPlace + " · " + Clean(stages[stages.Count - 1].name); } } private void ReadEnemies(PlayerInfo info) { if (info.statSheet != null) { enemyTypes = Collect(info.statSheet, PerBodyStatDef.killsAgainst, topKills, 4); Collect(info.statSheet, PerBodyStatDef.damageTakenFrom, nemeses, 3); } } private static int Collect(StatSheet stats, PerBodyStatDef perBody, List target, int max) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 if (perBody == null) { return 0; } List list = new List(); for (int i = 0; i < BodyCatalog.bodyCount; i++) { StatDef val = perBody.FindStatDef((BodyIndex)i); if (val == null) { continue; } ulong num = (((int)val.dataType == 1) ? ((ulong)Math.Max(0.0, stats.GetStatValueDouble(val))) : stats.GetStatValueULong(val)); if (num != 0L) { CharacterBody bodyPrefabBodyComponent = BodyCatalog.GetBodyPrefabBodyComponent((BodyIndex)i); string name = (((Object)(object)bodyPrefabBodyComponent != (Object)null) ? Clean(Language.GetString(bodyPrefabBodyComponent.baseNameToken)) : BodyCatalog.GetBodyName((BodyIndex)i)); CardEnemy cardEnemy = list.Find((CardEnemy b) => b.name == name); if (cardEnemy != null) { cardEnemy.value += num; continue; } list.Add(new CardEnemy { name = name, value = num, portrait = (((Object)(object)bodyPrefabBodyComponent != (Object)null) ? bodyPrefabBodyComponent.portraitIcon : null) }); } } list.Sort((CardEnemy a, CardEnemy b) => b.value.CompareTo(a.value)); for (int num2 = 0; num2 < list.Count && num2 < max; num2++) { target.Add(list[num2]); } return list.Count; } private void ReadSquad(RunReport report, PlayerInfo self) { if (report.playerInfoCount < 2) { return; } for (int i = 0; i < report.playerInfoCount; i++) { PlayerInfo playerInfo = report.GetPlayerInfo(i); if (playerInfo != null) { squad.Add(new CardPlayer { name = (playerInfo.name ?? ""), damage = ((playerInfo.statSheet != null) ? Stat(playerInfo.statSheet, "totalDamageDealt") : 0), self = (playerInfo == self) }); } } squad.Sort((CardPlayer a, CardPlayer b) => b.damage.CompareTo(a.damage)); if (squad.Count > 4) { int num = squad.FindIndex((CardPlayer p) => p.self); if (num > 3) { squad[3] = squad[num]; } squad.RemoveRange(4, squad.Count - 4); } } private void PickTitle() { if (hasStats) { double num = seconds / 60.0; if (dead && stagesCleared == 0L && seconds < 300.0) { Title("DEAD ON ARRIVAL", "down on stage 1 after " + time); } else if (rawDamageTaken == 0L && seconds >= 120.0) { Title("UNTOUCHABLE", "took 0 damage all run"); } else if (biggestStack >= 10) { Title("ONE-TRICK", biggestStack + "x " + biggestStackName); } else if (itemTotal >= 80) { Title("HOARDER", itemTotal + " items carried"); } else if (rawMinionDamage > rawDamage && rawMinionDamage != 0) { Title("DRONE COMMANDER", "minions dealt " + 100 * rawMinionDamage / (rawMinionDamage + rawDamage) + "% of the damage"); } else if (lunarCount >= 5) { Title("LUNATIC", lunarCount + " lunar items"); } else if (voidCount >= 6) { Title("VOID TOUCHED", voidCount + " void items"); } else if (stagesCleared >= 5 && seconds / (double)stagesCleared < 210.0) { Title("SPEEDRUNNER", FormatTime(seconds / (double)stagesCleared) + " per stage"); } else if (seconds >= 3600.0) { Title("MARATHON", time + " on the clock"); } else if (num >= 2.0 && (double)rawKills / num >= 60.0) { Title("EXTERMINATOR", Math.Round((double)rawKills / num) + " kills per minute"); } else if (rawPurchases == 0L && stagesCleared >= 2) { Title("MINIMALIST", "0 purchases"); } else if (win) { Title("ESCAPEE", "made it off the planet"); } else { Title("LOST IN TRANSIT", (stagesCleared == 1) ? "1 stage cleared" : (stagesCleared + " stages cleared")); } } } private double Number(string name) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 StatDef val = ((sheet != null) ? StatDef.Find(name) : null); if (val == null) { return 0.0; } if ((int)val.dataType != 1) { return sheet.GetStatValueULong(val); } return sheet.GetStatValueDouble(val); } private void PickHighlights() { List list = new List(items); list.RemoveAll((CardItem i) => i.count < 2); list.Sort((CardItem a, CardItem b) => b.count.CompareTo(a.count)); for (int num = 0; num < list.Count && num < 3; num++) { topStacks.Add(list[num]); } if (hasStats) { double num2 = seconds / 60.0; if (biggestStack >= 3) { Highlight(biggestStack + "x", biggestStackName); } if (seconds >= 20.0 && rawKills != 0) { Highlight(Compact((ulong)Math.Round((double)rawKills / num2)), "kills per minute"); } double num3 = Number("totalDistanceTraveled"); if (num3 >= 100.0) { Highlight((num3 >= 1000.0) ? ((num3 / 1000.0).ToString("0.0", CultureInfo.InvariantCulture) + " km") : (Math.Round(num3) + " m"), "travelled"); } if (enemyTypes >= 2) { Highlight(enemyTypes.ToString(), "kinds of enemy killed"); } double num4 = Number("totalTeleporterBossKillsWitnessed"); if (num4 >= 1.0) { Highlight(Compact((ulong)num4), (num4 >= 2.0) ? "teleporter bosses down" : "teleporter boss down"); } if (seconds >= 20.0 && rawDamage != 0) { Highlight(Compact((ulong)Math.Round((double)rawDamage / seconds)), "damage per second"); } double num5 = Number("totalLunarPurchases"); if (num5 >= 1.0) { Highlight(Compact((ulong)num5), (num5 >= 2.0) ? "lunar deals" : "lunar deal"); } double num6 = Number("totalBloodPurchases"); if (num6 >= 1.0) { Highlight(Compact((ulong)num6), (num6 >= 2.0) ? "times paid in blood" : "time paid in blood"); } double num7 = Number("totalDronesPurchased") + Number("totalTurretsPurchased"); if (num7 >= 1.0) { Highlight(Compact((ulong)num7), (num7 >= 2.0) ? "drones bought" : "drone bought"); } if (rawDamageTaken != 0 && rawHealed >= rawDamageTaken * 2) { Highlight(((double)rawHealed / (double)rawDamageTaken).ToString("0.#", CultureInfo.InvariantCulture) + "x", "healed vs damage taken"); } if (itemTotal >= 5 && seconds >= 20.0) { Highlight(Math.Max(1, (int)Math.Round(seconds / (double)itemTotal)) + " s", "per item picked up"); } } } private void Highlight(string value, string label) { highlights.Add(new KeyValuePair(value, label)); } private void Title(string name, string reason) { title = name; titleReason = reason; } internal static string Compact(ulong value) { if (value < 10000) { return value.ToString("N0", CultureInfo.InvariantCulture); } double num = value; string[] array = new string[6] { "K", "M", "B", "T", "Qa", "Qi" }; int num2 = -1; while (num >= 1000.0 && num2 < array.Length - 1) { num /= 1000.0; num2++; } return num.ToString((num >= 100.0) ? "0" : "0.#", CultureInfo.InvariantCulture) + array[num2]; } internal static string FormatTime(double seconds) { if (seconds < 0.0 || double.IsNaN(seconds) || double.IsInfinity(seconds)) { seconds = 0.0; } long num = (long)Math.Floor(seconds); long num2 = num / 3600; long num3 = num / 60 % 60; long num4 = num % 60; if (num2 <= 0) { return string.Format(CultureInfo.InvariantCulture, "{0}:{1:00}", num3, num4); } return string.Format(CultureInfo.InvariantCulture, "{0}:{1:00}:{2:00}", num2, num3, num4); } internal static string Clean(string text) { if (!string.IsNullOrEmpty(text)) { return Regex.Replace(text, "<.*?>", "").Trim(); } return ""; } } internal class CardRenderer : IDisposable { private const int W = 1200; private const int H = 675; private const int UiLayer = 5; private const int X0 = 372; private const int X1 = 1160; private const int MW = 788; private static readonly Color TextMain = Hex(15922424); private static readonly Color TextSoft = Hex(12173776); private static readonly Color TextDim = Hex(9345195); private static readonly Color Ink = Hex(724500); private static readonly Color TileBg = Hex(1448743); private static readonly Color Lose = Hex(15753803); private static readonly Color Win = Hex(8118410); private GameObject root; private RenderTexture target; private Texture2D background; private RectTransform canvasRect; private TMP_FontAsset font; private int width; private int height; private Color accent; private Color onAccent; private Color resultColor; public static CardRenderer Build(CardData card, float scale) { CardRenderer cardRenderer = new CardRenderer(); try { cardRenderer.Create(card, Mathf.Clamp(scale, 1f, 2f)); return cardRenderer; } catch { cardRenderer.Dispose(); throw; } } private void Create(CardData card, float scale) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Expected O, but got Unknown width = Mathf.RoundToInt(1200f * scale); height = Mathf.RoundToInt(675f * scale); font = card.font; PickColors(card); target = new RenderTexture(width, height, 24, (RenderTextureFormat)0); target.Create(); root = new GameObject("RunCardRoot"); ((Object)root).hideFlags = (HideFlags)61; root.transform.position = new Vector3(0f, -20000f, 0f); GameObject val = new GameObject("RunCardCamera"); val.transform.SetParent(root.transform, false); Camera val2 = val.AddComponent(); val2.clearFlags = (CameraClearFlags)2; val2.backgroundColor = Hex(658709); val2.orthographic = true; val2.cullingMask = 32; val2.nearClipPlane = 0.1f; val2.farClipPlane = 10f; val2.allowHDR = false; val2.allowMSAA = false; val2.useOcclusionCulling = false; val2.depth = -100f; val2.targetTexture = target; GameObject val3 = new GameObject("RunCardCanvas", new Type[1] { typeof(RectTransform) }); val3.layer = 5; val3.transform.SetParent(root.transform, false); Canvas obj = val3.AddComponent(); obj.renderMode = (RenderMode)1; obj.worldCamera = val2; obj.planeDistance = 1f; obj.pixelPerfect = false; CanvasScaler obj2 = val3.AddComponent(); obj2.uiScaleMode = (ScaleMode)0; obj2.scaleFactor = scale; canvasRect = (RectTransform)val3.transform; Section("background", delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) background = Backdrop.Build(accent, 1200, 675); Picture((Texture)(object)background, 0f, 0f, 1200f, 675f); }); Section("survivor", delegate { Survivor(card); }); Section("outcome", delegate { Outcome(card); }); Section("numbers", delegate { Numbers(card); }); Section("items", delegate { Items(card); }); Section("timeline", delegate { if (card.stages.Count > 0) { Timeline(card); } else { GameStats(card); } }); Section("encounters", delegate { Encounters(card); }); Section("footer", delegate { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(card.date)) { Label(card.date, 40f, 646f, 200f, 14f, 10.5f, TextDim, (TextAlignmentOptions)513, bold: false); } if (!string.IsNullOrEmpty(card.seed)) { Label("SEED " + card.seed, 372f, 646f, 400f, 14f, 10.5f, TextDim, (TextAlignmentOptions)513, bold: false); } if (card.showCredit) { Label("RunCard", 960f, 646f, 200f, 14f, 10.5f, TextDim, (TextAlignmentOptions)516, bold: true); } }); Canvas.ForceUpdateCanvases(); } private static void Section(string name, Action draw) { try { draw(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Card section '" + name + "' failed: " + ex)); } } private void PickColors(CardData card) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num3 = default(float); float num2 = default(float); Color.RGBToHSV(card.accent, ref num, ref num2, ref num3); if (num2 < 0.12f) { num = 0.61f; num2 = 0.25f; } else { num2 = Mathf.Clamp(num2, 0.45f, 0.8f); } accent = Color.HSVToRGB(num, num2, Mathf.Clamp(num3, 0.86f, 0.97f)); accent.a = 1f; onAccent = ((Brightness(accent) > 0.35f) ? Ink : TextMain); resultColor = (card.win ? Win : Lose); if (card.hasEndingColor && Brightness(card.endingColor) > 0.45f) { resultColor = card.endingColor; resultColor.a = 1f; } } private void Survivor(CardData card) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0246: 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_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) Box(48f, 48f, 176f, 176f, Mix(accent, 0.27f)); Portrait(card.portrait, 40f, 40f, 176f, accent, 3f, card.survivor); Label(card.survivor, 40f, 232f, 244f, 42f, 34f, TextMain, (TextAlignmentOptions)513, bold: true, 18f); Label(card.player, 40f, 274f, 244f, 20f, 15f, TextDim, (TextAlignmentOptions)513, bold: false); float num = 308f; if (!string.IsNullOrEmpty(card.title)) { float w = Mathf.Min(244f, Measure(card.title, 15f, bold: true) + 26f); Box(40f, num, w, 30f, accent); Label(card.title, 40f, num, w, 30f, 15f, onAccent, (TextAlignmentOptions)514, bold: true, 10f); Label(card.titleReason, 40f, num + 34f, 244f, 18f, 12f, TextSoft, (TextAlignmentOptions)513, bold: false, 9f); num += 76f; } if (card.skills.Count > 0) { Label("LOADOUT", 40f, num, 200f, 14f, 10.5f, TextDim, (TextAlignmentOptions)513, bold: true); for (int i = 0; i < card.skills.Count && i < 5; i++) { float num2 = 40 + i * 48; Box(num2, num + 20f, 40f, 40f, Mix(Color.white, 0.07f)); Icon(card.skills[i], num2 + 1f, num + 21f, 38f, 38f); Frame(num2, num + 20f, 40f, 40f, Mix(Color.white, 0.24f), 1f); } num += 80f; } if (!string.IsNullOrEmpty(card.difficulty)) { Label("DIFFICULTY", 40f, num, 200f, 14f, 10.5f, TextDim, (TextAlignmentOptions)513, bold: true); float num3 = 40f; if ((Object)(object)card.difficultyIcon != (Object)null) { Icon(card.difficultyIcon, 38f, num + 17f, 34f, 34f); num3 = 80f; } Color color = ((Brightness(card.difficultyColor) > 0.4f) ? card.difficultyColor : TextSoft); color.a = 1f; Label(card.difficulty, num3, num + 18f, 280f - num3, 32f, 20f, color, (TextAlignmentOptions)513, bold: true, 12f); num += 60f; } if (card.artifacts.Count > 0) { for (int j = 0; j < card.artifacts.Count && j < 8; j++) { float x = 40 + j * 30; Box(x, num, 26f, 26f, Mix(Color.white, 0.06f)); Icon(card.artifacts[j], x, num, 26f, 26f); } num += 38f; } int num4 = Mathf.Min(card.highlights.Count, Mathf.FloorToInt((634f - (num + 20f)) / 21f)); if (num4 > 0) { Label("HIGHLIGHTS", 40f, num, 200f, 14f, 10.5f, TextDim, (TextAlignmentOptions)513, bold: true); for (int k = 0; k < num4; k++) { float y = num + 20f + (float)k * 21f; Label(card.highlights[k].Key, 40f, y, 62f, 21f, 15f, accent, (TextAlignmentOptions)513, bold: true, 9f); Label(card.highlights[k].Value, 108f, y, 160f, 21f, 12.5f, TextSoft, (TextAlignmentOptions)513, bold: false, 9f); } } } private void Outcome(CardData card) { //IL_0021: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) Label(card.result, 372f, 28f, 440f, 66f, 56f, resultColor, (TextAlignmentOptions)513, bold: true, 30f); Label(card.flavor, 374f, 96f, 470f, 22f, 14.5f, TextSoft, (TextAlignmentOptions)513, bold: false, 10f, italic: true); if (card.dead) { float num = 1160f; if ((Object)(object)card.killerPortrait != (Object)null) { Portrait(card.killerPortrait, 1068f, 38f, 90f, resultColor, 2f, card.killer); num = 1052f; } float num2 = 800f; if (!string.IsNullOrEmpty(card.killer)) { Label("KILLED BY", num2, 44f, num - num2, 14f, 10.5f, TextDim, (TextAlignmentOptions)516, bold: true); Label(card.killer, num2, 60f, num - num2, 34f, 24f, TextMain, (TextAlignmentOptions)516, bold: true, 13f); } Label(card.deathPlace, num2, 98f, num - num2, 18f, 12.5f, TextSoft, (TextAlignmentOptions)516, bold: false, 9f); } } private void Numbers(CardData card) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_01b2: 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) string[] array = new string[6] { card.time, card.stagesCleared.ToString(), card.level.ToString(), card.kills, card.damage, card.gold }; string[] array2 = new string[6] { "TIME", (card.stagesCleared == 1) ? "STAGE CLEARED" : "STAGES CLEARED", "LEVEL", "KILLS", "DAMAGE", "GOLD" }; Box(372f, 146f, 788f, 62f, Mix(Color.white, 0.05f)); Box(372f, 146f, 788f, 1f, Mix(Color.white, 0.12f)); Box(372f, 207f, 788f, 1f, Mix(Color.white, 0.055f)); float num = 788f / (float)array.Length; for (int i = 0; i < array.Length; i++) { float num2 = 372f + (float)i * num; Label(array[i], num2 + 4f, 151f, num - 8f, 34f, 27f, TextMain, (TextAlignmentOptions)514, bold: true, 15f); Label(array2[i], num2 + 2f, 185f, num - 4f, 16f, 10f, TextDim, (TextAlignmentOptions)514, bold: true, 7f); if (i > 0) { Box(num2, 158f, 1f, 38f, Mix(Color.white, 0.1f)); } } } private void Items(CardData card) { //IL_001f: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_030a: 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_03bd: 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) Label("ITEMS", 372f, 224f, 60f, 16f, 12f, TextDim, (TextAlignmentOptions)513, bold: true); Label(card.itemTotal.ToString(), 422f, 222f, 54f, 20f, 15f, TextMain, (TextAlignmentOptions)513, bold: true, 10f); int num = 0; foreach (CardTier tier in card.tiers) { num += tier.count; } if (num > 0) { float num2 = 684f - 2f * (float)(card.tiers.Count - 1); float num3 = 476f; foreach (CardTier tier2 in card.tiers) { float num4 = Mathf.Max(4f, num2 * (float)tier2.count / (float)num); num4 = Mathf.Min(num4, 1160f - num3); if (num4 <= 0f) { break; } Box(num3, 229f, num4, 6f, tier2.color); num3 += num4 + 2f; } } int count = card.items.Count; if (count == 0) { Box(372f, 250f, 788f, 64f, Mix(Color.white, 0.04f)); Label("No items", 372f, 250f, 788f, 64f, 16f, TextDim, (TextAlignmentOptions)514, bold: false); return; } int num5 = 22; int num6 = 4; int num7 = 1; int num8 = 1; for (int num9 = 64; num9 >= 22; num9--) { int num10 = ((num9 >= 48) ? 8 : ((num9 >= 34) ? 6 : 4)); num5 = num9; num6 = num10; num7 = Mathf.Max(1, (788 + num10) / (num9 + num10)); num8 = Mathf.Max(1, (172 + num10) / (num9 + num10)); if (count <= num7 * num8) { break; } } int num11 = Mathf.Min(count, num7 * num8); float num12 = Mathf.Clamp((float)num5 * 0.24f, 9f, 16f); for (int i = 0; i < num11; i++) { CardItem cardItem = card.items[i]; int num13 = 372 + i % num7 * (num5 + num6); int num14 = 250 + i / num7 * (num5 + num6); if ((Object)(object)cardItem.background != (Object)null) { Picture(cardItem.background, num13, num14, num5, num5); } else { int num15 = ((num5 < 44) ? 1 : 2); Box(num13, num14, num5, num5, cardItem.border); Box(num13 + num15, num14 + num15, num5 - 2 * num15, num5 - 2 * num15, TileBg); } if ((Object)(object)cardItem.icon != (Object)null) { int num16 = Mathf.Max(1, num5 / 16); Icon(cardItem.icon, num13 + num16, num14 + num16, num5 - 2 * num16, num5 - 2 * num16); } if (cardItem.count > 1) { string text = "x" + cardItem.count; float num17 = (float)text.Length * num12 * 0.62f + 6f; float num18 = num12 + 5f; Box((float)(num13 + num5) - num17, (float)(num14 + num5) - num18, num17, num18, Mix(Color.black, 0.72f)); Label(text, (float)(num13 + num5) - num17, (float)(num14 + num5) - num18, num17 - 3f, num18, num12, TextMain, (TextAlignmentOptions)516, bold: true); } } } private void Timeline(CardData card) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) Label("TIMELINE", 372f, 440f, 120f, 16f, 12f, TextDim, (TextAlignmentOptions)513, bold: true); List list = new List(); if (card.multikill >= 2) { list.Add("x" + card.multikill + " MULTIKILL"); } if (!string.IsNullOrEmpty(card.peakDifficulty)) { Color val = ((Brightness(card.peakColor) > 0.35f) ? card.peakColor : TextMain); list.Add("PEAK " + card.peakDifficulty + ""); } if (list.Count > 0) { Label(string.Join(" · ", list.ToArray()), 502f, 440f, 658f, 16f, 12f, TextDim, (TextAlignmentOptions)516, bold: true, 8f, italic: false, rich: true); } int num = Mathf.Max(0, card.stages.Count - 40); int num2 = card.stages.Count - num; float num3 = 0f; for (int i = 0; i < num2; i++) { num3 += Mathf.Max(0f, card.stages[num + i].seconds); } if (num2 == 0 || num3 <= 0f) { return; } float num4 = 788f - 3f * (float)(num2 - 1); float[] array = new float[num2]; float num5 = 0f; for (int j = 0; j < num2; j++) { array[j] = Mathf.Max(14f, num4 * card.stages[num + j].seconds / num3); num5 += array[j]; } Color val2 = default(Color); ((Color)(ref val2))..ctor(accent.r * 0.72f, accent.g * 0.72f, accent.b * 0.72f, 1f); float num6 = 372f; for (int k = 0; k < num2; k++) { StageResult stageResult = card.stages[num + k]; float num7 = array[k] * num4 / num5; Box(num6, 464f, num7, 28f, (k % 2 == 0) ? accent : val2); if (num7 >= 18f) { Label((num + k + 1).ToString(), num6, 464f, num7, 28f, 14f, onAccent, (TextAlignmentOptions)514, bold: true, 8f); } string text = CardData.FormatTime(stageResult.seconds); if (num7 >= 84f) { Label(CardData.Clean(stageResult.name), num6, 497f, num7 - 6f, 15f, 11.5f, TextSoft, (TextAlignmentOptions)513, bold: false); float num8 = Measure(text, 12f, bold: true) + 8f; Label(text, num6, 513f, num8, 15f, 12f, TextMain, (TextAlignmentOptions)513, bold: true); if (stageResult.itemsGained > 0) { string text2 = "+" + stageResult.itemsGained + ((stageResult.itemsGained == 1) ? " item" : " items"); Label(text2, num6 + num8, 513f, num7 - num8 - 4f, 15f, 11f, TextDim, (TextAlignmentOptions)513, bold: false); } } else if (num7 >= 34f) { Label(text, num6, 497f, num7, 15f, 11.5f, TextMain, (TextAlignmentOptions)513, bold: true, 8f); } num6 += num7 + 3f; } if (card.dead) { Box(1156f, 461f, 4f, 34f, resultColor); } } private void GameStats(CardData card) { //IL_001f: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) Label("STATS", 372f, 440f, 120f, 16f, 12f, TextDim, (TextAlignmentOptions)513, bold: true); int num = Mathf.Min(card.gameStats.Count, 8); if (num != 0) { int num2 = (num + 1) / 2; float num3 = 374f; for (int i = 0; i < num; i++) { float num4 = 372f + (float)(i / num2) * (num3 + 40f); float y = 464f + (float)(i % num2) * 19f; Label(card.gameStats[i].Key, num4, y, num3 - 90f, 19f, 13f, TextSoft, (TextAlignmentOptions)513, bold: false); Label(card.gameStats[i].Value, num4 + num3 - 90f, y, 90f, 19f, 14f, TextMain, (TextAlignmentOptions)516, bold: true, 9f); } Box(372f + num3 + 20f, 466f, 1f, (float)num2 * 19f - 4f, Mix(Color.white, 0.1f)); } } private void Encounters(CardData card) { //IL_0017: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0377: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: 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_0249: Unknown result type (might be due to invalid IL or missing references) EnemyRow("YOU KILLED", card.topKills, 4, 372f, 546f, Mix(Color.white, 0.28f)); float num = 626f; if (card.nemeses.Count > 0) { EnemyRow("HURT YOU MOST", card.nemeses, 3, num, 546f, Mix(resultColor, 0.6f)); } else { StackRow(card.topStacks, num, 546f); } float num2 = num + 168f + 30f; float num3 = 1160f - num2; if (card.squad.Count > 1) { Label("SQUAD · DAMAGE", num2, 546f, 240f, 14f, 10.5f, TextDim, (TextAlignmentOptions)513, bold: true); ulong num4 = 1uL; foreach (CardPlayer item in card.squad) { num4 = Math.Max(num4, item.damage); } float x = num2 + 100f; float num5 = num3 - 100f - 52f; for (int i = 0; i < card.squad.Count && i < 4; i++) { CardPlayer cardPlayer = card.squad[i]; float num6 = 566f + (float)i * 17f; Label(cardPlayer.name, num2, num6, 96f, 16f, 12f, cardPlayer.self ? TextMain : TextSoft, (TextAlignmentOptions)513, cardPlayer.self); Box(x, num6 + 5f, num5, 6f, Mix(Color.white, 0.09f)); Box(x, num6 + 5f, Mathf.Max(2f, num5 * (float)((double)cardPlayer.damage / (double)num4)), 6f, cardPlayer.self ? accent : Mix(Color.white, 0.47f)); Label(CardData.Compact(cardPlayer.damage), num2 + num3 - 50f, num6, 50f, 16f, 12f, cardPlayer.self ? TextMain : TextSoft, (TextAlignmentOptions)516, bold: true, 8f); } } else if (card.numbers.Count != 0) { Label("NUMBERS", num2, 546f, 200f, 14f, 10.5f, TextDim, (TextAlignmentOptions)513, bold: true); float num7 = (num3 - 24f) / 2f; for (int j = 0; j < card.numbers.Count && j < 6; j++) { float num8 = num2 + (float)(j / 3) * (num7 + 24f); float y = 567f + (float)(j % 3) * 21f; Label(card.numbers[j].Key, num8, y, num7 - 56f, 18f, 12.5f, TextSoft, (TextAlignmentOptions)513, bold: false, 9f); Label(card.numbers[j].Value, num8 + num7 - 56f, y, 56f, 18f, 13.5f, TextMain, (TextAlignmentOptions)516, bold: true, 9f); } Box(num2 + num7 + 12f, 569f, 1f, 58f, Mix(Color.white, 0.1f)); } } private void EnemyRow(string title, List enemies, int max, float x, float top, Color border) { //IL_001e: 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_00b2: Unknown result type (might be due to invalid IL or missing references) if (enemies.Count != 0) { Label(title, x, top, 200f, 14f, 10.5f, TextDim, (TextAlignmentOptions)513, bold: true); for (int i = 0; i < enemies.Count && i < max; i++) { float num = x + 1f + (float)i * 56f; Portrait(enemies[i].portrait, num, top + 21f, 44f, border, 1f, enemies[i].name); Label(CardData.Compact(enemies[i].value), num - 6f, top + 68f, 56f, 16f, 12f, TextMain, (TextAlignmentOptions)514, bold: true, 8f); } } } private void StackRow(List stacks, float x, float top) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) if (stacks.Count == 0) { return; } Label("MOST STACKED", x, top, 200f, 14f, 10.5f, TextDim, (TextAlignmentOptions)513, bold: true); for (int i = 0; i < stacks.Count && i < 3; i++) { float num = x + 1f + (float)i * 56f; if ((Object)(object)stacks[i].background != (Object)null) { Picture(stacks[i].background, num, top + 21f, 44f, 44f); } else { Box(num, top + 21f, 44f, 44f, TileBg); Frame(num, top + 21f, 44f, 44f, stacks[i].border, 1f); } Icon(stacks[i].icon, num + 2f, top + 23f, 40f, 40f); Label("x" + stacks[i].count, num - 6f, top + 68f, 56f, 16f, 12f, TextMain, (TextAlignmentOptions)514, bold: true, 8f); } } public Texture2D Capture(out Color32[] pixels) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) RenderTexture active = RenderTexture.active; Texture2D val = new Texture2D(width, height, (TextureFormat)4, false); try { RenderTexture.active = target; val.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0); val.Apply(); pixels = val.GetPixels32(); for (int i = 0; i < pixels.Length; i++) { pixels[i].a = byte.MaxValue; } val.SetPixels32(pixels); val.Apply(); return val; } catch { Object.Destroy((Object)(object)val); throw; } finally { RenderTexture.active = active; } } public void Dispose() { if ((Object)(object)root != (Object)null) { Object.Destroy((Object)(object)root); root = null; } if ((Object)(object)background != (Object)null) { Object.Destroy((Object)(object)background); background = null; } if ((Object)(object)target != (Object)null) { target.Release(); Object.Destroy((Object)(object)target); target = null; } } private RectTransform Node(string name, float x, float y, float w, float h) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }) { layer = 5 }.transform; ((Transform)val).SetParent((Transform)(object)canvasRect, false); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 1f); val.pivot = val2; Vector2 anchorMin = (val.anchorMax = val2); val.anchorMin = anchorMin; val.anchoredPosition = new Vector2(x, 0f - y); val.sizeDelta = new Vector2(w, h); return val; } private void Box(float x, float y, float w, float h, Color color) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!(w <= 0f) && !(h <= 0f)) { Image obj = ((Component)Node("Box", x, y, w, h)).gameObject.AddComponent(); ((Graphic)obj).color = color; ((Graphic)obj).raycastTarget = false; } } private void Frame(float x, float y, float w, float h, Color color, float t) { //IL_0006: 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_0033: 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) Box(x, y, w, t, color); Box(x, y + h - t, w, t, color); Box(x, y + t, t, h - 2f * t, color); Box(x + w - t, y + t, t, h - 2f * t, color); } private void Portrait(Texture texture, float x, float y, float size, Color border, float t, string fallbackName) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) Box(x, y, size, size, new Color(0.04f, 0.06f, 0.1f, 0.85f)); if ((Object)(object)texture != (Object)null) { Picture(texture, x, y, size, size); } else if (!string.IsNullOrEmpty(fallbackName)) { Label(fallbackName, x + 3f, y, size - 6f, size, Mathf.Max(9f, size * 0.2f), TextSoft, (TextAlignmentOptions)514, bold: false, 7f); } Frame(x - t, y - t, size + 2f * t, size + 2f * t, border, t); } private void Picture(Texture texture, float x, float y, float w, float h) { RawImage obj = ((Component)Node("Picture", x, y, w, h)).gameObject.AddComponent(); obj.texture = texture; ((Graphic)obj).raycastTarget = false; } private void Icon(Sprite sprite, float x, float y, float w, float h) { if (!((Object)(object)sprite == (Object)null)) { Image obj = ((Component)Node("Icon", x, y, w, h)).gameObject.AddComponent(); obj.sprite = sprite; obj.preserveAspect = true; ((Graphic)obj).raycastTarget = false; } } private TextMeshProUGUI Label(string text, float x, float y, float w, float h, float size, Color color, TextAlignmentOptions align, bool bold, float shrinkTo = 0f, bool italic = false, bool rich = false) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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) if (string.IsNullOrEmpty(text) || w <= 0f) { return null; } TextMeshProUGUI val = ((Component)Node("Text", x, y, w, h)).gameObject.AddComponent(); if ((Object)(object)font != (Object)null) { ((TMP_Text)val).font = font; } ((TMP_Text)val).richText = rich; ((TMP_Text)val).fontSize = size; if (shrinkTo > 0f) { ((TMP_Text)val).enableAutoSizing = true; ((TMP_Text)val).fontSizeMax = size; ((TMP_Text)val).fontSizeMin = shrinkTo; } FontStyles val2 = (FontStyles)(bold ? 1 : 0); if (italic) { val2 = (FontStyles)(val2 | 2); } ((TMP_Text)val).fontStyle = val2; ((Graphic)val).color = color; ((TMP_Text)val).alignment = align; ((TMP_Text)val).enableWordWrapping = false; ((TMP_Text)val).overflowMode = (TextOverflowModes)1; ((Graphic)val).raycastTarget = false; ((TMP_Text)val).text = text; return val; } private float Measure(string text, float size, bool bold) { //IL_0027: 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) float num = (float)text.Length * size * 0.62f; try { TextMeshProUGUI val = Label(text, 0f, 0f, 2000f, 40f, size, Color.clear, (TextAlignmentOptions)513, bold); if ((Object)(object)val == (Object)null) { return num; } float x = ((TMP_Text)val).GetPreferredValues(text).x; Object.DestroyImmediate((Object)(object)((Component)val).gameObject); return (x > 1f && x < 2000f) ? x : num; } catch (Exception) { return num; } } private static Color Mix(Color color, float alpha) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) float num = Brightness(color); float num2 = alpha * num + (1f - alpha) * 0.08f; float num3 = Mathf.Pow(num, 2.2f) - Mathf.Pow(0.08f, 2.2f); if (Mathf.Abs(num3) > 0.0001f) { alpha = Mathf.Clamp01((Mathf.Pow(num2, 2.2f) - Mathf.Pow(0.08f, 2.2f)) / num3); } color.a = alpha; return color; } private static float Brightness(Color c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) return 0.299f * c.r + 0.587f * c.g + 0.114f * c.b; } private static Color Hex(int rgb) { //IL_0022: 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) return Color32.op_Implicit(new Color32((byte)((rgb >> 16) & 0xFF), (byte)((rgb >> 8) & 0xFF), (byte)(rgb & 0xFF), byte.MaxValue)); } } internal static class Backdrop { public static Texture2D Build(Color accent, int cardW, int cardH) { //IL_0012: 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_002c: 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_004c: 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) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Expected O, but got Unknown //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[202800]; Random random = new Random(7); float num = accent.r * 255f; float num2 = accent.g * 255f; float num3 = accent.b * 255f; float num4 = (float)cardW / (float)cardH; float num5 = Mathf.Clamp01(0.5f + (accent.b - Mathf.Max(accent.r, accent.g)) * 1.2f); float num6 = Mathf.Lerp(0.45f, 1f, num5); float num7 = 0.22f * num6; float num8 = 0.16f * num6; float num9 = 0.2f * num6; for (int i = 0; i < 338; i++) { float num10 = (float)i / 337f; int num11 = (337 - i) * 600; for (int j = 0; j < 600; j++) { float num12 = (float)j / 599f; float num13 = num12 * (float)cardW; float num14 = num10 * (float)cardH; float num15 = Mathf.Lerp(21f, 8f, num10); float num16 = Mathf.Lerp(27f, 10f, num10); float num17 = Mathf.Lerp(42f, 17f, num10); float num18 = (num12 - 0.1f) * num4; float num19 = num10 - 0.22f; float num20 = Mathf.Clamp01(1f - Mathf.Sqrt(num18 * num18 + num19 * num19) / 0.95f); num20 *= num20; num15 += num * num20 * num7; num16 += num2 * num20 * num7; num17 += num3 * num20 * num7; float num21 = 322f - 46f * num10; float num22 = Mathf.Clamp01((num21 - num13) / 2f + 0.5f); float num23 = 1f - 0.45f * num10; float num24 = (num * num8 + 14f) * num23 + num * num20 * num9; float num25 = (num2 * num8 + 18f) * num23 + num2 * num20 * num9; float num26 = (num3 * num8 + 30f) * num23 + num3 * num20 * num9; num15 = Mathf.Lerp(num15, num24, num22); num16 = Mathf.Lerp(num16, num25, num22); num17 = Mathf.Lerp(num17, num26, num22); float num27 = Mathf.Clamp01(1f - Mathf.Abs(num13 - num21) / 2.2f) * 0.75f; num15 += num * num27; num16 += num2 * num27; num17 += num3 * num27; float num28 = num13 - 1235f; float num29 = num14 - 800f; float num30 = Mathf.Sqrt(num28 * num28 + num29 * num29); float num31 = (Mathf.Clamp01(1f - Mathf.Abs(num30 - 430f) / 1.6f) * 0.05f + Mathf.Clamp01(1f - Mathf.Abs(num30 - 560f) / 1.6f) * 0.032f) * (1f - num22) * 255f; num15 += num31; num16 += num31; num17 += num31; float num32 = (num12 - 0.5f) * 2f; float num33 = (num10 - 0.5f) * 2f; float num34 = 1f - 0.3f * (num32 * num32 * 0.5f + num33 * num33 * 0.5f); float num35 = (float)(random.NextDouble() * 2.4 - 1.2); num15 = num15 * num34 + num35; num16 = num16 * num34 + num35; num17 = num17 * num34 + num35; array[num11 + j] = new Color32(ToByte(num15), ToByte(num16), ToByte(num17), byte.MaxValue); } } Texture2D val = new Texture2D(600, 338, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; val.SetPixels32(array); val.Apply(); return val; } private static byte ToByte(float value) { return (byte)Mathf.Clamp(Mathf.RoundToInt(value), 0, 255); } } internal static class ClipboardImage { private const uint CfDib = 8u; private const uint GmemMoveable = 2u; [DllImport("user32.dll", SetLastError = true)] private static extern bool OpenClipboard(IntPtr owner); [DllImport("user32.dll", SetLastError = true)] private static extern bool CloseClipboard(); [DllImport("user32.dll", SetLastError = true)] private static extern bool EmptyClipboard(); [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr SetClipboardData(uint format, IntPtr data); [DllImport("kernel32.dll", SetLastError = true)] private static extern IntPtr GlobalAlloc(uint flags, UIntPtr bytes); [DllImport("kernel32.dll", SetLastError = true)] private static extern IntPtr GlobalLock(IntPtr memory); [DllImport("kernel32.dll", SetLastError = true)] private static extern bool GlobalUnlock(IntPtr memory); [DllImport("kernel32.dll", SetLastError = true)] private static extern IntPtr GlobalFree(IntPtr memory); public static bool TryCopy(Color32[] pixels, int width, int height) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00a8: Unknown result type (might be due to invalid IL or missing references) if ((int)Application.platform != 2 || pixels == null || pixels.Length != width * height) { return false; } try { int num = (width * 3 + 3) & -4; byte[] array = new byte[40 + num * height]; WriteInt(array, 0, 40); WriteInt(array, 4, width); WriteInt(array, 8, height); array[12] = 1; array[14] = 24; WriteInt(array, 20, num * height); for (int i = 0; i < height; i++) { int num2 = 40 + i * num; int num3 = i * width; for (int j = 0; j < width; j++) { Color32 val = pixels[num3 + j]; array[num2++] = val.b; array[num2++] = val.g; array[num2++] = val.r; } } IntPtr intPtr = GlobalAlloc(2u, (UIntPtr)(uint)array.Length); if (intPtr == IntPtr.Zero) { return false; } IntPtr intPtr2 = GlobalLock(intPtr); if (intPtr2 == IntPtr.Zero) { GlobalFree(intPtr); return false; } Marshal.Copy(array, 0, intPtr2, array.Length); GlobalUnlock(intPtr); if (!OpenClipboard(IntPtr.Zero)) { GlobalFree(intPtr); return false; } bool flag = false; try { EmptyClipboard(); flag = SetClipboardData(8u, intPtr) != IntPtr.Zero; } finally { CloseClipboard(); } if (!flag) { GlobalFree(intPtr); } return flag; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Clipboard copy failed: " + ex.Message)); return false; } } private static void WriteInt(byte[] buffer, int offset, int value) { buffer[offset] = (byte)value; buffer[offset + 1] = (byte)(value >> 8); buffer[offset + 2] = (byte)(value >> 16); buffer[offset + 3] = (byte)(value >> 24); } } internal static class OptionsMenu { public static void Register(string pluginFolder, ConfigEntry openKey, ConfigEntry copyToClipboard, ConfigEntry showButton, ConfigEntry showCredit, ConfigEntry scale, ConfigEntry outputFolder) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_010b: 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) ModSettingsManager.SetModDescription("Turns the run report into a shareable image. Open it on the run report screen, save it, paste it.", "soxzcorp.runcard", "RunCard"); ModSettingsManager.AddOption((BaseOption)new KeyBindOption(openKey), "soxzcorp.runcard", "RunCard"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(copyToClipboard), "soxzcorp.runcard", "RunCard"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(showButton), "soxzcorp.runcard", "RunCard"); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(showCredit), "soxzcorp.runcard", "RunCard"); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(scale, new StepSliderConfig { min = 1f, max = 2f, increment = 0.25f, FormatString = "{0:0.00}x" }), "soxzcorp.runcard", "RunCard"); ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(outputFolder), "soxzcorp.runcard", "RunCard"); try { string path = Path.Combine(pluginFolder, "icon.png"); if (File.Exists(path)) { Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (ImageConversion.LoadImage(val, File.ReadAllBytes(path))) { ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)), "soxzcorp.runcard", "RunCard"); } } } catch (Exception ex) { Plugin.Log.LogInfo((object)("No icon in the settings menu: " + ex.Message)); } } } [BepInPlugin("soxzcorp.runcard", "RunCard", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "soxzcorp.runcard"; public const string Name = "RunCard"; private const string RiskOfOptionsGuid = "com.rune580.riskofoptions"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static GameEndReportPanelController Panel; internal static DisplayData Data; private ConfigEntry openKey; private ConfigEntry copyToClipboard; private ConfigEntry showButton; private ConfigEntry showCredit; private ConfigEntry outputFolder; private ConfigEntry scale; private bool busy; private string status; private float statusUntil; private GameEndReportPanelController buttonPanel; private bool nativeButton; private GameObject preview; private TMP_Text previewStatus; private RectTransform saveButtonRect; private RectTransform closeButtonRect; private RectTransform openButtonRect; private GameObject overlay; private int lastUiOpenFrame = -100; private Texture2D cardTexture; private Color32[] cardPixels; private string cardName; private bool saved; private GUIStyle fallbackButtonStyle; private GUIStyle statusStyle; private static bool PanelOpen { get { if ((Object)(object)Panel != (Object)null && ((Behaviour)Panel).isActiveAndEnabled) { return Data.runReport != null; } return false; } } private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; openKey = ((BaseUnityPlugin)this).Config.Bind("General", "OpenKey", new KeyboardShortcut((KeyCode)290, Array.Empty()), "Key that opens the RunCard on the run report screen. Press it again in the preview to save."); copyToClipboard = ((BaseUnityPlugin)this).Config.Bind("General", "CopyToClipboard", true, "When saving, also copy the card to the clipboard so it can be pasted into Discord etc. (Windows only)."); showButton = ((BaseUnityPlugin)this).Config.Bind("General", "ShowButton", true, "Show an 'Open RunCard' button on the run report screen."); showCredit = ((BaseUnityPlugin)this).Config.Bind("General", "ShowCredit", true, "Show the small 'Made with RunCard' line in the bottom right corner of the card."); outputFolder = ((BaseUnityPlugin)this).Config.Bind("General", "OutputFolder", "", "Folder the PNG files are written to. Empty = Pictures/RunCard."); scale = ((BaseUnityPlugin)this).Config.Bind("General", "ImageScale", 1.5f, new ConfigDescription("Image sharpness. 1 = 1200x675, 1.5 = 1800x1013, 2 = 2400x1350. Higher is sharper and makes a larger file.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 2f), Array.Empty())); new Harmony("soxzcorp.runcard").PatchAll(typeof(Plugin).Assembly); RunTracker.Init(); if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { try { RegisterOptions(); } catch (Exception ex) { Log.LogWarning((object)("In-game settings unavailable, use the config file: " + ex.Message)); } } } [MethodImpl(MethodImplOptions.NoInlining)] private void RegisterOptions() { OptionsMenu.Register(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), openKey, copyToClipboard, showButton, showCredit, scale, outputFolder); } private bool CreateOpenButton(GameEndReportPanelController panel) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown if ((Object)(object)panel.continueButton == (Object)null) { return false; } if (!((Component)panel.continueButton).gameObject.activeInHierarchy) { return CreateOverlayButton(panel); } GameObject val = CloneButton(panel, ((Component)panel.continueButton).transform.parent, OpenText(), new UnityAction(OnOpenButton), besideContinue: true); if ((Object)(object)val == (Object)null) { return false; } openButtonRect = (RectTransform)val.transform; return val.activeInHierarchy; } private bool CreateOverlayButton(GameEndReportPanelController panel) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) DestroyOverlay(); overlay = ScreenLayer("RunCardButtonLayer", out var _); GameObject val = CloneButton(panel, overlay.transform, OpenText(), new UnityAction(OnOpenButton), besideContinue: false); if ((Object)(object)val == (Object)null) { DestroyOverlay(); return false; } RectTransform val2 = (RectTransform)((Component)panel.continueButton).transform; Rect rect2 = val2.rect; float num; if (!(((Rect)(ref rect2)).width > 60f)) { num = 300f; } else { rect2 = val2.rect; num = ((Rect)(ref rect2)).width; } float num2 = num; rect2 = val2.rect; float num3; if (!(((Rect)(ref rect2)).height > 20f)) { num3 = 52f; } else { rect2 = val2.rect; num3 = ((Rect)(ref rect2)).height; } float num4 = num3; RectTransform val3 = (RectTransform)val.transform; Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(1f, 0f); val3.pivot = val4; Vector2 anchorMin = (val3.anchorMax = val4); val3.anchorMin = anchorMin; val3.anchoredPosition = new Vector2(-48f, 48f); val3.sizeDelta = new Vector2(num2, num4); openButtonRect = val3; return true; } private static GameObject ScreenLayer(string name, out RectTransform rect) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_00b2: 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_00da: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); Canvas val2 = val.AddComponent(); val2.renderMode = (RenderMode)0; int num = 0; Canvas[] array = Object.FindObjectsOfType(); foreach (Canvas val3 in array) { if ((Object)(object)val3 != (Object)(object)val2 && val3.isRootCanvas && (int)val3.renderMode == 0 && ((Object)val3).name.IndexOf("cursor", StringComparison.OrdinalIgnoreCase) < 0) { num = Mathf.Max(num, val3.sortingOrder); } } val2.sortingOrder = Mathf.Min(num + 1, 32000); CanvasScaler obj = val.AddComponent(); obj.uiScaleMode = (ScaleMode)1; obj.referenceResolution = new Vector2(1920f, 1080f); obj.matchWidthOrHeight = 1f; val.AddComponent(); rect = (RectTransform)val.transform; return val; } private static float ScreenLayerWidth() { if (Screen.height <= 0) { return 1920f; } return 1080f * (float)Screen.width / (float)Screen.height; } private void DestroyOverlay() { if ((Object)(object)overlay != (Object)null) { Object.Destroy((Object)(object)overlay); overlay = null; openButtonRect = null; } } private void OnOpenButton() { lastUiOpenFrame = Time.frameCount; OnOpenPressed(); } private IEnumerator OpenUnlessUiHandledIt() { yield return null; if (Time.frameCount - lastUiOpenFrame > 2 && (Object)(object)preview == (Object)null && (Object)(object)cardTexture == (Object)null && !busy) { OnOpenPressed(); } } private void Update() { //IL_017f: 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) RunTracker.Poll(); if (!PanelOpen) { if ((Object)(object)cardTexture != (Object)null) { ClosePreview(); } if ((Object)(object)overlay != (Object)null) { DestroyOverlay(); buttonPanel = null; } return; } if ((Object)(object)overlay != (Object)null && overlay.activeSelf != ((Object)(object)preview == (Object)null)) { overlay.SetActive((Object)(object)preview == (Object)null); } if (showButton.Value && (Object)(object)buttonPanel != (Object)(object)Panel) { buttonPanel = Panel; nativeButton = false; openButtonRect = null; try { nativeButton = CreateOpenButton(Panel); } catch (Exception ex) { Log.LogWarning((object)("Could not add the in-game button, using the simple one: " + ex.Message)); } } if ((Object)(object)preview == (Object)null && (Object)(object)openButtonRect != (Object)null && Input.GetMouseButtonUp(0) && ((Component)openButtonRect).gameObject.activeInHierarchy && Hit(openButtonRect) && !busy) { ((MonoBehaviour)this).StartCoroutine(OpenUnlessUiHandledIt()); } if ((Object)(object)preview != (Object)null && Input.GetMouseButtonUp(0)) { if (Hit(saveButtonRect)) { Save(); } else if (Hit(closeButtonRect)) { ClosePreview(); return; } } KeyboardShortcut value = openKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { OnOpenPressed(); } else if ((Object)(object)cardTexture != (Object)null && Input.GetKeyDown((KeyCode)27)) { ClosePreview(); } } private string OpenText() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = openKey.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey != 0) { value = openKey.Value; return "Open RunCard (" + ((object)((KeyboardShortcut)(ref value)).MainKey/*cast due to .constrained prefix*/).ToString() + ")"; } return "Open RunCard"; } private void OnOpenPressed() { if (!busy && PanelOpen) { if ((Object)(object)cardTexture != (Object)null) { Save(); } else { ((MonoBehaviour)this).StartCoroutine(Open()); } } } private static GameObject CloneButton(GameEndReportPanelController panel, Transform parent, string text, UnityAction action, bool besideContinue) { //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)panel.continueButton == (Object)null) { return null; } GameObject gameObject = ((Component)panel.continueButton).gameObject; GameObject val = Object.Instantiate(gameObject, parent); ((Object)val).name = "RunCardButton"; HGGamepadInputEvent[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } TMP_Text val2 = null; LanguageTextMeshController[] componentsInChildren2 = val.GetComponentsInChildren(true); foreach (LanguageTextMeshController val3 in componentsInChildren2) { val3.token = text; if ((Object)(object)val2 == (Object)null) { val2 = ((Component)val3).GetComponent(); } } TMP_Text[] componentsInChildren3 = val.GetComponentsInChildren(true); TMP_Text[] array; if ((Object)(object)val2 == (Object)null) { array = componentsInChildren3; foreach (TMP_Text val4 in array) { if (((Component)val4).gameObject.activeSelf && ((Behaviour)val4).enabled) { val2 = val4; break; } } } array = componentsInChildren3; foreach (TMP_Text val5 in array) { if ((Object)(object)val5 == (Object)(object)val2) { val5.text = text; } else if ((Object)(object)((Component)val5).gameObject != (Object)(object)val) { ((Component)val5).gameObject.SetActive(false); } } Button component = val.GetComponent