Decompiled source of Cosmetics UI v1.0.1

plugins/CosmeticsUI.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using BepInEx.Logging;
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: AssemblyTitle("REPO Cosmetics Display")]
[assembly: AssemblyDescription("A BepInEx mod that displays unlocked cosmetics on the map screen")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPO Cosmetics Display")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("87654321-4321-4321-4321-210987654321")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace REPOCosmeticsDisplay;

public enum CosmeticRarity
{
	Common,
	Uncommon,
	Rare,
	Legendary
}
public class Cosmetic
{
	public string ID { get; set; }

	public string Name { get; set; }

	public CosmeticRarity Rarity { get; set; }

	public bool IsUnlocked { get; set; }

	public Texture2D Icon { get; set; }

	public Color GetRarityColor()
	{
		//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)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: 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)
		return (Color)(Rarity switch
		{
			CosmeticRarity.Common => Color.white, 
			CosmeticRarity.Uncommon => Color.green, 
			CosmeticRarity.Rare => Color.blue, 
			CosmeticRarity.Legendary => new Color(1f, 0.85f, 0f), 
			_ => Color.white, 
		});
	}

	public string GetRarityText()
	{
		return Rarity switch
		{
			CosmeticRarity.Common => "Common", 
			CosmeticRarity.Uncommon => "Uncommon", 
			CosmeticRarity.Rare => "Rare", 
			CosmeticRarity.Legendary => "Legendary", 
			_ => "Unknown", 
		};
	}
}
public class CosmeticsManager
{
	private Dictionary<CosmeticRarity, List<Cosmetic>> cosmeticsByRarity;

	private List<Cosmetic> allCosmetics;

	public CosmeticsManager()
	{
		cosmeticsByRarity = new Dictionary<CosmeticRarity, List<Cosmetic>>
		{
			{
				CosmeticRarity.Common,
				new List<Cosmetic>()
			},
			{
				CosmeticRarity.Uncommon,
				new List<Cosmetic>()
			},
			{
				CosmeticRarity.Rare,
				new List<Cosmetic>()
			},
			{
				CosmeticRarity.Legendary,
				new List<Cosmetic>()
			}
		};
		allCosmetics = new List<Cosmetic>();
		InitializeCosmetics();
	}

	private void InitializeCosmetics()
	{
		AddCosmetic(new Cosmetic
		{
			ID = "common_01",
			Name = "Basic Red",
			Rarity = CosmeticRarity.Common,
			IsUnlocked = true
		});
		AddCosmetic(new Cosmetic
		{
			ID = "common_02",
			Name = "Basic Blue",
			Rarity = CosmeticRarity.Common,
			IsUnlocked = true
		});
		AddCosmetic(new Cosmetic
		{
			ID = "uncommon_01",
			Name = "Shadow Camo",
			Rarity = CosmeticRarity.Uncommon,
			IsUnlocked = true
		});
		AddCosmetic(new Cosmetic
		{
			ID = "uncommon_02",
			Name = "Digital Camo",
			Rarity = CosmeticRarity.Uncommon,
			IsUnlocked = false
		});
		AddCosmetic(new Cosmetic
		{
			ID = "rare_01",
			Name = "Neon Spirit",
			Rarity = CosmeticRarity.Rare,
			IsUnlocked = true
		});
		AddCosmetic(new Cosmetic
		{
			ID = "rare_02",
			Name = "Arctic Frost",
			Rarity = CosmeticRarity.Rare,
			IsUnlocked = false
		});
		AddCosmetic(new Cosmetic
		{
			ID = "legendary_01",
			Name = "Golden Titan",
			Rarity = CosmeticRarity.Legendary,
			IsUnlocked = false
		});
		AddCosmetic(new Cosmetic
		{
			ID = "legendary_02",
			Name = "Void Master",
			Rarity = CosmeticRarity.Legendary,
			IsUnlocked = false
		});
	}

	public void AddCosmetic(Cosmetic cosmetic)
	{
		allCosmetics.Add(cosmetic);
		cosmeticsByRarity[cosmetic.Rarity].Add(cosmetic);
	}

	public List<Cosmetic> GetCosmeticsByRarity(CosmeticRarity rarity)
	{
		return new List<Cosmetic>(cosmeticsByRarity[rarity]);
	}

	public List<Cosmetic> GetUnlockedCosmetics()
	{
		List<Cosmetic> list = new List<Cosmetic>();
		foreach (Cosmetic allCosmetic in allCosmetics)
		{
			if (allCosmetic.IsUnlocked)
			{
				list.Add(allCosmetic);
			}
		}
		return list;
	}

	public List<Cosmetic> GetUnlockedCosmeticsByRarity(CosmeticRarity rarity)
	{
		List<Cosmetic> list = new List<Cosmetic>();
		foreach (Cosmetic item in cosmeticsByRarity[rarity])
		{
			if (item.IsUnlocked)
			{
				list.Add(item);
			}
		}
		return list;
	}

	public int GetTotalUnlockedCount()
	{
		return GetUnlockedCosmetics().Count;
	}

	public int GetTotalCount()
	{
		return allCosmetics.Count;
	}

	public Cosmetic GetCosmeticByID(string id)
	{
		return allCosmetics.Find((Cosmetic c) => c.ID == id);
	}

	public void UnlockCosmetic(string id)
	{
		Cosmetic cosmeticByID = GetCosmeticByID(id);
		if (cosmeticByID != null)
		{
			cosmeticByID.IsUnlocked = true;
		}
	}

	public void LockCosmetic(string id)
	{
		Cosmetic cosmeticByID = GetCosmeticByID(id);
		if (cosmeticByID != null)
		{
			cosmeticByID.IsUnlocked = false;
		}
	}
}
public class UIManager
{
	private CosmeticsManager cosmeticsManager;

	private bool isVisible = false;

	private Rect windowRect;

	private bool windowRectInitialized = false;

	private Vector2 scrollPosition = Vector2.zero;

	private bool stylesInitialized = false;

	private GUIStyle headerStyle;

	private GUIStyle rarityStyle;

	private const float WINDOW_WIDTH = 340f;

	private const float WINDOW_HEIGHT = 500f;

	private const float ITEM_HEIGHT = 50f;

	private const float HEADER_HEIGHT = 30f;

	public bool IsVisible => isVisible;

	public UIManager(CosmeticsManager manager)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		cosmeticsManager = manager;
	}

	private void InitializeStyles()
	{
		//IL_000c: 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_001a: 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_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//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_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: 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)
		//IL_0078: Expected O, but got Unknown
		//IL_007e: Expected O, but got Unknown
		GUIStyle val = new GUIStyle(GUI.skin.label)
		{
			fontSize = 16,
			fontStyle = (FontStyle)1,
			alignment = (TextAnchor)4
		};
		val.normal.textColor = Color.white;
		headerStyle = val;
		rarityStyle = new GUIStyle(GUI.skin.label)
		{
			fontSize = 13,
			fontStyle = (FontStyle)1,
			alignment = (TextAnchor)3,
			padding = new RectOffset(5, 5, 3, 3)
		};
	}

	public void Toggle()
	{
		isVisible = !isVisible;
	}

	public void SetVisible(bool visible)
	{
		isVisible = visible;
	}

	public void DrawUI()
	{
		//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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Expected O, but got Unknown
		//IL_00b1: 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)
		if (!isVisible)
		{
			return;
		}
		if (!stylesInitialized)
		{
			InitializeStyles();
			stylesInitialized = true;
		}
		if (!windowRectInitialized)
		{
			windowRect = new Rect((float)Screen.width - 340f - 10f, 100f, 340f, 500f);
			windowRectInitialized = true;
		}
		try
		{
			windowRect = GUILayout.Window(9842, windowRect, new WindowFunction(DrawCosmeticsWindow), "COSMETICS", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(340f),
				GUILayout.Height(500f)
			});
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("[REPOCosmetics] Error drawing UI: " + ex.Message + "\n" + ex.StackTrace));
		}
	}

	private void DrawCosmeticsWindow(int windowID)
	{
		//IL_0062: 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_007b: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Expected O, but got Unknown
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Unlocked: {cosmeticsManager.GetTotalUnlockedCount()} / {cosmeticsManager.GetTotalCount()}", headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) });
		GUILayout.Space(4f);
		scrollPosition = GUILayout.BeginScrollView(scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
		DrawCosmeticsByRarity(CosmeticRarity.Common);
		DrawCosmeticsByRarity(CosmeticRarity.Uncommon);
		DrawCosmeticsByRarity(CosmeticRarity.Rare);
		DrawCosmeticsByRarity(CosmeticRarity.Legendary);
		GUILayout.EndScrollView();
		GUILayout.Space(4f);
		GUILayout.Label("Hold Tab to view | Release to hide", new GUIStyle(GUI.skin.label)
		{
			fontSize = 10,
			alignment = (TextAnchor)4
		}, Array.Empty<GUILayoutOption>());
		GUILayout.EndVertical();
		GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
	}

	private void DrawCosmeticsByRarity(CosmeticRarity rarity)
	{
		//IL_0039: 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_003f: 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)
		List<Cosmetic> cosmeticsByRarity = cosmeticsManager.GetCosmeticsByRarity(rarity);
		if (cosmeticsByRarity.Count == 0)
		{
			return;
		}
		int count = cosmeticsManager.GetUnlockedCosmeticsByRarity(rarity).Count;
		Color rarityColor = cosmeticsByRarity[0].GetRarityColor();
		GUI.color = rarityColor;
		GUILayout.Label($"{cosmeticsByRarity[0].GetRarityText()}  ({count}/{cosmeticsByRarity.Count})", rarityStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(22f) });
		GUI.color = Color.white;
		foreach (Cosmetic item in cosmeticsByRarity)
		{
			DrawCosmeticItem(item);
		}
		GUILayout.Space(8f);
	}

	private void DrawCosmeticItem(Cosmetic cosmetic)
	{
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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_00c5: Expected O, but got Unknown
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//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_0066: Expected O, but got Unknown
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: 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_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Expected O, but got Unknown
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Expected O, but got Unknown
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(50f) });
		if (cosmetic.IsUnlocked)
		{
			GUI.color = cosmetic.GetRarityColor();
			GUILayout.Label("✓", new GUIStyle(GUI.skin.label)
			{
				fontSize = 18
			}, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(22f) });
			GUI.color = Color.white;
		}
		else
		{
			GUI.color = new Color(0.4f, 0.4f, 0.4f);
			GUILayout.Label("✗", new GUIStyle(GUI.skin.label)
			{
				fontSize = 18
			}, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(22f) });
			GUI.color = Color.white;
		}
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		Color textColor = (Color)(cosmetic.IsUnlocked ? Color.white : new Color(0.5f, 0.5f, 0.5f));
		string name = cosmetic.Name;
		GUIStyle val = new GUIStyle(GUI.skin.label)
		{
			fontSize = 12,
			fontStyle = (FontStyle)1
		};
		val.normal.textColor = textColor;
		GUILayout.Label(name, val, Array.Empty<GUILayoutOption>());
		string text = "ID: " + cosmetic.ID;
		GUIStyle val2 = new GUIStyle(GUI.skin.label)
		{
			fontSize = 9
		};
		val2.normal.textColor = new Color(0.6f, 0.6f, 0.6f);
		GUILayout.Label(text, val2, Array.Empty<GUILayoutOption>());
		GUILayout.EndVertical();
		GUILayout.EndHorizontal();
	}
}
[BepInPlugin("com.repo.cosmetics.display", "REPO Cosmetics Display", "1.0.0")]
public class REPOCosmeticsMod : BaseUnityPlugin
{
	public static REPOCosmeticsMod Instance;

	public static ManualLogSource Log;

	private readonly Harmony harmony = new Harmony("com.repo.cosmetics.display");

	public static GameObject TextInstance;

	public static TextMeshProUGUI CosmeticsText;

	private static bool _resolved = false;

	private static FieldInfo _fieldRarity = null;

	private static int _rarityCommon = -2;

	private static int _rarityUncommon = -2;

	private static int _rarityRare = -2;

	private static int _rarityUltraRare = -2;

	private static readonly Color ColCommon = new Color(0.4f, 0.9f, 0.4f, 1f);

	private static readonly Color ColUncommon = new Color(0.4f, 0.75f, 1f, 1f);

	private static readonly Color ColRare = new Color(0.72f, 0.4f, 1f, 1f);

	private static readonly Color ColUltraRare = new Color(1f, 0.85f, 0.2f, 1f);

	private static readonly Color ColDefault = new Color(0.79f, 0.91f, 0.9f, 1f);

	private static FieldInfo _fieldCosmeticAssets = null;

	private static FieldInfo _fieldCosmeticUnlocks = null;

	private static FieldInfo _metaManagerInstanceField = null;

	private void Awake()
	{
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"REPO Cosmetics Display loaded");
		harmony.PatchAll();
	}

	public static void ResolveReflection()
	{
		if (_resolved)
		{
			return;
		}
		_resolved = true;
		Assembly assembly = null;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2.GetName().Name == "Assembly-CSharp")
			{
				assembly = assembly2;
				break;
			}
		}
		if (assembly == null)
		{
			Log.LogWarning((object)"Assembly-CSharp not found");
			return;
		}
		Type[] types = assembly.GetTypes();
		foreach (Type type in types)
		{
			if (!(type.Name != "MetaManager"))
			{
				_fieldCosmeticAssets = type.GetField("cosmeticAssets", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_fieldCosmeticUnlocks = type.GetField("cosmeticUnlocks", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_metaManagerInstanceField = type.GetField("instance", BindingFlags.Static | BindingFlags.Public);
				break;
			}
		}
		Log.LogInfo((object)("MetaManager — cosmeticAssets=" + (_fieldCosmeticAssets != null) + "  cosmeticUnlocks=" + (_fieldCosmeticUnlocks != null) + "  instance=" + (_metaManagerInstanceField != null)));
		Type[] types2 = assembly.GetTypes();
		foreach (Type type2 in types2)
		{
			if (!(type2.Name != "CosmeticAsset"))
			{
				_fieldRarity = type2.GetField("rarity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				Log.LogInfo((object)("CosmeticAsset found — rarity field=" + (_fieldRarity != null)));
				break;
			}
		}
		if (_fieldRarity == null)
		{
			Log.LogWarning((object)"rarity field not found");
			return;
		}
		Type fieldType = _fieldRarity.FieldType;
		if (!fieldType.IsEnum)
		{
			return;
		}
		string[] names = Enum.GetNames(fieldType);
		Array values = Enum.GetValues(fieldType);
		for (int l = 0; l < names.Length; l++)
		{
			string text = names[l].ToLower();
			int num = (int)values.GetValue(l);
			if (text.Contains("ultra"))
			{
				_rarityUltraRare = num;
			}
			else if (text.Contains("rare"))
			{
				_rarityRare = num;
			}
			else if (text.Contains("uncommon"))
			{
				_rarityUncommon = num;
			}
			else if (text.Contains("common"))
			{
				_rarityCommon = num;
			}
		}
		Log.LogInfo((object)$"Rarity — Common:{_rarityCommon}  Uncommon:{_rarityUncommon}  Rare:{_rarityRare}  UltraRare:{_rarityUltraRare}");
	}

	public static void ReadCosmeticCounts(out int totalAll, out int ownedAll, out int ownedCommon, out int totalCommon, out int ownedUncommon, out int totalUncommon, out int ownedRare, out int totalRare, out int ownedUltra, out int totalUltra)
	{
		totalAll = (ownedAll = 0);
		ownedCommon = (totalCommon = 0);
		ownedUncommon = (totalUncommon = 0);
		ownedRare = (totalRare = 0);
		ownedUltra = (totalUltra = 0);
		if (_metaManagerInstanceField == null || _fieldCosmeticAssets == null || _fieldCosmeticUnlocks == null)
		{
			return;
		}
		try
		{
			object value = _metaManagerInstanceField.GetValue(null);
			if (value == null)
			{
				return;
			}
			IList list = _fieldCosmeticAssets.GetValue(value) as IList;
			IList list2 = _fieldCosmeticUnlocks.GetValue(value) as IList;
			if (list == null || list2 == null)
			{
				return;
			}
			HashSet<int> hashSet = new HashSet<int>();
			foreach (object item in list2)
			{
				hashSet.Add((int)item);
			}
			for (int i = 0; i < list.Count; i++)
			{
				object obj = list[i];
				if (obj == null)
				{
					continue;
				}
				int num = ((_fieldRarity != null) ? ((int)_fieldRarity.GetValue(obj)) : (-1));
				bool flag = hashSet.Contains(i);
				totalAll++;
				if (flag)
				{
					ownedAll++;
				}
				if (num == _rarityCommon)
				{
					totalCommon++;
					if (flag)
					{
						ownedCommon++;
					}
				}
				else if (num == _rarityUncommon)
				{
					totalUncommon++;
					if (flag)
					{
						ownedUncommon++;
					}
				}
				else if (num == _rarityRare)
				{
					totalRare++;
					if (flag)
					{
						ownedRare++;
					}
				}
				else if (num == _rarityUltraRare)
				{
					totalUltra++;
					if (flag)
					{
						ownedUltra++;
					}
				}
			}
		}
		catch (Exception ex)
		{
			Log.LogDebug((object)("CosmeticsDisplay read failed: " + ex.Message));
		}
	}

	public static string BuildHudText(int ownedAll, int totalAll, int ownedCommon, int totalCommon, int ownedUncommon, int totalUncommon, int ownedRare, int totalRare, int ownedUltra, int totalUltra)
	{
		//IL_000b: 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_007f: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
		string text = string.Format("<color={0}>Cosmetics: {1} / {2}</color>", "#" + ColorUtility.ToHtmlStringRGB(ColDefault), ownedAll, totalAll);
		List<string> list = new List<string>();
		if (totalCommon > 0)
		{
			list.Add(string.Format("<color={0}>{1}/{2}  ●</color>", "#" + ColorUtility.ToHtmlStringRGB(ColCommon), ownedCommon, totalCommon));
		}
		if (totalUncommon > 0)
		{
			list.Add(string.Format("<color={0}>{1}/{2}  ●</color>", "#" + ColorUtility.ToHtmlStringRGB(ColUncommon), ownedUncommon, totalUncommon));
		}
		if (totalRare > 0)
		{
			list.Add(string.Format("<color={0}>{1}/{2}  ●</color>", "#" + ColorUtility.ToHtmlStringRGB(ColRare), ownedRare, totalRare));
		}
		if (totalUltra > 0)
		{
			list.Add(string.Format("<color={0}>{1}/{2}   ●</color>", "#" + ColorUtility.ToHtmlStringRGB(ColUltraRare), ownedUltra, totalUltra));
		}
		return (list.Count > 0) ? (text + "\n" + string.Join("\n", list.ToArray())) : text;
	}

	public static bool EnsureUI()
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)TextInstance != (Object)null)
		{
			return true;
		}
		GameObject val = GameObject.Find("Game Hud");
		GameObject val2 = GameObject.Find("Tax Haul");
		if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
		{
			return false;
		}
		TMP_Text component = val2.GetComponent<TMP_Text>();
		TMP_FontAsset font = ((component != null) ? component.font : null);
		TextInstance = new GameObject("CosmeticsDisplay");
		TextInstance.transform.SetParent(val.transform, false);
		TextInstance.SetActive(false);
		CosmeticsText = TextInstance.AddComponent<TextMeshProUGUI>();
		((TMP_Text)CosmeticsText).font = font;
		((TMP_Text)CosmeticsText).fontSize = 15f;
		((Graphic)CosmeticsText).color = Color.white;
		((TMP_Text)CosmeticsText).alignment = (TextAlignmentOptions)260;
		((TMP_Text)CosmeticsText).richText = true;
		RectTransform component2 = TextInstance.GetComponent<RectTransform>();
		component2.anchorMin = new Vector2(1f, 1f);
		component2.anchorMax = new Vector2(1f, 1f);
		component2.pivot = new Vector2(1f, 1f);
		component2.anchoredPosition = new Vector2(-20f, -50f);
		component2.sizeDelta = new Vector2(320f, 400f);
		Log.LogInfo((object)"Cosmetics HUD text element created");
		return true;
	}
}
[HarmonyPatch(typeof(RoundDirector), "Update")]
public static class RoundDirectorUpdatePatch
{
	private static int _frameCounter;

	private const int RefreshEvery = 120;

	private static int _cachedTotalAll;

	private static int _cachedOwnedAll;

	private static int _cachedTotalCommon;

	private static int _cachedOwnedCommon;

	private static int _cachedTotalUncommon;

	private static int _cachedOwnedUncommon;

	private static int _cachedTotalRare;

	private static int _cachedOwnedRare;

	private static int _cachedTotalUltra;

	private static int _cachedOwnedUltra;

	[HarmonyPostfix]
	public static void Postfix()
	{
		if (!SemiFunc.InputHold((InputKey)8) && (!((Object)(object)MapToolController.instance != (Object)null) || !Traverse.Create((object)MapToolController.instance).Field("mapToggled").GetValue<bool>()))
		{
			if ((Object)(object)REPOCosmeticsMod.TextInstance != (Object)null)
			{
				REPOCosmeticsMod.TextInstance.SetActive(false);
			}
			return;
		}
		REPOCosmeticsMod.ResolveReflection();
		if (REPOCosmeticsMod.EnsureUI())
		{
			_frameCounter++;
			if (_frameCounter >= 120 || _cachedTotalAll == 0)
			{
				_frameCounter = 0;
				REPOCosmeticsMod.ReadCosmeticCounts(out _cachedTotalAll, out _cachedOwnedAll, out _cachedOwnedCommon, out _cachedTotalCommon, out _cachedOwnedUncommon, out _cachedTotalUncommon, out _cachedOwnedRare, out _cachedTotalRare, out _cachedOwnedUltra, out _cachedTotalUltra);
			}
			REPOCosmeticsMod.TextInstance.SetActive(true);
			((TMP_Text)REPOCosmeticsMod.CosmeticsText).SetText(REPOCosmeticsMod.BuildHudText(_cachedOwnedAll, _cachedTotalAll, _cachedOwnedCommon, _cachedTotalCommon, _cachedOwnedUncommon, _cachedTotalUncommon, _cachedOwnedRare, _cachedTotalRare, _cachedOwnedUltra, _cachedTotalUltra), true);
		}
	}
}