using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using NukeLib.UI; using PluginConfig.API; using PluginConfig.API.Decorators; using PluginConfig.API.Fields; using TMPro; using Taberry.Cybergrind; using Taberry.NormalLevel; using Taberry.NormalLevel.Ranks; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Taberry")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+823288792f9eae973cb7ce907c0395d165fa838c")] [assembly: AssemblyProduct("Taberry")] [assembly: AssemblyTitle("Taberry")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Taberry { public static class ConfigManager { public enum RequirementType { Next, SRank } public enum DeadEnemyIconDisplayType { Cross, Hide } private static PluginConfigurator config; public static BoolField ShowByDefault; public static FloatField PanelScale; public static BoolField ToggleAnimation; public static BoolField ShowLevelName; public static BoolField ShowLevelDifficulty; public static BoolField ShowRankStats; public static BoolField ShowRequirements; public static EnumField RequirementStyle; public static BoolField ShowSecrets; public static BoolField ShowChallenge; public static BoolField ShowWave; public static BoolField ShowCGDifficulty; public static BoolField ShowEnemies; public static BoolField ShowTotalTime; public static BoolField ShowWaveTime; public static EnumField DeadEnemyDisplayType; public static void Initialize() { } static ConfigManager() { //IL_0048: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00f1: 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) //IL_0116: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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 //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Expected O, but got Unknown //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Expected O, but got Unknown //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Expected O, but got Unknown config = PluginConfigurator.Create("Taberry", "com.github.end-4.taberry"); string text = Path.Combine(Plugin.workingDir, "icon.png"); if (File.Exists(text)) { config.SetIconWithURL(text); } new ConfigHeader(config.rootPanel, "", 10); new ConfigHeader(config.rootPanel, "-- GENERAL --", 24); ShowByDefault = new BoolField(config.rootPanel, "Show by default", "showByDefault", true); PanelScale = new FloatField(config.rootPanel, "Panel scale", "panelScale", 1f); PanelScale.postValueChangeEvent += (PostFloatValueChangeEvent)delegate(float f) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) UIUtils.FindRecursive("Canvas/Level Stats Controller/").transform.localScale = f * Vector3.one; }; ToggleAnimation = new BoolField(config.rootPanel, "Toggle animation", "toggleAnimation", true); new ConfigHeader(config.rootPanel, "-- NORMAL LEVELS --", 24); ShowLevelName = new BoolField(config.rootPanel, "Show level name", "showLevelName", true); ShowLevelDifficulty = new BoolField(config.rootPanel, "Show difficulty", "showLevelDifficulty", true); ShowRankStats = new BoolField(config.rootPanel, "Show rank stats", "showRankStats", true); ShowRequirements = new BoolField(config.rootPanel, "Show rank requirements", "showRequirements", true); RequirementStyle = new EnumField(config.rootPanel, "Requirement style", "requirementStyle", RequirementType.Next); ShowSecrets = new BoolField(config.rootPanel, "Show secrets", "showSecrets", true); ShowChallenge = new BoolField(config.rootPanel, "Show challenge", "showChallenge", true); new ConfigHeader(config.rootPanel, "", 10); new ConfigHeader(config.rootPanel, "-- CYBER GRIND --", 24); ShowWave = new BoolField(config.rootPanel, "Show wave", "showWave", true); ShowCGDifficulty = new BoolField(config.rootPanel, "Show difficulty", "showCGDifficulty", true); ShowEnemies = new BoolField(config.rootPanel, "Show enemy icons", "showEnemies", true); ShowTotalTime = new BoolField(config.rootPanel, "Show total time", "showTotalTime", true); ShowWaveTime = new BoolField(config.rootPanel, "Show wave time", "showWaveTime", true); DeadEnemyDisplayType = new EnumField(config.rootPanel, "Dead enemy display type", "deadEnemyDisplayType", DeadEnemyIconDisplayType.Cross); } } internal static class DifficultyHelper { public static int difficulty => MonoSingleton.Instance.GetInt("difficulty", 0); public static string GetDifficultyName(int difficulty) { return difficulty switch { 0 => "Harmless", 1 => "Lenient", 2 => "Standard", 3 => "Violent", 4 => "Brutal", 5 => "ULTRAKILL Must Die", _ => "Unknown difficulty", }; } public static string GetDifficultyName() { return GetDifficultyName(difficulty); } } [BepInPlugin("com.github.end-4.taberry", "Taberry", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static Plugin Instance; internal static ManualLogSource Log; public static string workingPath = Assembly.GetExecutingAssembly().Location; public static string workingDir = Path.GetDirectoryName(workingPath); public const string PluginGUID = "com.github.end-4.taberry"; public const string PluginName = "Taberry"; public const string PluginVersion = "1.0.0"; internal static readonly string BundlePath = Path.Combine(workingDir, "assets", "taberry.bundle"); private void Awake() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Instance != (Object)null)) { Instance = this; Log = ((BaseUnityPlugin)this).Logger; ConfigManager.Initialize(); new Harmony("Taberry").PatchAll(); SceneManager.sceneLoaded += OnSceneLoaded; Log.LogInfo((object)"Taberry loaded"); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //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) GameObject val = UIUtils.FindRecursive("Canvas/Level Stats Controller/"); if ((Object)(object)val != (Object)null) { val.transform.localScale = ConfigManager.PanelScale.value * Vector3.one; } if (SceneHelper.CurrentScene == "Main Menu" || SceneHelper.CurrentScene == "uk_construct") { return; } if (SceneHelper.CurrentScene == "Endless") { CybergrindHandler.Setup(); return; } GameObject val2 = UIUtils.FindRecursive("Canvas/Level Stats Controller"); if (!((Object)(object)val2 == (Object)null) && val2.activeSelf) { NormalLevelHandler.Setup(); } } } public class TabEnabler : MonoBehaviour { public GameObject levelStats; private void Start() { levelStats.SetActive(ConfigManager.ShowByDefault.value); } private void Update() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!MonoSingleton.Instance.InputSource.Stats.WasPerformedThisFrame || !((Object)(object)levelStats != (Object)null)) { return; } SlideFadeToggleEffect val = levelStats.GetComponent(); if ((Object)(object)val == (Object)null && ConfigManager.ToggleAnimation.value) { val = levelStats.AddComponent(); val.hiddenOffset = new Vector2(0f, 30f); val.speed = 25f; val.OnExitComplete += delegate { levelStats.SetActive(false); }; } else if ((Object)(object)val != (Object)null && !ConfigManager.ToggleAnimation.value) { Object.Destroy((Object)(object)val); } if (!levelStats.activeSelf) { levelStats.SetActive(true); } else if ((Object)(object)val != (Object)null) { val.StartExit(); } else { levelStats.SetActive(false); } } } } namespace Taberry.NormalLevel { public class LevelMiscController : MonoBehaviour { private GameObject SecretsGroup; private GameObject Challenge; private GameObject ChallengeDone; private List SecretOrbs = new List(); private static StatsManager sman => MonoSingleton.Instance; private void Awake() { SecretsGroup = UIUtils.FindRecursive(((Component)this).gameObject, "Secrets/SecretOrbs"); Challenge = UIUtils.FindRecursive(((Component)this).gameObject, "Challenge"); ChallengeDone = UIUtils.FindRecursive(((Component)this).gameObject, "ChallengeDone"); } private void Start() { for (int i = 0; i < sman.secretObjects.Length; i++) { GameObject item = Object.Instantiate(NormalLevelHandler.SecretPrefab, SecretsGroup.transform); SecretOrbs.Add(item); } UpdateVisibilities(); NormalLevelHandler.UnfuckLayouts(); } public void UpdateVisibilities() { GameObject val = UIUtils.FindRecursive(((Component)this).gameObject, "Secrets"); UIUtils.FindRecursive(((Component)this).gameObject, "Secrets/SecretIcon").SetActive(SecretOrbs.Count > 0); val.SetActive(ConfigManager.ShowSecrets.value && SecretOrbs.Count > 0); UIUtils.FindRecursive(((Component)this).gameObject, "padder").SetActive(!val.activeSelf); } private void Update() { foreach (int prevSecret in sman.prevSecrets) { UIUtils.FindRecursive(SecretOrbs[prevSecret], "DoneMark").SetActive(true); } foreach (int newSecret in sman.newSecrets) { UIUtils.FindRecursive(SecretOrbs[newSecret], "DoneMark").SetActive(true); } if ((Object)(object)MonoSingleton.Instance != (Object)null && MonoSingleton.Instance.challengeDone && !MonoSingleton.Instance.challengeFailed) { Challenge.SetActive(false); ChallengeDone.SetActive(ConfigManager.ShowChallenge.value); } else { Challenge.SetActive(ConfigManager.ShowChallenge.value); ChallengeDone.SetActive(false); } } } public class LevelScoresController : MonoBehaviour { private GameObject TimeObj; private GameObject KillsObj; private GameObject StyleObj; private Image CircProgMaskImage; private Image CircProgBorderImage; private TextMeshProUGUI ValueTextComp; private TextMeshProUGUI RequirementTextComp; private static StatsManager sman => MonoSingleton.Instance; private Color RankColor(string formattedRankText) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Match match = Regex.Match(formattedRankText, "#([A-Fa-f0-9]{6})"); Color result = default(Color); if (match.Success && ColorUtility.TryParseHtmlString(match.Value, ref result)) { return result; } return Color.white; } private string FormatTime(float seconds) { float num = (int)seconds / 60; float num2 = seconds % 60f; return string.Format("{0}:{1}", num, num2.ToString("00.000")); } private void Awake() { TimeObj = UIUtils.FindRecursive(((Component)this).gameObject, "Time"); KillsObj = UIUtils.FindRecursive(((Component)this).gameObject, "Kills"); StyleObj = UIUtils.FindRecursive(((Component)this).gameObject, "Style"); } private void Start() { UpdateVisibilities(); NormalLevelHandler.UnfuckLayouts(); } internal void UpdateVisibilities() { UIUtils.FindRecursive(TimeObj, "RequirementText").SetActive(ConfigManager.ShowRequirements.value && !NormalLevelHandler.IsSecretLevel); UIUtils.FindRecursive(KillsObj, "RequirementText").SetActive(ConfigManager.ShowRequirements.value && !NormalLevelHandler.IsSecretLevel); UIUtils.FindRecursive(StyleObj, "RequirementText").SetActive(ConfigManager.ShowRequirements.value && !NormalLevelHandler.IsSecretLevel); if (NormalLevelHandler.IsSecretLevel) { UIUtils.FindRecursive(TimeObj, "CircProg/CircProgMask").SetActive(false); KillsObj.SetActive(false); StyleObj.SetActive(false); } } private void UpdateRank(GameObject targetObject, int[] ranks, float currentValue, bool reverse, Func valueToStringTransform = null) { //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (valueToStringTransform == null) { valueToStringTransform = (float f) => f.ToString(); } CircProgMaskImage = UIUtils.FindRecursive(targetObject, "CircProg/CircProgMask").GetComponent(); CircProgBorderImage = UIUtils.FindRecursive(targetObject, "CircProg/CircProgMask/CircProgBorder").GetComponent(); ValueTextComp = UIUtils.FindRecursive(targetObject, "ValueText").GetComponent(); RequirementTextComp = UIUtils.FindRecursive(targetObject, "RequirementText").GetComponent(); string text = valueToStringTransform(currentValue); ((TMP_Text)ValueTextComp).text = text; float num = (reverse ? ranks[0] : ranks[^1]); float num2 = currentValue / num; if (reverse) { num2 = 1f - num2; } CircProgMaskImage.fillAmount = num2; int rank = SingularRankHelper.GetRank(ranks, currentValue, reverse); Color color = default(Color); ColorUtility.TryParseHtmlString(SingularRankHelper.GetRankForegroundColor(rank), ref color); ((Graphic)CircProgBorderImage).color = color; int num3 = rank; switch (ConfigManager.RequirementStyle.value) { case ConfigManager.RequirementType.Next: num3 = SingularRankHelper.ClampRank(rank + ((!reverse) ? 1 : 0), ranks); break; case ConfigManager.RequirementType.SRank: num3 = ranks.Length; break; } int num4 = Math.Min(num3 - 1, ranks.Length - 1); float arg = ranks[num4]; string rankForegroundColor = SingularRankHelper.GetRankForegroundColor(num3); string text2 = valueToStringTransform(arg); ((TMP_Text)RequirementTextComp).text = "/" + text2 + ""; } private void Update() { UpdateRank(TimeObj, MonoSingleton.Instance.timeRanks, sman.seconds, reverse: true, FormatTime); UpdateRank(KillsObj, MonoSingleton.Instance.killRanks, sman.kills, reverse: false); UpdateRank(StyleObj, MonoSingleton.Instance.styleRanks, sman.stylePoints, reverse: false); } } public class LevelTitleController : MonoBehaviour { private GameObject SmallText; private GameObject BigText; internal void UpdateTitle() { string text = ""; MapInfo instance = MapInfo.Instance; StockMapInfo instance2 = StockMapInfo.Instance; text = ((MapInfoBase)(instance?)).levelName ?? instance2?.assets.LargeText ?? SceneHelper.CurrentScene ?? "???"; string text2 = ""; string text3 = ""; if (text.Contains(":")) { string[] array = text.Split(':'); text2 = array[0].Trim(); text3 = array[1].Trim(); } else { text2 = (SceneHelper.IsPlayingCustom ? "Custom level" : "Campaign"); text3 = ((text.Length > 0) ? text : SceneHelper.CurrentScene); } if (ConfigManager.ShowLevelDifficulty.value) { ((TMP_Text)SmallText.GetComponent()).text = DifficultyHelper.GetDifficultyName() + " > " + text2; } else { ((TMP_Text)SmallText.GetComponent()).text = text2; } ((TMP_Text)BigText.GetComponent()).text = text3; NormalLevelHandler.UnfuckLayouts(); } internal void UpdateTitle(bool _) { UpdateTitle(); } private void Awake() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown SmallText = UIUtils.FindRecursive(((Component)this).gameObject, "LevelInfoRow/Small"); BigText = UIUtils.FindRecursive(((Component)this).gameObject, "Main"); ConfigManager.ShowLevelDifficulty.postValueChangeEvent += new PostBoolValueChangeEvent(UpdateTitle); } private void Start() { UpdateTitle(); } private void OnDestroy() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown ConfigManager.ShowLevelDifficulty.postValueChangeEvent -= new PostBoolValueChangeEvent(UpdateTitle); } } internal static class NormalLevelHandler { internal static GameObject LevelStatsPrefab; internal static GameObject SecretPrefab; internal static bool IsSecretLevel; private static GameObject LevelStats; internal static GameObject LevelName; internal static GameObject LevelStatsColumn; internal static GameObject LevelMiscRow; static NormalLevelHandler() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown ConfigManager.ShowLevelName.postValueChangeEvent += new PostBoolValueChangeEvent(UpdateVisibilities); ConfigManager.ShowRankStats.postValueChangeEvent += new PostBoolValueChangeEvent(UpdateVisibilities); ConfigManager.ShowRequirements.postValueChangeEvent += new PostBoolValueChangeEvent(UpdateVisibilities); ConfigManager.ShowSecrets.postValueChangeEvent += new PostBoolValueChangeEvent(UpdateVisibilities); ConfigManager.ShowChallenge.postValueChangeEvent += new PostBoolValueChangeEvent(UpdateVisibilities); } private static void UpdateVisibilities(bool _) { UpdateVisibilities(); } private static void UpdateVisibilities() { if ((Object)(object)LevelName != (Object)null) { LevelName.SetActive(ConfigManager.ShowLevelName.value); } if ((Object)(object)LevelStatsColumn != (Object)null) { LevelStatsColumn.SetActive(ConfigManager.ShowRankStats.value); LevelStatsColumn.GetComponent().UpdateVisibilities(); } if ((Object)(object)LevelMiscRow != (Object)null) { LevelMiscRow.SetActive((ConfigManager.ShowSecrets.value || ConfigManager.ShowChallenge.value) && !IsSecretLevel); LevelMiscRow.GetComponent().UpdateVisibilities(); } LevelStats.SetActive(ConfigManager.ShowLevelName.value || ConfigManager.ShowRankStats.value || ConfigManager.ShowSecrets.value || ConfigManager.ShowChallenge.value); } public static void UnfuckLayouts() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)LevelStats.transform); } internal static void Setup() { GameObject val = UIUtils.FindRecursive("Canvas/Level Stats Controller"); GameObject obj = UIUtils.FindRecursive(val, "Level Stats (1)"); if ((Object)(object)LevelStatsPrefab == (Object)null || (Object)(object)SecretPrefab == (Object)null) { AssetBundle val2 = AssetBundle.LoadFromFile(Plugin.BundlePath); if ((Object)(object)LevelStatsPrefab == (Object)null) { LevelStatsPrefab = val2.LoadAsset("LevelStats"); } if ((Object)(object)SecretPrefab == (Object)null) { SecretPrefab = val2.LoadAsset("Secret"); } val2.Unload(false); } IsSecretLevel = Object.FindObjectOfType().secretLevel; Object.Destroy((Object)(object)obj); LevelStats = Object.Instantiate(LevelStatsPrefab, val.transform); LevelName = UIUtils.FindRecursive(LevelStats, "Name"); LevelStatsColumn = UIUtils.FindRecursive(LevelStats, "StatsColumn"); LevelMiscRow = UIUtils.FindRecursive(LevelStats, "MiscRow"); UnfuckLayouts(); Object.Destroy((Object)(object)val.GetComponent()); val.AddComponent().levelStats = LevelStats; LevelName.AddComponent(); LevelStatsColumn.AddComponent(); LevelMiscRow.AddComponent(); UpdateVisibilities(); } } } namespace Taberry.NormalLevel.Ranks { public static class SingularRankHelper { public static int GetRank(int[] ranksToCheck, float value, bool reverse) { int i; for (i = 0; i < ranksToCheck.Length && ((reverse && value <= (float)ranksToCheck[i]) || (!reverse && value >= (float)ranksToCheck[i])); i++) { } if (ranksToCheck != null && ranksToCheck.Length != 0) { return Mathf.Clamp(i, 0, ranksToCheck.Length); } return 0; } public static int ClampRank(int rank, int[] ranksToCheck) { return Mathf.Clamp(rank, 0, ranksToCheck.Length); } public static string GetRankForegroundColor(int rank) { return rank switch { 0 => "#0094FF", 1 => "#4CFF00", 2 => "#FFD800", 3 => "#FF6A00", 4 => "#FF0000", _ => "#FFFFFF", }; } } } namespace Taberry.Cybergrind { internal static class CybergrindHandler { internal enum EnemyCategory { Common, Uncommon, Special, Mass } internal record struct EnemyIconRecord(EnemyIdentifier Enemy, EnemyCategory Type, bool IsRadiant, GameObject IconObject) : IComparable { public bool Equals(EnemyIconRecord? other) { if (other.HasValue) { return (Object)(object)other.Value.Enemy == (Object)(object)Enemy; } return false; } public int CompareTo(EnemyIconRecord other) { int num = Type.CompareTo(other.Type); if (num != 0) { return num; } int num2 = MonoSingleton.Instance.GetEnemyRank(Enemy).CompareTo(MonoSingleton.Instance.GetEnemyRank(other.Enemy)); if (num2 != 0) { return num2; } int num3 = string.Compare(Enemy.FullName, other.Enemy.FullName, StringComparison.InvariantCultureIgnoreCase); if (num3 == 0) { return ((Object)Enemy).GetInstanceID().CompareTo(((Object)other.Enemy).GetInstanceID()); } return num3; } } internal static GameObject EnemyIconPrefab; internal static GameObject CGStatsPrefab; internal static GameObject CGStatsObject; internal static GameObject WaveProgress; internal static GameObject CGEnemies; internal static GameObject TimeGroup; internal static GameObject TotalTime; internal static GameObject ThisWaveTime; internal static SortedSet icons; static CybergrindHandler() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown icons = new SortedSet(); ConfigManager.ShowWave.postValueChangeEvent += new PostBoolValueChangeEvent(UpdateVisibilities); ConfigManager.ShowEnemies.postValueChangeEvent += new PostBoolValueChangeEvent(UpdateVisibilities); ConfigManager.ShowTotalTime.postValueChangeEvent += new PostBoolValueChangeEvent(UpdateVisibilities); ConfigManager.ShowWaveTime.postValueChangeEvent += new PostBoolValueChangeEvent(UpdateVisibilities); ConfigManager.ShowCGDifficulty.postValueChangeEvent += new PostBoolValueChangeEvent(UpdateVisibilities); } private static void UpdateVisibilities() { GameObject waveProgress = WaveProgress; if (waveProgress != null) { waveProgress.SetActive(ConfigManager.ShowWave.value); } GameObject cGEnemies = CGEnemies; if (cGEnemies != null) { cGEnemies.SetActive(ConfigManager.ShowEnemies.value && icons.Any((EnemyIconRecord icon) => icon.IconObject.activeSelf)); } GameObject totalTime = TotalTime; if (totalTime != null) { totalTime.SetActive(ConfigManager.ShowTotalTime.value); } GameObject thisWaveTime = ThisWaveTime; if (thisWaveTime != null) { thisWaveTime.SetActive(ConfigManager.ShowWaveTime.value); } GameObject timeGroup = TimeGroup; if (timeGroup != null) { timeGroup.SetActive(ConfigManager.ShowTotalTime.value || ConfigManager.ShowWaveTime.value); } GameObject cGStatsObject = CGStatsObject; if (cGStatsObject != null) { cGStatsObject.SetActive(WaveProgress.activeSelf || CGEnemies.activeSelf || TimeGroup.activeSelf); } GameObject cGStatsObject2 = CGStatsObject; if (cGStatsObject2 != null) { UIUtils.FindRecursive(cGStatsObject2, "Wave").GetComponent()?.UpdateVisibilities(); } } private static void UpdateVisibilities(bool _) { UpdateVisibilities(); } public static void Setup() { GameObject val = UIUtils.FindRecursive("Canvas/Level Stats Controller"); GameObject obj = UIUtils.FindRecursive(val, "Level Stats (1)"); if ((Object)(object)CGStatsPrefab == (Object)null || (Object)(object)EnemyIconPrefab == (Object)null) { AssetBundle val2 = AssetBundle.LoadFromFile(Plugin.BundlePath); if ((Object)(object)CGStatsPrefab == (Object)null) { CGStatsPrefab = val2.LoadAsset("CGStats"); } if ((Object)(object)EnemyIconPrefab == (Object)null) { EnemyIconPrefab = val2.LoadAsset("CGEnemy"); } val2.Unload(false); } Object.Destroy((Object)(object)obj); CGStatsObject = Object.Instantiate(CGStatsPrefab, val.transform); WaveProgress = UIUtils.FindRecursive(CGStatsObject, "Wave"); CGEnemies = UIUtils.FindRecursive(CGStatsObject, "Enemies"); TimeGroup = UIUtils.FindRecursive(CGStatsObject, "Time"); TotalTime = UIUtils.FindRecursive(TimeGroup, "Total"); ThisWaveTime = UIUtils.FindRecursive(TimeGroup, "ThisWave"); Object.Destroy((Object)(object)val.GetComponent()); val.AddComponent().levelStats = CGStatsObject; UIUtils.FindRecursive(CGStatsObject, "Wave").AddComponent(); UpdateVisibilities(); } public static void UnfuckEnemiesLayout() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (!((Object)(object)CGEnemies == (Object)null)) { LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)CGEnemies.transform); } } } [HarmonyPatch] internal static class CybergrindPatches { private static float lastSeconds; private static StatsManager sman => MonoSingleton.Instance; [HarmonyPatch(typeof(EndlessGrid), "SpawnOnGrid")] [HarmonyPostfix] private static void EndlessGrid_SpawnOnGrid(GameObject obj, bool radiant, GameObject __result, PrefabDatabase ___prefabs) { EnemyIdentifier val = ((__result != null) ? __result.GetComponentInChildren(true) : null); if (val != null) { GameObject val2 = Object.Instantiate(CybergrindHandler.EnemyIconPrefab, CybergrindHandler.CGEnemies.transform); UIUtils.FindRecursive(val2, "TypeIcon").AddComponent().enemyIdentifier = val; if (radiant) { UIUtils.FindRecursive(val2, "RadiantModifier").SetActive(true); } CybergrindHandler.EnemyCategory type = CybergrindHandler.EnemyCategory.Common; if (___prefabs.uncommonEnemies.Any((EndlessEnemy prefab) => (Object)(object)prefab.prefab == (Object)(object)obj)) { type = CybergrindHandler.EnemyCategory.Uncommon; } else if (___prefabs.specialEnemies.Any((EndlessEnemy prefab) => (Object)(object)prefab.prefab == (Object)(object)obj)) { type = CybergrindHandler.EnemyCategory.Special; } else if ((Object)(object)obj == (Object)(object)___prefabs.hideousMass) { type = CybergrindHandler.EnemyCategory.Mass; } CybergrindHandler.icons.Add(new CybergrindHandler.EnemyIconRecord(val, type, radiant, val2)); CollectionExtensions.Do((IEnumerable)CybergrindHandler.icons, (Action)delegate(CybergrindHandler.EnemyIconRecord icon2) { icon2.IconObject.transform.SetAsLastSibling(); }); CybergrindHandler.UnfuckEnemiesLayout(); } } [HarmonyPatch(typeof(EndlessGrid), "Update")] [HarmonyPostfix] private static void EndlessGrid_Update() { foreach (var (val3, _, active, val4) in CybergrindHandler.icons) { if (!Object.op_Implicit((Object)(object)val3)) { val4.SetActive(false); CybergrindHandler.UnfuckEnemiesLayout(); continue; } UIUtils.FindRecursive(val4, "RadiantModifier").gameObject.SetActive(active); UIUtils.FindRecursive(val4, "IdolModifier").gameObject.SetActive(val3.blessed); UIUtils.FindRecursive(val4, "Eliminated").SetActive(val3.dead); val4.SetActive(!val3.dead || ConfigManager.DeadEnemyDisplayType.value == ConfigManager.DeadEnemyIconDisplayType.Cross); CybergrindHandler.UnfuckEnemiesLayout(); } CybergrindHandler.CGEnemies.SetActive(ConfigManager.ShowEnemies.value && CybergrindHandler.icons.Any((CybergrindHandler.EnemyIconRecord icon) => icon.IconObject.activeSelf)); float seconds = sman.seconds; float num = sman.seconds - lastSeconds; float num2 = 0f; float num3 = 0f; num2 = (int)seconds / 60; num3 = (int)num / 60; seconds %= 60f; num %= 60f; CybergrindHandler.TotalTime.GetComponent().text = num2 + ":" + seconds.ToString("00.000"); CybergrindHandler.ThisWaveTime.GetComponent().text = "+ " + num3 + ":" + num.ToString("00.000"); } [HarmonyPatch(typeof(EndlessGrid), "NextWave")] [HarmonyPostfix] private static void EndlessGrid_NextWave() { CollectionExtensions.Do((IEnumerable)CybergrindHandler.icons, (Action)delegate(CybergrindHandler.EnemyIconRecord icon) { Object.Destroy((Object)(object)icon.IconObject); }); CybergrindHandler.icons.Clear(); lastSeconds = sman.seconds; } } public class WaveIndicatorController : MonoBehaviour { private TextMeshProUGUI WaveText; private GameObject DifficultyTextObj; private Image CircProgMask; private ActivateNextWave NextWaveObj; internal void UpdateVisibilities() { DifficultyTextObj.SetActive(ConfigManager.ShowCGDifficulty.value); } private void Start() { WaveText = UIUtils.FindRecursive(((Component)this).gameObject, "WaveNumber/NumberText").GetComponent(); DifficultyTextObj = UIUtils.FindRecursive(((Component)this).gameObject, "WaveNumber/Difficulty"); CircProgMask = UIUtils.FindRecursive(((Component)this).gameObject, "WaveCircularProgress").GetComponent(); NextWaveObj = Object.FindObjectOfType(); ((TMP_Text)DifficultyTextObj.GetComponent()).text = DifficultyHelper.GetDifficultyName(); UpdateVisibilities(); } private void Update() { ((TMP_Text)WaveText).text = MonoSingleton.Instance.currentWave.ToString(); float fillAmount = (float)NextWaveObj.deadEnemies / (float)MonoSingleton.Instance.enemyAmount; CircProgMask.fillAmount = fillAmount; } } }