Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CosmeticBoxScanner Fixed v1.0.7
Cosmetics_Box_Scanner.dll
Decompiled 26 minutes agousing System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using Cosmetics_Box_Scanner.Models; using Cosmetics_Box_Scanner.Patches; using Cosmetics_Box_Scanner.Systems; using Cosmetics_Box_Scanner.UI; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("Cosmetics_Box_Scanner")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.7.0")] [assembly: AssemblyInformationalVersion("1.0.7")] [assembly: AssemblyProduct("Cosmetics_Box_Scanner")] [assembly: AssemblyTitle("Cosmetics_Box_Scanner")] [assembly: AssemblyVersion("1.0.7.0")] namespace Cosmetics_Box_Scanner { [BepInPlugin("cosmetic.scanner", "Cosmetic Scanner", "1.0.3")] public class Plugin : BaseUnityPlugin { internal static Plugin Instance; internal static ManualLogSource Log; public static bool ShowGUI; private Harmony harmony; public ScannerUI scannerUI; private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; harmony = new Harmony("cosmetic.scanner"); harmony.PatchAll(); Log.LogInfo((object)"Cosmetic Scanner Loaded"); } public void ToggleGUI() { if (scannerUI == null) { scannerUI = new ScannerUI(); scannerUI.Create(); Log.LogInfo((object)"UI CREATED"); } ShowGUI = !ShowGUI; scannerUI.SetVisible(ShowGUI); PlayerUpdatePatch.ResetTimer(); if (ShowGUI) { CosmeticScannerSystem.Scan(); scannerUI.Refresh(CosmeticScannerSystem.Stats, visible: true); scannerUI.ShowStatus("Cosmetic Overlay Enabled"); } else { scannerUI.Refresh(CosmeticScannerSystem.Stats, visible: false); scannerUI.ShowStatus("Cosmetic Overlay Disabled"); } } } } namespace Cosmetics_Box_Scanner.UI { internal class RarityRowFactory { public static GameObject CreateRarityRow(Transform parent, string spriteName, out TextMeshProUGUI textComponent, int index, int rowSpacing = 65) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0083: 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) //IL_0099: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0119: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(spriteName); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(1f, 1f); val2.pivot = new Vector2(0.5f, 1f); val2.anchoredPosition = new Vector2(0f, (float)(-15 - index * rowSpacing)); val2.sizeDelta = new Vector2(0f, 36f); GameObject val3 = new GameObject("Icon"); val3.transform.SetParent(val.transform, false); Image val4 = val3.AddComponent<Image>(); val4.sprite = AssetLoader.Load(spriteName); RectTransform component = ((Component)val4).GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 0.5f); component.anchorMax = new Vector2(0f, 0.5f); component.pivot = new Vector2(0f, 0.5f); component.anchoredPosition = new Vector2(15f, 0f); component.sizeDelta = new Vector2(55f, 55f); GameObject val5 = new GameObject("Count"); val5.transform.SetParent(val.transform, false); textComponent = val5.AddComponent<TextMeshProUGUI>(); ((TMP_Text)textComponent).fontSize = 24f; ((Graphic)textComponent).color = Color.white; ((TMP_Text)textComponent).enableWordWrapping = false; RectTransform component2 = ((Component)textComponent).GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 0f); component2.anchorMax = new Vector2(1f, 1f); component2.offsetMin = new Vector2(85f, 0f); component2.offsetMax = Vector2.zero; return val; } } public class ScannerUI { private GameObject canvasObject; private GameObject panelObject; private GameObject commonRow; private GameObject uncommonRow; private GameObject rareRow; private GameObject ultraRow; private TextMeshProUGUI commonText; private TextMeshProUGUI uncommonText; private TextMeshProUGUI rareText; private TextMeshProUGUI ultraText; private TextMeshProUGUI statusText; private float statusTimer; public void Create() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)canvasObject != (Object)null)) { canvasObject = new GameObject("CosmeticScannerCanvas"); Object.DontDestroyOnLoad((Object)(object)canvasObject); Canvas val = canvasObject.AddComponent<Canvas>(); val.renderMode = (RenderMode)0; val.sortingOrder = 9999; canvasObject.AddComponent<CanvasScaler>(); canvasObject.AddComponent<GraphicRaycaster>(); panelObject = new GameObject("Panel"); panelObject.transform.SetParent(canvasObject.transform, false); Image val2 = panelObject.AddComponent<Image>(); ((Graphic)val2).color = new Color(0f, 0f, 0f, 0.45f); RectTransform component = panelObject.GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 0f); component.pivot = new Vector2(1f, 0f); component.anchoredPosition = new Vector2(-20f, 20f); component.sizeDelta = new Vector2(240f, 320f); commonRow = RarityRowFactory.CreateRarityRow(panelObject.transform, "transparent_bg_common.png", out commonText, 0); uncommonRow = RarityRowFactory.CreateRarityRow(panelObject.transform, "transparent_bg_uncommon.png", out uncommonText, 1); rareRow = RarityRowFactory.CreateRarityRow(panelObject.transform, "transparent_bg_rare.png", out rareText, 2); ultraRow = RarityRowFactory.CreateRarityRow(panelObject.transform, "transparent_bg_ultrarare.png", out ultraText, 3); GameObject val3 = new GameObject("StatusText"); val3.transform.SetParent(canvasObject.transform, false); statusText = val3.AddComponent<TextMeshProUGUI>(); ((TMP_Text)statusText).fontSize = 28f; ((Graphic)statusText).color = Color.white; ((TMP_Text)statusText).alignment = (TextAlignmentOptions)514; RectTransform component2 = ((Component)statusText).GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0.5f, 0.1f); component2.anchorMax = new Vector2(0.5f, 0.1f); component2.pivot = new Vector2(0.5f, 0.5f); component2.sizeDelta = new Vector2(600f, 80f); ((Component)statusText).gameObject.SetActive(false); canvasObject.SetActive(true); panelObject.SetActive(false); } } public void Refresh(CosmeticStats stats, bool visible) { if (!((Object)(object)commonText == (Object)null)) { commonRow.SetActive(stats.Common > 0); uncommonRow.SetActive(stats.Uncommon > 0); rareRow.SetActive(stats.Rare > 0); ultraRow.SetActive(stats.UltraRare > 0); ((TMP_Text)commonText).text = stats.Common.ToString(); ((TMP_Text)uncommonText).text = stats.Uncommon.ToString(); ((TMP_Text)rareText).text = stats.Rare.ToString(); ((TMP_Text)ultraText).text = stats.UltraRare.ToString(); bool flag = stats.Common > 0 || stats.Uncommon > 0 || stats.Rare > 0 || stats.UltraRare > 0; if ((Object)(object)panelObject != (Object)null) { panelObject.SetActive(visible && flag); } } } public void ShowStatus(string message) { if (!((Object)(object)statusText == (Object)null)) { ((TMP_Text)statusText).text = message; ((Component)statusText).gameObject.SetActive(true); statusTimer = 2f; } } public void Tick() { if (statusTimer > 0f) { statusTimer -= Time.deltaTime; if (statusTimer <= 0f) { ((Component)statusText).gameObject.SetActive(false); } } } public void SetVisible(bool visible) { if ((Object)(object)panelObject != (Object)null) { panelObject.SetActive(visible); } if (!visible && (Object)(object)statusText != (Object)null) { ((Component)statusText).gameObject.SetActive(false); } } } } namespace Cosmetics_Box_Scanner.Systems { public static class AssetLoader { public static Sprite Load(string fileName) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location), fileName); if (!File.Exists(text)) { Plugin.Log.LogError((object)("SPRITE NOT FOUND: " + text)); return null; } byte[] array = File.ReadAllBytes(text); Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, array); ((Texture)val).filterMode = (FilterMode)0; return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } public static class CosmeticScannerSystem { public static CosmeticStats Stats = new CosmeticStats(); public static void Scan() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0062: Expected I4, but got Unknown CosmeticWorldObject[] array = Object.FindObjectsOfType<CosmeticWorldObject>(); Stats.Common = 0; Stats.Uncommon = 0; Stats.Rare = 0; Stats.UltraRare = 0; CosmeticWorldObject[] array2 = array; foreach (CosmeticWorldObject val in array2) { Rarity rarity = val.rarity; Rarity val2 = rarity; switch ((int)val2) { case 0: Stats.Common++; break; case 1: Stats.Uncommon++; break; case 2: Stats.Rare++; break; case 3: Stats.UltraRare++; break; } } } } } namespace Cosmetics_Box_Scanner.Patches { [HarmonyPatch(typeof(PlayerAvatar))] [HarmonyPatch("Update")] public class PlayerUpdatePatch { private static float scanTimer; private static bool debugMode; public static void ResetTimer() { scanTimer = 0f; } private static void Postfix() { Plugin.Instance.scannerUI?.Tick(); if (Input.GetKeyDown((KeyCode)287)) { Plugin.Instance.ToggleGUI(); } if ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) && Input.GetKeyDown((KeyCode)288)) { debugMode = !debugMode; if (debugMode) { Plugin.Instance.scannerUI.Refresh(CosmeticStats.CreateDebugStats(), visible: true); } else { CosmeticScannerSystem.Scan(); Plugin.Instance.scannerUI.Refresh(CosmeticScannerSystem.Stats, Plugin.ShowGUI); } } if (Plugin.ShowGUI && !debugMode) { scanTimer += Time.deltaTime; if (scanTimer >= 2f) { scanTimer = 0f; CosmeticScannerSystem.Scan(); Plugin.Instance.scannerUI.Refresh(CosmeticScannerSystem.Stats, visible: true); } } } } } namespace Cosmetics_Box_Scanner.Models { public class CosmeticStats { public int Common; public int Uncommon; public int Rare; public int UltraRare; public static CosmeticStats CreateDebugStats() { return new CosmeticStats { Common = 3, Uncommon = 2, Rare = 3, UltraRare = 1 }; } } }