Decompiled source of QuickCustomizer v4.0.0

QuickCustomizer.dll

Decompiled 19 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("QuickCustomizer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyInformationalVersion("4.0.0")]
[assembly: AssemblyProduct("QuickCustomizer")]
[assembly: AssemblyTitle("QuickCustomizer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.0.0.0")]
[module: UnverifiableCode]
namespace QuickCustomizer;

public class CustomizerUIComponent : MonoBehaviour
{
	public static bool showMenu = false;

	private static bool showWelcomeBanner = true;

	private static int selectedTab = 0;

	private static readonly string[] tabNames = new string[7] { "Colors", "Hats", "Visors", "Skins", "Pets", "Nameplates", "Profile" };

	private static Vector2 scrollPos = Vector2.zero;

	private static bool pendingWelcomeChat = false;

	private static float chatRetryTimer = 0f;

	private static int chatRetryCount = 0;

	private static List<string> unlockedHats = new List<string>();

	private static List<string> unlockedVisors = new List<string>();

	private static List<string> unlockedSkins = new List<string>();

	private static List<string> unlockedPets = new List<string>();

	private static List<string> unlockedNamePlates = new List<string>();

	public CustomizerUIComponent(IntPtr ptr)
		: base(ptr)
	{
	}

	private void Update()
	{
		if (Input.GetKeyDown((KeyCode)282))
		{
			showMenu = !showMenu;
			if (showMenu)
			{
				CacheCosmetics();
			}
		}
		if (pendingWelcomeChat)
		{
			chatRetryTimer -= Time.deltaTime;
			if (chatRetryTimer <= 0f)
			{
				chatRetryTimer = 0.5f;
				chatRetryCount++;
				if (SendWelcomeToChat() || chatRetryCount > 15)
				{
					pendingWelcomeChat = false;
				}
			}
		}
		FixFortegreenHand();
	}

	private static void FixFortegreenHand()
	{
		//IL_007f: 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_00b3: 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)
		try
		{
			if (!((Object)(object)PlayerControl.LocalPlayer != (Object)null) || !((Object)(object)PlayerControl.LocalPlayer.Data != (Object)null))
			{
				return;
			}
			byte b = (byte)PlayerControl.LocalPlayer.Data.DefaultOutfit.ColorId;
			if (b != 18 && b <= 18)
			{
				return;
			}
			foreach (SpriteRenderer item in Object.FindObjectsOfType<SpriteRenderer>())
			{
				if ((Object)(object)item != (Object)null && ((Object)((Component)item).gameObject).name.IndexOf("hand", StringComparison.OrdinalIgnoreCase) >= 0 && item.color.r > 0.7f && item.color.g < 0.3f)
				{
					item.color = new Color(0.1f, 0.55f, 0.27f, item.color.a);
				}
			}
		}
		catch
		{
		}
	}

	public static void ResetWelcomeBanner()
	{
		showWelcomeBanner = true;
		pendingWelcomeChat = true;
		chatRetryTimer = 0.5f;
		chatRetryCount = 0;
	}

	public static bool SendWelcomeToChat()
	{
		try
		{
			string text = "[QuickCustomizer] Press F1 for menu. Chat commands: /color, /name, /hat, /visor, /skin, /pet, /blank, /random, /help";
			if ((Object)(object)DestroyableSingleton<HudManager>.Instance != (Object)null && (Object)(object)DestroyableSingleton<HudManager>.Instance.Chat != (Object)null && (Object)(object)PlayerControl.LocalPlayer != (Object)null)
			{
				DestroyableSingleton<HudManager>.Instance.Chat.AddChat(PlayerControl.LocalPlayer, text, true);
				return true;
			}
		}
		catch
		{
		}
		return false;
	}

	private static void CacheCosmetics()
	{
		try
		{
			unlockedHats.Clear();
			unlockedVisors.Clear();
			unlockedSkins.Clear();
			unlockedPets.Clear();
			unlockedNamePlates.Clear();
			if (!((Object)(object)DestroyableSingleton<HatManager>.Instance != (Object)null))
			{
				return;
			}
			Il2CppReferenceArray<HatData> val = DestroyableSingleton<HatManager>.Instance.GetUnlockedHats();
			if (val != null)
			{
				foreach (HatData item in (Il2CppArrayBase<HatData>)(object)val)
				{
					if ((Object)(object)item != (Object)null)
					{
						unlockedHats.Add(((CosmeticData)item).ProductId);
					}
				}
			}
			Il2CppReferenceArray<VisorData> val2 = DestroyableSingleton<HatManager>.Instance.GetUnlockedVisors();
			if (val2 != null)
			{
				foreach (VisorData item2 in (Il2CppArrayBase<VisorData>)(object)val2)
				{
					if ((Object)(object)item2 != (Object)null)
					{
						unlockedVisors.Add(((CosmeticData)item2).ProductId);
					}
				}
			}
			Il2CppReferenceArray<SkinData> val3 = DestroyableSingleton<HatManager>.Instance.GetUnlockedSkins();
			if (val3 != null)
			{
				foreach (SkinData item3 in (Il2CppArrayBase<SkinData>)(object)val3)
				{
					if ((Object)(object)item3 != (Object)null)
					{
						unlockedSkins.Add(((CosmeticData)item3).ProductId);
					}
				}
			}
			Il2CppReferenceArray<PetData> val4 = DestroyableSingleton<HatManager>.Instance.GetUnlockedPets();
			if (val4 != null)
			{
				foreach (PetData item4 in (Il2CppArrayBase<PetData>)(object)val4)
				{
					if ((Object)(object)item4 != (Object)null)
					{
						unlockedPets.Add(((CosmeticData)item4).ProductId);
					}
				}
			}
			try
			{
				Il2CppReferenceArray<NamePlateData> val5 = DestroyableSingleton<HatManager>.Instance.GetUnlockedNamePlates();
				if (val5 == null)
				{
					return;
				}
				foreach (NamePlateData item5 in (Il2CppArrayBase<NamePlateData>)(object)val5)
				{
					if ((Object)(object)item5 != (Object)null)
					{
						unlockedNamePlates.Add(((CosmeticData)item5).ProductId);
					}
				}
			}
			catch
			{
			}
		}
		catch
		{
		}
	}

	private void OnGUI()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0685: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_0656: Unknown result type (might be due to invalid IL or missing references)
		//IL_0519: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
		GUI.Label(new Rect(20f, 20f, 1000f, 40f), "<size=14><color=yellow>[QuickCustomizer] Press 'F1' for Wardrobe | Use /color, /name, /hat, /visor, /skin, /pet, /blank, /random</color></size>");
		if (showWelcomeBanner && (Object)(object)PlayerControl.LocalPlayer != (Object)null)
		{
			Rect val = default(Rect);
			((Rect)(ref val))..ctor((float)Screen.width / 2f - 250f, (float)Screen.height / 2f - 140f, 500f, 280f);
			GUI.Box(val, "Welcome to QuickCustomizer!");
			GUI.BeginGroup(new Rect(((Rect)(ref val)).x + 20f, ((Rect)(ref val)).y + 35f, ((Rect)(ref val)).width - 40f, ((Rect)(ref val)).height - 45f));
			GUI.Label(new Rect(0f, 5f, 460f, 160f), "<b>You're running QuickCustomizer!</b>\n\n• Press <b><color=yellow>F1</color></b> anytime for the wardrobe menu.\n• Chat commands: <color=cyan>/color</color>, <color=cyan>/name</color>, <color=cyan>/hat</color>, <color=cyan>/visor</color>, <color=cyan>/skin</color>, <color=cyan>/pet</color>, <color=cyan>/blank</color>, <color=cyan>/random</color>\n• Fortegreen hand fix & blank name support active!");
			if (GUI.Button(new Rect(130f, 185f, 200f, 35f), "Got it, let's play!"))
			{
				showWelcomeBanner = false;
			}
			GUI.EndGroup();
		}
		if (!showMenu)
		{
			return;
		}
		Rect val2 = default(Rect);
		((Rect)(ref val2))..ctor(150f, 130f, 540f, 460f);
		GUI.Box(val2, "Wardrobe Customizer [QuickCustomizer]");
		if ((Object)(object)PlayerControl.LocalPlayer == (Object)null)
		{
			GUI.BeginGroup(new Rect(((Rect)(ref val2)).x + 10f, ((Rect)(ref val2)).y + 25f, ((Rect)(ref val2)).width - 20f, ((Rect)(ref val2)).height - 35f));
			GUI.Label(new Rect(10f, 60f, 500f, 50f), "<color=red><b>Please join a Lobby or Freeplay game first!</b>\nCosmetics and name customization require an active player instance.</color>");
			if (GUI.Button(new Rect(10f, ((Rect)(ref val2)).height - 75f, ((Rect)(ref val2)).width - 40f, 32f), "Close Menu"))
			{
				showMenu = false;
			}
			GUI.EndGroup();
			return;
		}
		GUI.BeginGroup(new Rect(((Rect)(ref val2)).x + 10f, ((Rect)(ref val2)).y + 25f, ((Rect)(ref val2)).width - 20f, ((Rect)(ref val2)).height - 35f));
		try
		{
			float num = (((Rect)(ref val2)).width - 20f) / 7f;
			for (int i = 0; i < tabNames.Length; i++)
			{
				if (GUI.Button(new Rect((float)i * num, 10f, num - 2f, 30f), tabNames[i]))
				{
					selectedTab = i;
					scrollPos = Vector2.zero;
				}
			}
			float num2 = 55f;
			float num3 = 310f;
			float num4 = ((Rect)(ref val2)).width - 25f;
			scrollPos = GUI.BeginScrollView(new Rect(0f, num2, num4, num3), scrollPos, new Rect(0f, 0f, num4 - 20f, GetContentHeight()));
			if (selectedTab == 0)
			{
				GUI.Label(new Rect(0f, 0f, 400f, 25f), "Select Color ID (0 - 18) [18 = Fortegreen, /color 31 for Fortegreen]:");
				int num5 = 6;
				for (int j = 0; j < 19; j += num5)
				{
					for (int k = 0; k < num5; k++)
					{
						int num6 = j + k;
						if (num6 < 19)
						{
							float num7 = k * 72;
							float num8 = 30 + j / num5 * 35;
							string text = ((num6 == 18) ? "Fortegreen" : $"Color {num6}");
							if (GUI.Button(new Rect(num7, num8, 68f, 30f), text))
							{
								CustomizerLogic.SetColor((byte)num6);
								PlayerPrefs.SetInt("QC_SavedColor", num6);
								PlayerPrefs.Save();
							}
						}
					}
				}
			}
			else if (selectedTab == 1)
			{
				DrawItemGrid(unlockedHats, "Hat", delegate(string id)
				{
					PlayerControl localPlayer = PlayerControl.LocalPlayer;
					if (localPlayer != null)
					{
						localPlayer.SetHat(id, 0);
					}
					PlayerPrefs.SetString("QC_SavedHat", id);
					PlayerPrefs.Save();
				});
			}
			else if (selectedTab == 2)
			{
				DrawItemGrid(unlockedVisors, "Visor", delegate(string id)
				{
					PlayerControl localPlayer = PlayerControl.LocalPlayer;
					if (localPlayer != null)
					{
						localPlayer.SetVisor(id, 0);
					}
					PlayerPrefs.SetString("QC_SavedVisor", id);
					PlayerPrefs.Save();
				});
			}
			else if (selectedTab == 3)
			{
				DrawItemGrid(unlockedSkins, "Skin", delegate(string id)
				{
					PlayerControl localPlayer = PlayerControl.LocalPlayer;
					if (localPlayer != null)
					{
						localPlayer.SetSkin(id, 0);
					}
					PlayerPrefs.SetString("QC_SavedSkin", id);
					PlayerPrefs.Save();
				});
			}
			else if (selectedTab == 4)
			{
				DrawItemGrid(unlockedPets, "Pet", delegate(string id)
				{
					PlayerControl localPlayer = PlayerControl.LocalPlayer;
					if (localPlayer != null)
					{
						localPlayer.SetPet(id, 0);
					}
					PlayerPrefs.SetString("QC_SavedPet", id);
					PlayerPrefs.Save();
				});
			}
			else if (selectedTab == 5)
			{
				DrawItemGrid(unlockedNamePlates, "Nameplate", delegate(string id)
				{
					CustomizerLogic.SetNamePlate(id);
					PlayerPrefs.SetString("QC_SavedNamePlate", id);
					PlayerPrefs.Save();
				});
			}
			else if (selectedTab == 6)
			{
				GUI.Label(new Rect(0f, 0f, 400f, 25f), "<b>Choose Display Name:</b>");
				string[] array = new string[11]
				{
					"SuperMarioTime", "SMT", "Crewmate", "Impostor", "Player", "Pro", "Guest", "Host", "Sus", "Blank",
					"???"
				};
				int num9 = 3;
				float num10 = 145f;
				float num11 = 35f;
				float num12 = 10f;
				float num13 = 8f;
				for (int num14 = 0; num14 < array.Length; num14++)
				{
					int num15 = num14 / num9;
					float num16 = (float)(num14 % num9) * (num10 + num12);
					float num17 = 32f + (float)num15 * (num11 + num13);
					string text2 = array[num14];
					string text3 = ((text2 == "Blank") ? "ㅤ" : text2);
					if (GUI.Button(new Rect(num16, num17, num10, num11), text2))
					{
						CustomizerLogic.SetName(text3);
						PlayerPrefs.SetString("QC_SavedName", text3);
						PlayerPrefs.Save();
					}
				}
			}
			GUI.EndScrollView();
			if (GUI.Button(new Rect(10f, ((Rect)(ref val2)).height - 75f, ((Rect)(ref val2)).width - 40f, 32f), "Close Menu"))
			{
				showMenu = false;
			}
		}
		catch (Exception ex)
		{
			GUI.Label(new Rect(10f, 60f, 400f, 100f), "UI Error: " + ex.Message);
		}
		GUI.EndGroup();
	}

	private static float GetContentHeight()
	{
		if (selectedTab == 0)
		{
			return 220f;
		}
		if (selectedTab == 6)
		{
			return 280f;
		}
		int num = Mathf.CeilToInt((float)(((selectedTab == 1) ? unlockedHats : ((selectedTab == 2) ? unlockedVisors : ((selectedTab == 3) ? unlockedSkins : ((selectedTab == 4) ? unlockedPets : unlockedNamePlates))))?.Count ?? 0) / 3f);
		return Mathf.Max(300, num * 38 + 40);
	}

	private static void DrawItemGrid(List<string> items, string labelName, Action<string> equipAction)
	{
		//IL_0014: 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_0119: Unknown result type (might be due to invalid IL or missing references)
		GUI.Label(new Rect(0f, 0f, 400f, 25f), $"Select Unlocked {labelName} ({items.Count}):");
		if (items == null || items.Count == 0)
		{
			GUI.Label(new Rect(0f, 35f, 400f, 25f), "No unlocked " + labelName.ToLower() + "s found.");
			return;
		}
		int num = 3;
		float num2 = 150f;
		float num3 = 32f;
		float num4 = 10f;
		float num5 = 6f;
		for (int i = 0; i < items.Count; i++)
		{
			int num6 = i / num;
			float num7 = (float)(i % num) * (num2 + num4);
			float num8 = 30f + (float)num6 * (num3 + num5);
			string text = items[i];
			string text2 = ((text.Length > 16) ? (text.Substring(0, 14) + "..") : text);
			if (GUI.Button(new Rect(num7, num8, num2, num3), text2))
			{
				equipAction?.Invoke(text);
			}
		}
	}
}
[BepInPlugin("com.quickcustomizer.mod", "QuickCustomizer", "4.0.0")]
[BepInProcess("Among Us.exe")]
public class Plugin : BasePlugin
{
	public Harmony Harmony { get; } = new Harmony("com.quickcustomizer.mod");

	public override void Load()
	{
		Harmony.PatchAll();
		ClassInjector.RegisterTypeInIl2Cpp<CustomizerUIComponent>();
		((BasePlugin)this).Log.LogInfo((object)"QuickCustomizer loaded successfully!");
	}
}
public static class CustomizerLogic
{
	public static void SetColor(byte colorId)
	{
		if (!((Object)(object)PlayerControl.LocalPlayer == (Object)null))
		{
			PlayerControl.LocalPlayer.CmdCheckColor(colorId);
		}
	}

	public static void SetName(string newName)
	{
		if (newName == null)
		{
			return;
		}
		string text = newName;
		if (!string.IsNullOrEmpty(text) && !text.Equals("blank", StringComparison.OrdinalIgnoreCase))
		{
			switch (text)
			{
			case "⠀":
			case "\u200b":
			case "\u00ad":
				break;
			default:
				goto IL_0049;
			}
		}
		text = "ㅤ";
		goto IL_0049;
		IL_0049:
		if (!((Object)(object)PlayerControl.LocalPlayer != (Object)null) || !((Object)(object)PlayerControl.LocalPlayer.Data != (Object)null))
		{
			return;
		}
		PlayerControl.LocalPlayer.Data.PlayerName = text;
		try
		{
			if ((Object)(object)PlayerControl.LocalPlayer.cosmetics != (Object)null && (Object)(object)PlayerControl.LocalPlayer.cosmetics.nameText != (Object)null)
			{
				((TMP_Text)PlayerControl.LocalPlayer.cosmetics.nameText).text = text;
			}
		}
		catch
		{
		}
	}

	public static void SetNamePlate(string namePlateId)
	{
		if ((Object)(object)PlayerControl.LocalPlayer == (Object)null)
		{
			return;
		}
		try
		{
			PlayerControl.LocalPlayer.SetNamePlate(namePlateId);
		}
		catch
		{
			try
			{
				((object)PlayerControl.LocalPlayer).GetType().GetMethod("SetNamePlate", new Type[1] { typeof(string) })?.Invoke(PlayerControl.LocalPlayer, new object[1] { namePlateId });
			}
			catch
			{
			}
		}
	}

	public static bool SetCosmeticByQuery(string type, string query)
	{
		if ((Object)(object)PlayerControl.LocalPlayer == (Object)null || (Object)(object)DestroyableSingleton<HatManager>.Instance == (Object)null)
		{
			return false;
		}
		try
		{
			switch (type)
			{
			case "hat":
				foreach (HatData item in (Il2CppArrayBase<HatData>)(object)DestroyableSingleton<HatManager>.Instance.GetUnlockedHats())
				{
					if ((Object)(object)item != (Object)null && ((CosmeticData)item).ProductId.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						PlayerControl.LocalPlayer.SetHat(((CosmeticData)item).ProductId, 0);
						PlayerPrefs.SetString("QC_SavedHat", ((CosmeticData)item).ProductId);
						PlayerPrefs.Save();
						return true;
					}
				}
				break;
			case "visor":
				foreach (VisorData item2 in (Il2CppArrayBase<VisorData>)(object)DestroyableSingleton<HatManager>.Instance.GetUnlockedVisors())
				{
					if ((Object)(object)item2 != (Object)null && ((CosmeticData)item2).ProductId.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						PlayerControl.LocalPlayer.SetVisor(((CosmeticData)item2).ProductId, 0);
						PlayerPrefs.SetString("QC_SavedVisor", ((CosmeticData)item2).ProductId);
						PlayerPrefs.Save();
						return true;
					}
				}
				break;
			case "skin":
				foreach (SkinData item3 in (Il2CppArrayBase<SkinData>)(object)DestroyableSingleton<HatManager>.Instance.GetUnlockedSkins())
				{
					if ((Object)(object)item3 != (Object)null && ((CosmeticData)item3).ProductId.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						PlayerControl.LocalPlayer.SetSkin(((CosmeticData)item3).ProductId, 0);
						PlayerPrefs.SetString("QC_SavedSkin", ((CosmeticData)item3).ProductId);
						PlayerPrefs.Save();
						return true;
					}
				}
				break;
			case "pet":
				foreach (PetData item4 in (Il2CppArrayBase<PetData>)(object)DestroyableSingleton<HatManager>.Instance.GetUnlockedPets())
				{
					if ((Object)(object)item4 != (Object)null && ((CosmeticData)item4).ProductId.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						PlayerControl.LocalPlayer.SetPet(((CosmeticData)item4).ProductId, 0);
						PlayerPrefs.SetString("QC_SavedPet", ((CosmeticData)item4).ProductId);
						PlayerPrefs.Save();
						return true;
					}
				}
				break;
			case "nameplate":
				foreach (NamePlateData item5 in (Il2CppArrayBase<NamePlateData>)(object)DestroyableSingleton<HatManager>.Instance.GetUnlockedNamePlates())
				{
					if ((Object)(object)item5 != (Object)null && ((CosmeticData)item5).ProductId.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						SetNamePlate(((CosmeticData)item5).ProductId);
						PlayerPrefs.SetString("QC_SavedNamePlate", ((CosmeticData)item5).ProductId);
						PlayerPrefs.Save();
						return true;
					}
				}
				break;
			}
		}
		catch
		{
		}
		return false;
	}

	public static void ApplySavedCustomization()
	{
		if ((Object)(object)PlayerControl.LocalPlayer == (Object)null)
		{
			return;
		}
		try
		{
			if (PlayerPrefs.HasKey("QC_SavedColor"))
			{
				SetColor((byte)PlayerPrefs.GetInt("QC_SavedColor"));
			}
			if (PlayerPrefs.HasKey("QC_SavedHat"))
			{
				PlayerControl.LocalPlayer.SetHat(PlayerPrefs.GetString("QC_SavedHat"), 0);
			}
			if (PlayerPrefs.HasKey("QC_SavedVisor"))
			{
				PlayerControl.LocalPlayer.SetVisor(PlayerPrefs.GetString("QC_SavedVisor"), 0);
			}
			if (PlayerPrefs.HasKey("QC_SavedSkin"))
			{
				PlayerControl.LocalPlayer.SetSkin(PlayerPrefs.GetString("QC_SavedSkin"), 0);
			}
			if (PlayerPrefs.HasKey("QC_SavedPet"))
			{
				PlayerControl.LocalPlayer.SetPet(PlayerPrefs.GetString("QC_SavedPet"), 0);
			}
			if (PlayerPrefs.HasKey("QC_SavedNamePlate"))
			{
				SetNamePlate(PlayerPrefs.GetString("QC_SavedNamePlate"));
			}
			if (PlayerPrefs.HasKey("QC_SavedName"))
			{
				SetName(PlayerPrefs.GetString("QC_SavedName"));
			}
		}
		catch
		{
		}
	}

	public static bool HandleChatCommand(string message)
	{
		if (string.IsNullOrEmpty(message))
		{
			return false;
		}
		if (message.StartsWith("/color ", StringComparison.OrdinalIgnoreCase))
		{
			if (int.TryParse(message.Substring(7).Trim(), out var result))
			{
				SetColor((byte)result);
				PlayerPrefs.SetInt("QC_SavedColor", result);
				PlayerPrefs.Save();
				return true;
			}
		}
		else
		{
			if (message.StartsWith("/name ", StringComparison.OrdinalIgnoreCase))
			{
				string text = message.Substring(6).Trim();
				if (string.IsNullOrEmpty(text) || text.Equals("blank", StringComparison.OrdinalIgnoreCase))
				{
					text = "ㅤ";
				}
				SetName(text);
				PlayerPrefs.SetString("QC_SavedName", text);
				PlayerPrefs.Save();
				return true;
			}
			if (message.StartsWith("/hat ", StringComparison.OrdinalIgnoreCase))
			{
				return SetCosmeticByQuery("hat", message.Substring(5).Trim());
			}
			if (message.StartsWith("/visor ", StringComparison.OrdinalIgnoreCase))
			{
				return SetCosmeticByQuery("visor", message.Substring(7).Trim());
			}
			if (message.StartsWith("/skin ", StringComparison.OrdinalIgnoreCase))
			{
				return SetCosmeticByQuery("skin", message.Substring(6).Trim());
			}
			if (message.StartsWith("/pet ", StringComparison.OrdinalIgnoreCase))
			{
				return SetCosmeticByQuery("pet", message.Substring(5).Trim());
			}
			if (message.StartsWith("/nameplate ", StringComparison.OrdinalIgnoreCase))
			{
				return SetCosmeticByQuery("nameplate", message.Substring(11).Trim());
			}
			if (message.Equals("/blank", StringComparison.OrdinalIgnoreCase) || message.Equals("/noname", StringComparison.OrdinalIgnoreCase))
			{
				SetName("ㅤ");
				PlayerPrefs.SetString("QC_SavedName", "ㅤ");
				PlayerPrefs.Save();
				return true;
			}
			if (message.Equals("/random", StringComparison.OrdinalIgnoreCase))
			{
				Random random = new Random();
				byte b = (byte)random.Next(0, 19);
				SetColor(b);
				PlayerPrefs.SetInt("QC_SavedColor", (int)b);
				string[] array = new string[7] { "SuperMarioTime", "Crewmate", "Impostor", "Pro", "Sus", "ㅤ", "Guest" };
				string text2 = array[random.Next(array.Length)];
				SetName(text2);
				PlayerPrefs.SetString("QC_SavedName", text2);
				PlayerPrefs.Save();
				return true;
			}
			if (message.Equals("/help", StringComparison.OrdinalIgnoreCase) || message.Equals("/info", StringComparison.OrdinalIgnoreCase))
			{
				CustomizerUIComponent.SendWelcomeToChat();
				return true;
			}
		}
		return false;
	}
}
[HarmonyPatch(typeof(PlayerControl), "FixedUpdate")]
public static class PlayerSpawnPatch
{
	private static PlayerControl lastProcessedPlayer;

	private static bool uiCreated;

	public static void Postfix(PlayerControl __instance)
	{
		//IL_002d: 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_003e: Expected O, but got Unknown
		if (!((Object)(object)PlayerControl.LocalPlayer == (Object)null) && !((Object)(object)__instance != (Object)(object)PlayerControl.LocalPlayer))
		{
			if (!uiCreated)
			{
				uiCreated = true;
				GameObject val = new GameObject("QuickCustomizerUIObject");
				val.AddComponent<CustomizerUIComponent>();
				Object.DontDestroyOnLoad((Object)val);
			}
			if ((Object)(object)PlayerControl.LocalPlayer != (Object)(object)lastProcessedPlayer)
			{
				lastProcessedPlayer = PlayerControl.LocalPlayer;
				CustomizerUIComponent.ResetWelcomeBanner();
				CustomizerLogic.ApplySavedCustomization();
			}
		}
	}
}
[HarmonyPatch(typeof(PlayerControl), "CmdCheckColor")]
public static class ColorCheckBypassPatch
{
	public static bool Prefix(PlayerControl __instance, byte bodyColor)
	{
		__instance.RpcSetColor(bodyColor);
		return false;
	}
}
[HarmonyPatch(typeof(ChatController), "SendChat")]
public static class ChatCommandPatch
{
	public static bool Prefix(ChatController __instance)
	{
		try
		{
			if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.freeChatField != (Object)null)
			{
				string text = string.Empty;
				FreeChatInputField freeChatField = __instance.freeChatField;
				Type type = ((object)freeChatField).GetType();
				PropertyInfo propertyInfo = type.GetProperty("text", BindingFlags.Instance | BindingFlags.Public) ?? type.GetProperty("Text", BindingFlags.Instance | BindingFlags.Public);
				if (propertyInfo != null)
				{
					text = propertyInfo.GetValue(freeChatField) as string;
				}
				else
				{
					FieldInfo fieldInfo = type.GetField("text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetField("Text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (fieldInfo != null)
					{
						text = fieldInfo.GetValue(freeChatField) as string;
					}
				}
				if (!string.IsNullOrEmpty(text))
				{
					text = text.Trim();
					if (CustomizerLogic.HandleChatCommand(text))
					{
						if (propertyInfo != null)
						{
							propertyInfo.SetValue(freeChatField, string.Empty);
						}
						else
						{
							(type.GetField("text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? type.GetField("Text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))?.SetValue(freeChatField, string.Empty);
						}
						__instance.SetVisible(false);
						return false;
					}
				}
			}
		}
		catch
		{
		}
		return true;
	}
}