Decompiled source of CustomRankLetterColorizer v2.0.5

CustomRankLetterColorizer.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using TMPro;
using UnityEngine;
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("CustomRankLetterColorizer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomRankLetterColorizer")]
[assembly: AssemblyTitle("CustomRankLetterColorizer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace CustomRankLetterColorizer;

[BepInPlugin("ali.uk.customrankcolor", "Custom Rank Letter Colorizer", "2.0.5")]
public class CustomRankLetterColorizerPlugin : BaseUnityPlugin
{
	public static ManualLogSource Log;

	public Color DColor = HexToColor("0094FF");

	public Color CColor = HexToColor("4CFF00");

	public Color BColor = HexToColor("FFD800");

	public Color AColor = HexToColor("FF6A00");

	public Color SColor = HexToColor("FF0000");

	public Color PColor = HexToColor("FFFFFF");

	public Color GoldBorderColor = HexToColor("FFB100");

	public Color DBorderColor = Color.black;

	public Color CBorderColor = Color.black;

	public Color BBorderColor = Color.black;

	public Color ABorderColor = Color.black;

	public Color SBorderColor = Color.black;

	public Color PBorderColor = HexToColor("FFB100");

	public string DText = "D";

	public string CText = "C";

	public string BText = "B";

	public string AText = "A";

	public string SText = "S";

	public string PText = "P";

	public bool DHasBorder;

	public bool CHasBorder;

	public bool BHasBorder;

	public bool AHasBorder;

	public bool SHasBorder;

	public bool PHasBorder = true;

	public bool BLSUsesBorderColor = true;

	public Color MajorAssistsBackgroundColor = HexToColor("4D99E6");

	public Color MajorAssistsTextColor = HexToColor("FFFFFF");

	public Color CheatsBorderColor = HexToColor("40FF40");

	public Color CheatsTextColor = HexToColor("FFFFFF");

	public string CheatsText = "_";

	private PluginConfigurator config;

	public static CustomRankLetterColorizerPlugin Instance { get; private set; }

	private void Awake()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: 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_0118: Expected O, but got Unknown
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Expected O, but got Unknown
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Expected O, but got Unknown
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Expected O, but got Unknown
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Expected O, but got Unknown
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Expected O, but got Unknown
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Expected O, but got Unknown
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Expected O, but got Unknown
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Expected O, but got Unknown
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Expected O, but got Unknown
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Expected O, but got Unknown
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Expected O, but got Unknown
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Expected O, but got Unknown
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Expected O, but got Unknown
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Expected O, but got Unknown
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Expected O, but got Unknown
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Expected O, but got Unknown
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Expected O, but got Unknown
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Expected O, but got Unknown
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Expected O, but got Unknown
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Expected O, but got Unknown
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Expected O, but got Unknown
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Expected O, but got Unknown
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Expected O, but got Unknown
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Expected O, but got Unknown
		//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0300: Expected O, but got Unknown
		//IL_0316: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Expected O, but got Unknown
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0336: Expected O, but got Unknown
		//IL_0331: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Expected O, but got Unknown
		//IL_033b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: Unknown result type (might be due to invalid IL or missing references)
		//IL_034e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0358: Expected O, but got Unknown
		//IL_0358: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Expected O, but got Unknown
		//IL_0369: Unknown result type (might be due to invalid IL or missing references)
		//IL_0370: Expected O, but got Unknown
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Expected O, but got Unknown
		//IL_039b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a5: Expected O, but got Unknown
		//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a7: Expected O, but got Unknown
		//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Expected O, but got Unknown
		//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f7: Expected O, but got Unknown
		//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f9: Expected O, but got Unknown
		//IL_040f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0419: Expected O, but got Unknown
		//IL_0419: Unknown result type (might be due to invalid IL or missing references)
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_042f: Expected O, but got Unknown
		//IL_042a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0431: Expected O, but got Unknown
		//IL_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_0439: Unknown result type (might be due to invalid IL or missing references)
		//IL_0447: Unknown result type (might be due to invalid IL or missing references)
		//IL_0451: Expected O, but got Unknown
		//IL_0451: Unknown result type (might be due to invalid IL or missing references)
		//IL_0467: Expected O, but got Unknown
		//IL_0462: Unknown result type (might be due to invalid IL or missing references)
		//IL_0469: Expected O, but got Unknown
		//IL_047f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0489: Expected O, but got Unknown
		//IL_0494: Unknown result type (might be due to invalid IL or missing references)
		//IL_049e: Expected O, but got Unknown
		//IL_0499: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a0: Expected O, but got Unknown
		//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Expected O, but got Unknown
		//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04da: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f0: Expected O, but got Unknown
		//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f2: Expected O, but got Unknown
		//IL_0508: Unknown result type (might be due to invalid IL or missing references)
		//IL_0512: Expected O, but got Unknown
		//IL_0512: Unknown result type (might be due to invalid IL or missing references)
		//IL_051e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0528: Expected O, but got Unknown
		//IL_0523: Unknown result type (might be due to invalid IL or missing references)
		//IL_052a: Expected O, but got Unknown
		//IL_052d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0532: Unknown result type (might be due to invalid IL or missing references)
		//IL_0540: Unknown result type (might be due to invalid IL or missing references)
		//IL_054a: Expected O, but got Unknown
		//IL_054a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0560: Expected O, but got Unknown
		//IL_055b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0562: Expected O, but got Unknown
		//IL_0578: Unknown result type (might be due to invalid IL or missing references)
		//IL_0582: Expected O, but got Unknown
		//IL_058d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0597: Expected O, but got Unknown
		//IL_0592: Unknown result type (might be due to invalid IL or missing references)
		//IL_0599: Expected O, but got Unknown
		//IL_059c: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05af: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b9: Expected O, but got Unknown
		//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e9: Expected O, but got Unknown
		//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05eb: Expected O, but got Unknown
		//IL_0601: Unknown result type (might be due to invalid IL or missing references)
		//IL_060b: Expected O, but got Unknown
		//IL_060b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0617: Unknown result type (might be due to invalid IL or missing references)
		//IL_0621: Expected O, but got Unknown
		//IL_061c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0623: Expected O, but got Unknown
		//IL_0626: Unknown result type (might be due to invalid IL or missing references)
		//IL_062b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0639: Unknown result type (might be due to invalid IL or missing references)
		//IL_0643: Expected O, but got Unknown
		//IL_0643: Unknown result type (might be due to invalid IL or missing references)
		//IL_0659: Expected O, but got Unknown
		//IL_0654: Unknown result type (might be due to invalid IL or missing references)
		//IL_065b: Expected O, but got Unknown
		//IL_0671: Unknown result type (might be due to invalid IL or missing references)
		//IL_067b: Expected O, but got Unknown
		//IL_067b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0687: Unknown result type (might be due to invalid IL or missing references)
		//IL_0691: Expected O, but got Unknown
		//IL_068c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0693: Expected O, but got Unknown
		//IL_0696: Unknown result type (might be due to invalid IL or missing references)
		//IL_069b: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b3: Expected O, but got Unknown
		//IL_06c8: Expected O, but got Unknown
		//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ca: Expected O, but got Unknown
		//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ea: Expected O, but got Unknown
		//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0704: Unknown result type (might be due to invalid IL or missing references)
		//IL_0711: Expected O, but got Unknown
		//IL_070c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0712: Unknown result type (might be due to invalid IL or missing references)
		//IL_0728: Expected O, but got Unknown
		//IL_0723: Unknown result type (might be due to invalid IL or missing references)
		//IL_072a: Expected O, but got Unknown
		//IL_0740: Unknown result type (might be due to invalid IL or missing references)
		//IL_074a: Expected O, but got Unknown
		//IL_074a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0756: Unknown result type (might be due to invalid IL or missing references)
		//IL_0760: Expected O, but got Unknown
		//IL_075b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0762: Expected O, but got Unknown
		//IL_0765: Unknown result type (might be due to invalid IL or missing references)
		//IL_076a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0778: Unknown result type (might be due to invalid IL or missing references)
		//IL_0782: Expected O, but got Unknown
		//IL_078d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0797: Expected O, but got Unknown
		//IL_0792: Unknown result type (might be due to invalid IL or missing references)
		//IL_0799: Expected O, but got Unknown
		//IL_079c: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_07af: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b9: Expected O, but got Unknown
		//IL_07cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07db: Expected O, but got Unknown
		//IL_07de: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_07fb: Expected O, but got Unknown
		//IL_0811: Unknown result type (might be due to invalid IL or missing references)
		//IL_0816: Unknown result type (might be due to invalid IL or missing references)
		//IL_081d: Expected O, but got Unknown
		//IL_0820: Unknown result type (might be due to invalid IL or missing references)
		//IL_0825: Unknown result type (might be due to invalid IL or missing references)
		//IL_0833: Unknown result type (might be due to invalid IL or missing references)
		//IL_083d: Expected O, but got Unknown
		//IL_0853: Unknown result type (might be due to invalid IL or missing references)
		//IL_0858: Unknown result type (might be due to invalid IL or missing references)
		//IL_085f: Expected O, but got Unknown
		//IL_0862: Unknown result type (might be due to invalid IL or missing references)
		//IL_0867: Unknown result type (might be due to invalid IL or missing references)
		//IL_0875: Unknown result type (might be due to invalid IL or missing references)
		//IL_087f: Expected O, but got Unknown
		//IL_088a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		config = PluginConfigurator.Create("Rank Colorizer", "ali.uk.customrankcolor");
		try
		{
			Texture2D val = new Texture2D(2, 2);
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("CustomRankLetterColorizer.iconofalltime.png");
			if (stream != null)
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				ImageConversion.LoadImage(val, array);
				config.image = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
			else
			{
				Log.LogWarning((object)"Made a fuck up whoops");
			}
		}
		catch (Exception)
		{
		}
		new ConfigHeader(config.rootPanel, "Change rank letters & borders", 24);
		ConfigPanel val2 = new ConfigPanel(config.rootPanel, "D Rank Settings", "panel_D");
		StringField val3 = new StringField(val2, "Letter Text", "text_D", DText);
		DText = val3.value;
		val3.onValueChange += (StringValueChangeEventDelegate)delegate(StringValueChangeEvent e)
		{
			DText = e.value;
		};
		ColorField val4 = new ColorField(val2, "Letter Color", "color_D", DColor);
		DColor = val4.value;
		val4.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			DColor = e.value;
			UpdateRankColorCache();
		};
		BoolField val5 = new BoolField(val2, "Show Border", "border_D", DHasBorder);
		DHasBorder = val5.value;
		val5.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
		{
			DHasBorder = e.value;
		};
		ColorField val6 = new ColorField(val2, "Border Color", "bordercolor_D", DBorderColor);
		DBorderColor = val6.value;
		val6.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			DBorderColor = e.value;
		};
		ConfigPanel val7 = new ConfigPanel(config.rootPanel, "C Rank Settings", "panel_C");
		StringField val8 = new StringField(val7, "Letter Text", "text_C", CText);
		CText = val8.value;
		val8.onValueChange += (StringValueChangeEventDelegate)delegate(StringValueChangeEvent e)
		{
			CText = e.value;
		};
		ColorField val9 = new ColorField(val7, "Letter Color", "color_C", CColor);
		CColor = val9.value;
		val9.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			CColor = e.value;
			UpdateRankColorCache();
		};
		BoolField val10 = new BoolField(val7, "Show Border", "border_C", CHasBorder);
		CHasBorder = val10.value;
		val10.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
		{
			CHasBorder = e.value;
		};
		ColorField val11 = new ColorField(val7, "Border Color", "bordercolor_C", CBorderColor);
		CBorderColor = val11.value;
		val11.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			CBorderColor = e.value;
		};
		ConfigPanel val12 = new ConfigPanel(config.rootPanel, "B Rank Settings", "panel_B");
		StringField val13 = new StringField(val12, "Letter Text", "text_B", BText);
		BText = val13.value;
		val13.onValueChange += (StringValueChangeEventDelegate)delegate(StringValueChangeEvent e)
		{
			BText = e.value;
		};
		ColorField val14 = new ColorField(val12, "Letter Color", "color_B", BColor);
		BColor = val14.value;
		val14.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			BColor = e.value;
			UpdateRankColorCache();
		};
		BoolField val15 = new BoolField(val12, "Show Border", "border_B", BHasBorder);
		BHasBorder = val15.value;
		val15.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
		{
			BHasBorder = e.value;
		};
		ColorField val16 = new ColorField(val12, "Border Color", "bordercolor_B", BBorderColor);
		BBorderColor = val16.value;
		val16.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			BBorderColor = e.value;
		};
		ConfigPanel val17 = new ConfigPanel(config.rootPanel, "A Rank Settings", "panel_A");
		StringField val18 = new StringField(val17, "Letter Text", "text_A", AText);
		AText = val18.value;
		val18.onValueChange += (StringValueChangeEventDelegate)delegate(StringValueChangeEvent e)
		{
			AText = e.value;
		};
		ColorField val19 = new ColorField(val17, "Letter Color", "color_A", AColor);
		AColor = val19.value;
		val19.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			AColor = e.value;
			UpdateRankColorCache();
		};
		BoolField val20 = new BoolField(val17, "Show Border", "border_A", AHasBorder);
		AHasBorder = val20.value;
		val20.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
		{
			AHasBorder = e.value;
		};
		ColorField val21 = new ColorField(val17, "Border Color", "bordercolor_A", ABorderColor);
		ABorderColor = val21.value;
		val21.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			ABorderColor = e.value;
		};
		ConfigPanel val22 = new ConfigPanel(config.rootPanel, "S Rank Settings", "panel_S");
		StringField val23 = new StringField(val22, "Letter Text", "text_S", SText);
		SText = val23.value;
		val23.onValueChange += (StringValueChangeEventDelegate)delegate(StringValueChangeEvent e)
		{
			SText = e.value;
		};
		ColorField val24 = new ColorField(val22, "Letter Color", "color_S", SColor);
		SColor = val24.value;
		val24.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			SColor = e.value;
			UpdateRankColorCache();
		};
		BoolField val25 = new BoolField(val22, "Show Border", "border_S", SHasBorder);
		SHasBorder = val25.value;
		val25.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
		{
			SHasBorder = e.value;
		};
		ColorField val26 = new ColorField(val22, "Border Color", "bordercolor_S", SBorderColor);
		SBorderColor = val26.value;
		val26.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			SBorderColor = e.value;
		};
		ConfigPanel val27 = new ConfigPanel(config.rootPanel, "P Rank Settings", "panel_P");
		StringField val28 = new StringField(val27, "Letter Text", "text_P", PText);
		PText = val28.value;
		val28.onValueChange += (StringValueChangeEventDelegate)delegate(StringValueChangeEvent e)
		{
			PText = e.value;
		};
		ColorField val29 = new ColorField(val27, "Letter Color", "color_P", PColor);
		PColor = val29.value;
		val29.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			PColor = e.value;
			UpdateRankColorCache();
		};
		BoolField val30 = new BoolField(val27, "Show Border", "border_P", PHasBorder);
		PHasBorder = val30.value;
		val30.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
		{
			PHasBorder = e.value;
		};
		ColorField val31 = new ColorField(val27, "Border Color", "bordercolor_P", PBorderColor);
		PBorderColor = val31.value;
		val31.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			PBorderColor = e.value;
		};
		BoolField val32 = new BoolField(val27, "BetterLevelStats Uses Border Color", "bls_border", BLSUsesBorderColor);
		BLSUsesBorderColor = val32.value;
		val32.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
		{
			BLSUsesBorderColor = e.value;
		};
		ConfigPanel val33 = new ConfigPanel(config.rootPanel, "Cheats Rank Settings", "panel_cheats");
		new ConfigHeader(val33, "Border is always enabled (total rank only)", 24);
		StringField val34 = new StringField(val33, "Letter Text", "text_cheats", CheatsText);
		CheatsText = val34.value;
		val34.onValueChange += (StringValueChangeEventDelegate)delegate(StringValueChangeEvent e)
		{
			CheatsText = e.value;
		};
		ColorField val35 = new ColorField(val33, "Text Color", "textcolor_cheats", CheatsTextColor);
		CheatsTextColor = val35.value;
		val35.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			CheatsTextColor = e.value;
		};
		ColorField val36 = new ColorField(val33, "Border Color", "bordercolor_cheats", CheatsBorderColor);
		CheatsBorderColor = val36.value;
		val36.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			CheatsBorderColor = e.value;
		};
		ColorField val37 = new ColorField(config.rootPanel, "Gold Color", "color_border", GoldBorderColor);
		GoldBorderColor = val37.value;
		val37.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			GoldBorderColor = e.value;
		};
		ColorField val38 = new ColorField(config.rootPanel, "Major Assists Background Color", "color_ma_bg", MajorAssistsBackgroundColor);
		MajorAssistsBackgroundColor = val38.value;
		val38.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			MajorAssistsBackgroundColor = e.value;
		};
		ColorField val39 = new ColorField(config.rootPanel, "Major Assists Text Color", "color_ma_text", MajorAssistsTextColor);
		MajorAssistsTextColor = val39.value;
		val39.onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			MajorAssistsTextColor = e.value;
		};
		UpdateRankColorCache();
		new Harmony("ali.uk.customrankcolor").PatchAll();
		Log.LogInfo((object)"Enjoy ur ranks :3.");
	}

	private static Color HexToColor(string hex)
	{
		//IL_0016: 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)
		Color result = default(Color);
		if (ColorUtility.TryParseHtmlString("#" + hex, ref result))
		{
			return result;
		}
		return Color.white;
	}

	private void UpdateRankColorCache()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//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_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: 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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		RankColors.D = DColor;
		RankColors.C = CColor;
		RankColors.B = BColor;
		RankColors.A = AColor;
		RankColors.S = SColor;
		RankColors.P = PColor;
		RankColors.InvalidateHexCache();
	}
}
public static class RankColors
{
	public static Color D = (Color)(((??)CustomRankLetterColorizerPlugin.Instance?.DColor) ?? new Color(0f, 0.5843f, 1f));

	public static Color C = (Color)(((??)CustomRankLetterColorizerPlugin.Instance?.CColor) ?? new Color(0.298f, 1f, 0f));

	public static Color B = (Color)(((??)CustomRankLetterColorizerPlugin.Instance?.BColor) ?? new Color(1f, 0.847f, 0f));

	public static Color A = (Color)(((??)CustomRankLetterColorizerPlugin.Instance?.AColor) ?? new Color(1f, 0.415f, 0f));

	public static Color S = (Color)(((??)CustomRankLetterColorizerPlugin.Instance?.SColor) ?? new Color(1f, 0f, 0f));

	public static Color P = (Color)(((??)CustomRankLetterColorizerPlugin.Instance?.PColor) ?? new Color(1f, 1f, 1f));

	private static readonly Dictionary<string, string> _hexCache = new Dictionary<string, string>();

	public static readonly Dictionary<string, string> VanillaHexToRank = new Dictionary<string, string>
	{
		{ "0094FF", "D" },
		{ "4CFF00", "C" },
		{ "FFD800", "B" },
		{ "FF6A00", "A" },
		{ "FF0000", "S" }
	};

	public static void InvalidateHexCache()
	{
		_hexCache.Clear();
	}

	public static Color GetColor(string rank)
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0068: 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_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		return (Color)(rank switch
		{
			"D" => D, 
			"C" => C, 
			"B" => B, 
			"A" => A, 
			"S" => S, 
			"P" => P, 
			_ => Color.white, 
		});
	}

	public static string GetHexColor(string rank)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		if (!_hexCache.TryGetValue(rank, out var value))
		{
			value = ColorUtility.ToHtmlStringRGB(GetColor(rank));
			_hexCache[rank] = value;
		}
		return value;
	}

	public static string GetText(string rank)
	{
		CustomRankLetterColorizerPlugin instance = CustomRankLetterColorizerPlugin.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return rank;
		}
		return rank switch
		{
			"D" => instance.DText, 
			"C" => instance.CText, 
			"B" => instance.BText, 
			"A" => instance.AText, 
			"S" => instance.SText, 
			"P" => instance.PText, 
			_ => rank, 
		};
	}

	public static bool HasBorder(string rank)
	{
		CustomRankLetterColorizerPlugin instance = CustomRankLetterColorizerPlugin.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return rank == "P";
		}
		return rank switch
		{
			"D" => instance.DHasBorder, 
			"C" => instance.CHasBorder, 
			"B" => instance.BHasBorder, 
			"A" => instance.AHasBorder, 
			"S" => instance.SHasBorder, 
			"P" => instance.PHasBorder, 
			_ => false, 
		};
	}

	public static bool IsRankText(string text)
	{
		CustomRankLetterColorizerPlugin instance = CustomRankLetterColorizerPlugin.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return false;
		}
		if (!(text == instance.DText) && !(text == instance.CText) && !(text == instance.BText) && !(text == instance.AText) && !(text == instance.SText))
		{
			return text == instance.PText;
		}
		return true;
	}

	public static Color GetBorderColor(string rank)
	{
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: 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_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		CustomRankLetterColorizerPlugin instance = CustomRankLetterColorizerPlugin.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			if (!(rank == "P"))
			{
				return Color.black;
			}
			return new Color(1f, 0.694f, 0f);
		}
		return (Color)(rank switch
		{
			"D" => instance.DBorderColor, 
			"C" => instance.CBorderColor, 
			"B" => instance.BBorderColor, 
			"A" => instance.ABorderColor, 
			"S" => instance.SBorderColor, 
			"P" => instance.PBorderColor, 
			_ => Color.black, 
		});
	}

	public static Color GetGoldBorderColor()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		return (Color)(((??)CustomRankLetterColorizerPlugin.Instance?.GoldBorderColor) ?? new Color(1f, 0.694f, 0f));
	}

	public static Color GetMajorAssistsBackgroundColor()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		return (Color)(((??)CustomRankLetterColorizerPlugin.Instance?.MajorAssistsBackgroundColor) ?? new Color(0.3f, 0.6f, 0.9f, 1f));
	}

	public static Color GetMajorAssistsTextColor()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		return (Color)(((??)CustomRankLetterColorizerPlugin.Instance?.MajorAssistsTextColor) ?? new Color(0.298f, 0.6f, 0.902f, 1f));
	}

	public static Color GetCheatsBorderColor()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		return (Color)(((??)CustomRankLetterColorizerPlugin.Instance?.CheatsBorderColor) ?? new Color(0.25f, 1f, 0.25f));
	}

	public static Color GetCheatsTextColor()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		return CustomRankLetterColorizerPlugin.Instance?.CheatsTextColor ?? Color.white;
	}

	public static string GetCheatsText()
	{
		return CustomRankLetterColorizerPlugin.Instance?.CheatsText ?? "_";
	}

	public static int GetRankPoints(string rank)
	{
		return rank switch
		{
			"D" => 500, 
			"C" => 1000, 
			"B" => 1500, 
			"A" => 2000, 
			"S" => 2500, 
			"P" => 4000, 
			_ => 0, 
		};
	}
}
internal static class FinalRankTrueLetters
{
	public static string TimeRank;

	public static string KillsRank;

	public static string StyleRank;

	public static void Clear()
	{
		TimeRank = null;
		KillsRank = null;
		StyleRank = null;
	}
}
internal static class FinalRankHelper
{
	public static string StripColorTag(string rank)
	{
		if (string.IsNullOrEmpty(rank))
		{
			return rank;
		}
		if (!rank.Contains("<color="))
		{
			return rank;
		}
		int num = rank.IndexOf('>') + 1;
		int num2 = rank.IndexOf("</color>");
		if (num > 0 && num2 >= num)
		{
			int num3 = num;
			return rank.Substring(num3, num2 - num3);
		}
		return rank;
	}

	public static string GetTrueLetter(string rankString)
	{
		if (string.IsNullOrEmpty(rankString))
		{
			return null;
		}
		if (rankString.Contains("<color=#"))
		{
			int num = rankString.IndexOf("<color=#") + 8;
			if (num + 6 <= rankString.Length)
			{
				string key = rankString.Substring(num, 6).ToUpperInvariant();
				if (RankColors.VanillaHexToRank.TryGetValue(key, out var value))
				{
					return value;
				}
			}
		}
		return StripColorTag(rankString);
	}

	public static void ApplyBorder(TMP_Text rankText, string rank)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: 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_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)rankText == (Object)null)
		{
			return;
		}
		Transform parent = rankText.transform.parent;
		Image val = ((parent != null) ? ((Component)parent).GetComponent<Image>() : null);
		if (!((Object)(object)val == (Object)null))
		{
			string rank2 = StripColorTag(rank);
			if (RankColors.HasBorder(rank2))
			{
				Color borderColor = RankColors.GetBorderColor(rank2);
				((Graphic)val).color = new Color(borderColor.r, borderColor.g, borderColor.b, 1f);
			}
			else
			{
				((Graphic)val).color = new Color(0f, 0f, 0f, 0.6275f);
			}
		}
	}
}
[HarmonyPatch(typeof(TMP_Text), "set_text")]
internal static class RankTextPatch
{
	private static readonly Dictionary<int, float> _origSizes = new Dictionary<int, float>();

	private static readonly Dictionary<int, bool> _wasAutoSizing = new Dictionary<int, bool>();

	private const float MULTI_LINE_SCALE_MULTIPLIER = 0.7f;

	private static readonly Dictionary<string, string> RankHexPatterns = new Dictionary<string, string>
	{
		{ "0094FF", "D" },
		{ "4CFF00", "C" },
		{ "FFD800", "B" },
		{ "FF6A00", "A" },
		{ "FF0000", "S" },
		{ "FFFFFF", "P" },
		{ "FFAF00", "P" }
	};

	private static readonly Regex ColorTagRegex = new Regex("<color=#([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})?>(.*?)</color>", RegexOptions.Compiled);

	private const string VanillaMAYes = "<color=#4C99E6>YES</color>";

	private const string BLSCheatsPrefix = "<color=#40FF40FF>";

	private const string BLSCheatsSuffix = "</color>";

	private const string BLSMAPrefix = "<color=#4C99E6FF>";

	private const string BLSMASuffix = "</color>*";

	private static bool IsCalledFromAllowedComponent()
	{
		StackFrame[] frames = new StackTrace().GetFrames();
		for (int i = 0; i < frames.Length; i++)
		{
			MethodBase method = frames[i].GetMethod();
			if (method == null)
			{
				continue;
			}
			Type declaringType = method.DeclaringType;
			if (!(declaringType == null))
			{
				switch (declaringType.Name)
				{
				case "FinalRank":
				case "LevelSelectPanel":
				case "LayerSelect":
				case "ChapterSelectButton":
				case "RankIcon":
					return true;
				case "LevelStats":
				case "StatsManager":
					return true;
				}
			}
		}
		return false;
	}

	private static bool IsInsideLevelStats(TMP_Text t)
	{
		return (Object)(object)((Component)t).GetComponentInParent<LevelStats>() != (Object)null;
	}

	private static string IAmSufferingWithThisShit(string hex, string rank)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		List<string> list = new List<string>();
		string[] array = new string[6] { "D", "C", "B", "A", "S", "P" };
		for (int i = 0; i < array.Length; i++)
		{
			if (array[i] != rank)
			{
				string item = ColorUtility.ToHtmlStringRGB(RankColors.GetColor(array[i]));
				list.Add(item);
			}
		}
		list.Add("0094FF");
		list.Add("4CFF00");
		list.Add("FFD800");
		list.Add("FF6A00");
		list.Add("FF0000");
		list.Add("FFFFFF");
		list.Add("FFAF00");
		bool flag = false;
		for (int j = 0; j < list.Count; j++)
		{
			if (list[j].ToUpper() == hex.ToUpper())
			{
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			return hex;
		}
		int[] array2 = new int[3] { 0, 1, 2 };
		int[] array3 = new int[2] { -1, 1 };
		for (int k = 0; k < array2.Length; k++)
		{
			for (int l = 0; l < array3.Length; l++)
			{
				string text = DoTheNudgeThing(hex, array2[k], array3[l]);
				if (text == null)
				{
					continue;
				}
				bool flag2 = false;
				for (int m = 0; m < list.Count; m++)
				{
					if (list[m].ToUpper() == text.ToUpper())
					{
						flag2 = true;
						break;
					}
				}
				if (!flag2)
				{
					return text;
				}
			}
		}
		for (int n = 0; n < array2.Length; n++)
		{
			for (int num = 0; num < array3.Length; num++)
			{
				string text2 = DoTheNudgeThing(hex, array2[n], array3[num] * 2);
				if (text2 == null)
				{
					continue;
				}
				bool flag3 = false;
				for (int num2 = 0; num2 < list.Count; num2++)
				{
					if (list[num2].ToUpper() == text2.ToUpper())
					{
						flag3 = true;
						break;
					}
				}
				if (!flag3)
				{
					return text2;
				}
			}
		}
		return hex;
	}

	private static string DoTheNudgeThing(string hex, int channel, int howMuch)
	{
		if (hex.Length != 6)
		{
			return null;
		}
		string s = hex.Substring(0, 2);
		string s2 = hex.Substring(2, 2);
		string s3 = hex.Substring(4, 2);
		int num = int.Parse(s, NumberStyles.HexNumber);
		int num2 = int.Parse(s2, NumberStyles.HexNumber);
		int num3 = int.Parse(s3, NumberStyles.HexNumber);
		switch (channel)
		{
		case 0:
			num += howMuch;
			break;
		case 1:
			num2 += howMuch;
			break;
		case 2:
			num3 += howMuch;
			break;
		}
		if (num < 0 || num > 255)
		{
			return null;
		}
		if (num2 < 0 || num2 > 255)
		{
			return null;
		}
		if (num3 < 0 || num3 > 255)
		{
			return null;
		}
		return num.ToString("X2") + num2.ToString("X2") + num3.ToString("X2");
	}

	private static void Prefix(TMP_Text __instance, ref string value)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrEmpty(value) || (!IsCalledFromAllowedComponent() && !IsInsideLevelStats(__instance)))
		{
			return;
		}
		if (value == "<color=#4C99E6>YES</color>")
		{
			string text = ColorUtility.ToHtmlStringRGB(RankColors.GetMajorAssistsBackgroundColor());
			value = "<color=#" + text + ">YES</color>";
			return;
		}
		if (IsInsideLevelStats(__instance))
		{
			if (value.StartsWith("<color=#40FF40FF>") && value.EndsWith("</color>") && !value.EndsWith("</color>*"))
			{
				string text2 = ColorUtility.ToHtmlStringRGB(RankColors.GetCheatsBorderColor());
				string text3 = RankColors.GetCheatsText();
				if (text3 == "_")
				{
					text3 = "-";
				}
				__instance.enableWordWrapping = false;
				__instance.enableAutoSizing = false;
				value = "<color=#" + text2 + ">" + text3 + "</color>";
				return;
			}
			if (value.StartsWith("<color=#4C99E6FF>") && value.EndsWith("</color>*"))
			{
				string obj = value;
				int length = "<color=#4C99E6FF>".Length;
				string text4 = RankColors.GetText(obj.Substring(length, value.Length - "</color>*".Length - length));
				string text5 = ColorUtility.ToHtmlStringRGB(RankColors.GetMajorAssistsBackgroundColor());
				__instance.enableWordWrapping = false;
				__instance.enableAutoSizing = false;
				value = "<color=#" + text5 + ">" + text4 + "</color>*";
				return;
			}
		}
		if (!value.Contains("<color=#") || value.Contains('\n'))
		{
			return;
		}
		value = ColorTagRegex.Replace(value, delegate(Match match)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			string text6 = match.Groups[1].Value.ToUpperInvariant();
			string value2 = match.Groups[2].Value;
			string value3 = match.Groups[3].Value;
			if (!RankHexPatterns.TryGetValue(text6, out var value4))
			{
				return match.Value;
			}
			if (value3 == "YES")
			{
				string text7 = ColorUtility.ToHtmlStringRGB(RankColors.GetGoldBorderColor());
				return "<color=#" + text7 + ">YES</color>";
			}
			if (value3 == "NO")
			{
				return match.Value;
			}
			string text8 = RankColors.GetText(value4);
			string text9 = text8.Replace(' ', '\n');
			int instanceID = ((Object)__instance).GetInstanceID();
			(int lineCount, int maxLineLen) tuple = AnalyzeText(text9);
			int item = tuple.lineCount;
			int item2 = tuple.maxLineLen;
			bool flag = (text8.Length > 1 && RankColors.IsRankText(text8)) || item > 1;
			if (flag && IsInsideLevelStats(__instance))
			{
				__instance.enableWordWrapping = false;
				__instance.enableAutoSizing = false;
				flag = false;
			}
			if (flag)
			{
				__instance.enableWordWrapping = true;
				__instance.alignment = (TextAlignmentOptions)514;
				if (!_origSizes.TryGetValue(instanceID, out var value5))
				{
					value5 = __instance.fontSize;
					_origSizes[instanceID] = value5;
					_wasAutoSizing[instanceID] = __instance.enableAutoSizing;
				}
				float num = 1f;
				if (item > 1)
				{
					num = 1f / (float)item * 0.7f;
					__instance.alignment = (TextAlignmentOptions)514;
				}
				else if (item2 > 1)
				{
					num = 1f / (float)item2;
				}
				__instance.fontSizeMax = value5 * num;
				__instance.fontSizeMin = value5 * (0.5f * num);
				__instance.enableAutoSizing = true;
			}
			else
			{
				__instance.enableAutoSizing = false;
				__instance.enableWordWrapping = false;
				if (_origSizes.TryGetValue(instanceID, out var value6))
				{
					__instance.fontSize = value6;
					__instance.enableAutoSizing = _wasAutoSizing[instanceID];
					_origSizes.Remove(instanceID);
					_wasAutoSizing.Remove(instanceID);
				}
			}
			Color val = ((!(text6 == "FFAF00") || !((Object)(object)CustomRankLetterColorizerPlugin.Instance != (Object)null)) ? RankColors.GetColor(value4) : (CustomRankLetterColorizerPlugin.Instance.BLSUsesBorderColor ? RankColors.GetBorderColor("P") : RankColors.GetColor("P")));
			string hex = ((text6 == "FFAF00") ? ColorUtility.ToHtmlStringRGB(val) : RankColors.GetHexColor(value4));
			hex = IAmSufferingWithThisShit(hex, value4);
			return (!string.IsNullOrEmpty(value2)) ? ("<color=#" + hex + value2 + ">" + text9 + "</color>") : ("<color=#" + hex + ">" + text9 + "</color>");
		});
	}

	private static (int lineCount, int maxLineLen) AnalyzeText(string text)
	{
		int num = 1;
		int num2 = 0;
		int num3 = 0;
		for (int i = 0; i < text.Length; i++)
		{
			if (text[i] == '\n')
			{
				if (num3 > num2)
				{
					num2 = num3;
				}
				num3 = 0;
				num++;
			}
			else
			{
				num3++;
			}
		}
		if (num3 > num2)
		{
			num2 = num3;
		}
		return (num, num2);
	}
}
[HarmonyPatch(typeof(ChallengeManager), "OnEnable")]
internal static class ChallengeManager_OnEnable_Patch
{
	private static void Postfix(ChallengeManager __instance)
	{
		//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)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance.challengePanel == (Object)null))
		{
			Image component = __instance.challengePanel.GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				Color goldBorderColor = RankColors.GetGoldBorderColor();
				((Graphic)component).color = new Color(goldBorderColor.r, goldBorderColor.g, goldBorderColor.b, ((Graphic)component).color.a);
			}
		}
	}
}
[HarmonyPatch(typeof(ChallengeManager), "ChallengeDone")]
internal static class ChallengeManager_ChallengeDone_Patch
{
	private static void Postfix(ChallengeManager __instance)
	{
		//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)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance.challengePanel == (Object)null))
		{
			Image component = __instance.challengePanel.GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				Color goldBorderColor = RankColors.GetGoldBorderColor();
				((Graphic)component).color = new Color(goldBorderColor.r, goldBorderColor.g, goldBorderColor.b, ((Graphic)component).color.a);
			}
		}
	}
}
[HarmonyPatch(typeof(LayerSelect), "Gold")]
internal static class LayerSelect_Gold_Patch
{
	private static void Postfix(LayerSelect __instance)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: 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)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		if (__instance.gold)
		{
			Color goldBorderColor = RankColors.GetGoldBorderColor();
			((Graphic)((Component)__instance).GetComponent<Image>()).color = new Color(goldBorderColor.r, goldBorderColor.g, goldBorderColor.b, 0.75f);
		}
	}
}
[HarmonyPatch(typeof(LayerSelect), "SecretMissionDone")]
internal static class LayerSelect_SecretMissionDone_Patch
{
	private static void Postfix(LayerSelect __instance)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: 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)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		if (__instance.gold)
		{
			Color goldBorderColor = RankColors.GetGoldBorderColor();
			((Graphic)((Component)__instance).GetComponent<Image>()).color = new Color(goldBorderColor.r, goldBorderColor.g, goldBorderColor.b, 0.75f);
		}
	}
}
[HarmonyPatch(typeof(LayerSelect), "AddScore")]
internal static class LayerSelect_AddScore_Patch
{
	private static void Postfix(LayerSelect __instance)
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: 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_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance.rankImage == (Object)null) && __instance.complete)
		{
			string rank = (__instance.allPerfects ? "P" : GetRankLetterFromScore(__instance.trueScore));
			if (RankColors.HasBorder(rank))
			{
				Color borderColor = RankColors.GetBorderColor(rank);
				((Graphic)__instance.rankImage).color = new Color(borderColor.r, borderColor.g, borderColor.b, 1f);
				__instance.rankImage.sprite = __instance.rankSpriteOnP ?? __instance.rankSpriteOriginal;
			}
			else
			{
				((Graphic)__instance.rankImage).color = Color.white;
				__instance.rankImage.sprite = __instance.rankSpriteOriginal;
			}
		}
	}

	private static string GetRankLetterFromScore(int score)
	{
		if (score < 4)
		{
			return score switch
			{
				1 => "C", 
				2 => "B", 
				3 => "A", 
				_ => "D", 
			};
		}
		return "S";
	}
}
[HarmonyPatch(typeof(LevelSelectPanel), "CheckScore")]
internal static class LevelSelectPanel_CheckScore_Patch
{
	private static readonly Dictionary<int, Transform> _rankTransformCache = new Dictionary<int, Transform>();

	private static void Postfix(LevelSelectPanel __instance)
	{
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		RankData rank = GameProgressSaver.GetRank(GetMissionNumber(__instance), false);
		if (rank == null)
		{
			return;
		}
		int @int = MonoSingleton<PrefsManager>.Instance.GetInt("difficulty", 0);
		if (rank.ranks[@int] < 0)
		{
			return;
		}
		bool flag = rank.majorAssists != null && rank.majorAssists[@int];
		string text = ((rank.ranks[@int] == 12 && !flag) ? "P" : RankHelper.GetRankLetter(rank.ranks[@int]));
		if (flag)
		{
			((Graphic)((Component)__instance).GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.35f);
		}
		else if (RankColors.HasBorder(text))
		{
			Color borderColor = RankColors.GetBorderColor(text);
			((Graphic)((Component)__instance).GetComponent<Image>()).color = new Color(borderColor.r, borderColor.g, borderColor.b, 0.75f);
		}
		else
		{
			((Graphic)((Component)__instance).GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.35f);
		}
		int instanceID = ((Object)__instance).GetInstanceID();
		if (!_rankTransformCache.TryGetValue(instanceID, out var value))
		{
			value = ((Component)__instance).transform.Find("Stats/Rank");
			_rankTransformCache[instanceID] = value;
		}
		if ((Object)(object)value == (Object)null)
		{
			return;
		}
		Image component = ((Component)value).GetComponent<Image>();
		TMP_Text componentInChildren = ((Component)value).GetComponentInChildren<TMP_Text>();
		if (!((Object)(object)component == (Object)null) && !((Object)(object)componentInChildren == (Object)null))
		{
			if (flag)
			{
				Color majorAssistsBackgroundColor = RankColors.GetMajorAssistsBackgroundColor();
				((Graphic)component).color = new Color(majorAssistsBackgroundColor.r, majorAssistsBackgroundColor.g, majorAssistsBackgroundColor.b, 1f);
				component.sprite = __instance.filledPanel;
				string text2 = ColorUtility.ToHtmlStringRGB(RankColors.GetMajorAssistsTextColor());
				componentInChildren.text = "<color=#" + text2 + ">" + text + "</color>";
			}
			else if (RankColors.HasBorder(text))
			{
				Color borderColor2 = RankColors.GetBorderColor(text);
				((Graphic)component).color = new Color(borderColor2.r, borderColor2.g, borderColor2.b, 1f);
				component.sprite = __instance.filledPanel;
				string hexColor = RankColors.GetHexColor(text);
				componentInChildren.text = "<color=#" + hexColor + ">" + RankColors.GetText(text) + "</color>";
			}
			else
			{
				((Graphic)component).color = Color.white;
				component.sprite = __instance.unfilledPanel;
				string hexColor2 = RankColors.GetHexColor(text);
				componentInChildren.text = "<color=#" + hexColor2 + ">" + RankColors.GetText(text) + "</color>";
			}
		}
	}

	private static int GetMissionNumber(LevelSelectPanel panel)
	{
		int num = panel.levelNumber;
		if (num == 666 || num == 100)
		{
			num += panel.levelNumberInLayer - 1;
		}
		return num;
	}
}
[HarmonyPatch(typeof(LevelSelectPanel), "CheckScore")]
internal static class LevelSelectPanel_ChallengeText_Patch
{
	private static void Postfix(LevelSelectPanel __instance)
	{
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance.challengeIcon == (Object)null)
		{
			return;
		}
		TMP_Text componentInChildren = ((Component)__instance.challengeIcon).GetComponentInChildren<TMP_Text>();
		if ((Object)(object)componentInChildren == (Object)null || componentInChildren.text != "C O M P L E T E")
		{
			return;
		}
		RankData rank = GameProgressSaver.GetRank((__instance.levelNumber == 666 || __instance.levelNumber == 100) ? (__instance.levelNumber + __instance.levelNumberInLayer - 1) : __instance.levelNumber, false);
		if (rank != null)
		{
			int @int = MonoSingleton<PrefsManager>.Instance.GetInt("difficulty", 0);
			bool flag = rank.majorAssists != null && rank.majorAssists[@int];
			string rank2 = ((rank.ranks[@int] == 12 && !flag) ? "P" : RankHelper.GetRankLetter(rank.ranks[@int]));
			if (flag)
			{
				Color majorAssistsBackgroundColor = RankColors.GetMajorAssistsBackgroundColor();
				((Graphic)componentInChildren).color = DarkenColor(majorAssistsBackgroundColor, 0.253f);
			}
			else if (RankColors.HasBorder(rank2))
			{
				Color borderColor = RankColors.GetBorderColor(rank2);
				((Graphic)componentInChildren).color = DarkenColor(borderColor, 0.253f);
			}
			else
			{
				((Graphic)componentInChildren).color = Color.black;
			}
		}
	}

	private static Color DarkenColor(Color c, float amount)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		return new Color(Mathf.Clamp01(c.r - amount), Mathf.Clamp01(c.g - amount), Mathf.Clamp01(c.b - amount), c.a);
	}
}
[HarmonyPatch(typeof(ChapterSelectButton), "CheckScore")]
internal static class ChapterSelectButton_CheckScore_Patch
{
	private static void Postfix(ChapterSelectButton __instance)
	{
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		Image value = Traverse.Create((object)__instance).Field("rankButton").GetValue<Image>();
		Sprite value2 = Traverse.Create((object)__instance).Field("originalRankSprite").GetValue<Sprite>();
		if (__instance.allPerfects == __instance.layersInChapter.Length)
		{
			if ((Object)(object)value != (Object)null)
			{
				if (RankColors.HasBorder("P"))
				{
					Color borderColor = RankColors.GetBorderColor("P");
					((Graphic)value).color = new Color(borderColor.r, borderColor.g, borderColor.b, 1f);
					Sprite value3 = Traverse.Create((object)__instance).Field("rankOnP").GetValue<Sprite>();
					if ((Object)(object)value3 != (Object)null)
					{
						value.sprite = value3;
					}
				}
				else
				{
					((Graphic)value).color = Color.white;
					value.sprite = value2;
				}
			}
			if (__instance.golds != __instance.layersInChapter.Length)
			{
				return;
			}
			Image component = ((Component)__instance).GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				Color goldBorderColor = RankColors.GetGoldBorderColor();
				((Graphic)component).color = new Color(goldBorderColor.r, goldBorderColor.g, goldBorderColor.b, 1f);
				Sprite value4 = Traverse.Create((object)__instance).Field("buttonOnP").GetValue<Sprite>();
				if ((Object)(object)value4 != (Object)null)
				{
					component.sprite = value4;
				}
			}
			return;
		}
		string rankLetterFromAverageScore = GetRankLetterFromAverageScore(__instance);
		if (rankLetterFromAverageScore != null && RankColors.HasBorder(rankLetterFromAverageScore) && (Object)(object)value != (Object)null)
		{
			Color borderColor2 = RankColors.GetBorderColor(rankLetterFromAverageScore);
			((Graphic)value).color = new Color(borderColor2.r, borderColor2.g, borderColor2.b, 1f);
			Sprite value5 = Traverse.Create((object)__instance).Field("rankOnP").GetValue<Sprite>();
			if ((Object)(object)value5 != (Object)null)
			{
				value.sprite = value5;
			}
		}
		else if ((Object)(object)value != (Object)null)
		{
			((Graphic)value).color = Color.white;
			value.sprite = value2;
		}
	}

	private static string GetRankLetterFromAverageScore(ChapterSelectButton __instance)
	{
		if (__instance.notComplete)
		{
			return null;
		}
		int totalScore = __instance.totalScore;
		if (totalScore < 4)
		{
			return totalScore switch
			{
				1 => "C", 
				2 => "B", 
				3 => "A", 
				_ => "D", 
			};
		}
		return "S";
	}
}
[HarmonyPatch(typeof(FinalRank), "SetTime")]
internal static class FinalRank_SetTime_Patch
{
	private static void Prefix(string rank)
	{
		FinalRankTrueLetters.TimeRank = FinalRankHelper.GetTrueLetter(rank);
	}

	private static void Postfix(FinalRank __instance, string rank)
	{
		FinalRankHelper.ApplyBorder(__instance.timeRank, rank);
	}
}
[HarmonyPatch(typeof(FinalRank), "SetKills")]
internal static class FinalRank_SetKills_Patch
{
	private static void Prefix(string rank)
	{
		FinalRankTrueLetters.KillsRank = FinalRankHelper.GetTrueLetter(rank);
	}

	private static void Postfix(FinalRank __instance, string rank)
	{
		FinalRankHelper.ApplyBorder(__instance.killsRank, rank);
	}
}
[HarmonyPatch(typeof(FinalRank), "SetStyle")]
internal static class FinalRank_SetStyle_Patch
{
	private static void Prefix(string rank)
	{
		FinalRankTrueLetters.StyleRank = FinalRankHelper.GetTrueLetter(rank);
	}

	private static void Postfix(FinalRank __instance, string rank)
	{
		FinalRankHelper.ApplyBorder(__instance.styleRank, rank);
	}
}
[HarmonyPatch(typeof(FinalRank), "Appear")]
internal static class FinalRank_Appear_Patch
{
	private static void Postfix(FinalRank __instance)
	{
		int num = (int)typeof(FinalRank).GetField("i", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
		if (num <= 0)
		{
			return;
		}
		GameObject[] toAppear = __instance.toAppear;
		if (toAppear == null || num > toAppear.Length)
		{
			return;
		}
		GameObject val = toAppear[num - 1];
		if ((Object)(object)val == (Object)null || ((Object)(object)val != (Object)(object)((Component)__instance.timeRank).gameObject && (Object)(object)val != (Object)(object)((Component)__instance.killsRank).gameObject && (Object)(object)val != (Object)(object)((Component)__instance.styleRank).gameObject))
		{
			return;
		}
		string text = null;
		if ((Object)(object)val == (Object)(object)((Component)__instance.timeRank).gameObject)
		{
			text = FinalRankTrueLetters.TimeRank;
		}
		else if ((Object)(object)val == (Object)(object)((Component)__instance.killsRank).gameObject)
		{
			text = FinalRankTrueLetters.KillsRank;
		}
		else if ((Object)(object)val == (Object)(object)((Component)__instance.styleRank).gameObject)
		{
			text = FinalRankTrueLetters.StyleRank;
		}
		if (text == null)
		{
			return;
		}
		int rankPoints = RankColors.GetRankPoints(text);
		if (rankPoints == 0)
		{
			return;
		}
		TMP_Text component = val.GetComponent<TMP_Text>();
		if (!((Object)(object)component == (Object)null))
		{
			string text2 = component.text;
			int num2 = 0;
			switch (text2)
			{
			case "<color=#0094FF>D</color>":
				num2 = 500;
				break;
			case "<color=#4CFF00>C</color>":
				num2 = 1000;
				break;
			case "<color=#FFD800>B</color>":
				num2 = 1500;
				break;
			case "<color=#FF6A00>A</color>":
				num2 = 2000;
				break;
			case "<color=#FF0000>S</color>":
				num2 = 2500;
				break;
			}
			int num3 = rankPoints - num2;
			if (num3 != 0)
			{
				__instance.AddPoints(num3);
			}
		}
	}
}
[HarmonyPatch(typeof(StatsManager), "GetFinalRank")]
internal static class StatsManager_GetFinalRank_Patch
{
	private static void Postfix(StatsManager __instance)
	{
		//IL_00ed: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: 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_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance.fr == (Object)null || (Object)(object)__instance.fr.totalRank == (Object)null)
		{
			return;
		}
		Transform parent = __instance.fr.totalRank.transform.parent;
		Image val = ((parent != null) ? ((Component)parent).GetComponent<Image>() : null);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		AssistController instance = MonoSingleton<AssistController>.Instance;
		if ((Object)(object)instance != (Object)null && instance.cheatsEnabled)
		{
			Color cheatsBorderColor = RankColors.GetCheatsBorderColor();
			((Graphic)val).color = new Color(cheatsBorderColor.r, cheatsBorderColor.g, cheatsBorderColor.b, 1f);
			string text = ColorUtility.ToHtmlStringRGB(RankColors.GetCheatsTextColor());
			string cheatsText = RankColors.GetCheatsText();
			__instance.fr.totalRank.SetText("<color=#" + text + ">" + cheatsText + "</color>", true);
			return;
		}
		if (__instance.majorUsed)
		{
			Color majorAssistsBackgroundColor = RankColors.GetMajorAssistsBackgroundColor();
			((Graphic)val).color = new Color(majorAssistsBackgroundColor.r, majorAssistsBackgroundColor.g, majorAssistsBackgroundColor.b, 1f);
			string rankLetter = RankHelper.GetRankLetter(__instance.rankScore);
			string text2 = ColorUtility.ToHtmlStringRGB(RankColors.GetMajorAssistsTextColor());
			__instance.fr.totalRank.SetText("<color=#" + text2 + ">" + rankLetter + "</color>", true);
			return;
		}
		bool flag = __instance.rankScore == 12;
		if (flag && RankColors.HasBorder("P"))
		{
			Color borderColor = RankColors.GetBorderColor("P");
			((Graphic)val).color = new Color(borderColor.r, borderColor.g, borderColor.b, 1f);
		}
		else if (!flag)
		{
			string rankLetter2 = RankHelper.GetRankLetter(__instance.rankScore);
			if (RankColors.HasBorder(rankLetter2))
			{
				Color borderColor2 = RankColors.GetBorderColor(rankLetter2);
				((Graphic)val).color = new Color(borderColor2.r, borderColor2.g, borderColor2.b, 1f);
			}
			else
			{
				((Graphic)val).color = new Color(0f, 0f, 0f, 0.6275f);
			}
		}
		else
		{
			((Graphic)val).color = new Color(0f, 0f, 0f, 0.6275f);
		}
	}
}
[HarmonyPatch(typeof(FinalRank), "SetRank")]
internal static class FinalRank_SetRank_Cheats_Patch
{
	private static void Postfix(FinalRank __instance, string rank)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance.totalRank == (Object)null))
		{
			AssistController instance = MonoSingleton<AssistController>.Instance;
			if ((Object)(object)instance != (Object)null && instance.cheatsEnabled)
			{
				string text = ColorUtility.ToHtmlStringRGB(RankColors.GetCheatsTextColor());
				string cheatsText = RankColors.GetCheatsText();
				__instance.totalRank.SetText("<color=#" + text + ">" + cheatsText + "</color>", true);
			}
			else
			{
				FinalRankHelper.ApplyBorder(__instance.totalRank, rank);
			}
		}
	}
}
[HarmonyPatch(typeof(RankHelper), "GetRankBackgroundColor")]
internal static class RankHelper_GetRankBackgroundColor_Patch
{
	private static void Postfix(int rank, ref Color __result)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		string rankLetter = RankHelper.GetRankLetter(rank);
		if (RankColors.HasBorder(rankLetter))
		{
			__result = RankColors.GetBorderColor(rankLetter);
		}
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "ali.uk.customrankcolor";

	public const string PLUGIN_NAME = "Custom Rank Letter Colorizer";

	public const string PLUGIN_VERSION = "2.0.5";
}