Decompiled source of AFKTextFX v1.4.1

AFKTextFX.dll

Decompiled a month ago
using System;
using System.Collections;
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;
using System.Text.RegularExpressions;
using AFKTextFX.Data;
using AFKTextFX.UI;
using AFKTextFX.Utils;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AFKTextFX")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("AFKTextFX")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AFKTextFX
{
	[BepInPlugin("AFKTextFX", "My first plugin", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <WaitForSteamAndInit>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Plugin <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitForSteamAndInit>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!SteamAPI.IsSteamRunning())
				{
					Logger.LogInfo((object)"Waiting for SteamAPI to initialize...");
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				BannedWordsManager.LoadBannedWords();
				ConfigManager.Init(((BaseUnityPlugin)<>4__this).Config);
				<>4__this.textFXUI = new TextFXUI();
				<>4__this.harmony = new Harmony("AFKTextFX");
				<>4__this.harmony.PatchAll();
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal static ManualLogSource Logger;

		private TextFXUI textFXUI;

		private Harmony harmony;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin AFKTextFX is loaded!");
			((MonoBehaviour)this).StartCoroutine(WaitForSteamAndInit());
		}

		[IteratorStateMachine(typeof(<WaitForSteamAndInit>d__4))]
		private IEnumerator WaitForSteamAndInit()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForSteamAndInit>d__4(0)
			{
				<>4__this = this
			};
		}

		private void Update()
		{
			textFXUI.Update();
		}

		private void OnGUI()
		{
			textFXUI.OnGUI();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AFKTextFX";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace AFKTextFX.Utils
{
	public static class RichTextUtils
	{
		public static string ToRainbowRichText(string input)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(input))
			{
				return string.Empty;
			}
			StringBuilder stringBuilder = new StringBuilder();
			int length = input.Length;
			for (int i = 0; i < length; i++)
			{
				float num = (float)i / (float)length;
				Color val = Color.HSVToRGB(num, 1f, 1f);
				string arg = ColorUtility.ToHtmlStringRGB(val);
				stringBuilder.Append($"<color=#{arg}>{input[i]}</color>");
			}
			return stringBuilder.ToString();
		}
	}
}
namespace AFKTextFX.UI
{
	public class TextFXUI
	{
		private bool showGUI = false;

		private Rect guiRect = new Rect(0f, 0f, 420f, 200f);

		private string lobbyNameColorInput = ConfigManager.LobbyNameColor;

		private string hexPlayerNameColorInput = ConfigManager.PlayerNameColor;

		private string rankInput = ConfigManager.Rank;

		private string hexMessageColorInput = ConfigManager.MessageColor;

		private Color currentLobbyNameColorPreviewColor = Color.white;

		private Texture2D playerLobbyColorPreviewTexture;

		private Color currentPlayerNameColorPreviewColor = Color.white;

		private Texture2D playerNameColorPreviewTexture;

		private Color currentMessageColorPreviewColor = Color.white;

		private Texture2D messageColorPreviewTexture;

		private bool isLobbyNameRainbow = false;

		private bool isPlayerNameRainbow = false;

		private bool isMessageColorRainbow = false;

		public TextFXUI()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_0058: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00a5: 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_00c9: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			playerLobbyColorPreviewTexture = new Texture2D(1, 1);
			playerLobbyColorPreviewTexture.SetPixel(0, 0, Color.white);
			playerLobbyColorPreviewTexture.Apply();
			playerNameColorPreviewTexture = new Texture2D(1, 1);
			playerNameColorPreviewTexture.SetPixel(0, 0, Color.white);
			playerNameColorPreviewTexture.Apply();
			messageColorPreviewTexture = new Texture2D(1, 1);
			messageColorPreviewTexture.SetPixel(0, 0, Color.white);
			messageColorPreviewTexture.Apply();
			UpdateColorPreview();
		}

		public void Update()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(ConfigManager.UIToggleKey))
			{
				showGUI = !showGUI;
			}
			if (showGUI && Input.GetKeyDown((KeyCode)27))
			{
				showGUI = false;
			}
		}

		public void OnGUI()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (showGUI)
			{
				guiRect = GUI.Window(0, guiRect, new WindowFunction(DrawGuiWindow), "AFK Text FX Tool");
				UpdateColorPreview();
			}
		}

		private void UpdateColorPreview()
		{
			//IL_004e: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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)
			if (!isLobbyNameRainbow)
			{
				string text = lobbyNameColorInput.TrimStart('#').ToUpper();
				Color val = default(Color);
				if (text.Length == 6 && ColorUtility.TryParseHtmlString("#" + text, ref val))
				{
					currentLobbyNameColorPreviewColor = val;
				}
				else
				{
					currentLobbyNameColorPreviewColor = Color.clear;
				}
			}
			if (!isPlayerNameRainbow)
			{
				string text2 = hexPlayerNameColorInput.TrimStart('#').ToUpper();
				Color val2 = default(Color);
				if (text2.Length == 6 && ColorUtility.TryParseHtmlString("#" + text2, ref val2))
				{
					currentPlayerNameColorPreviewColor = val2;
				}
				else
				{
					currentPlayerNameColorPreviewColor = Color.clear;
				}
			}
			if (!isMessageColorRainbow)
			{
				string text3 = hexMessageColorInput.TrimStart('#').ToUpper();
				Color val3 = default(Color);
				if (text3.Length == 6 && ColorUtility.TryParseHtmlString("#" + text3, ref val3))
				{
					currentMessageColorPreviewColor = val3;
				}
				else
				{
					currentMessageColorPreviewColor = Color.clear;
				}
			}
		}

		private void DrawGuiWindow(int windowID)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: 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_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			GUI.Label(new Rect(20f, 30f, 120f, 20f), "Lobby Name Color:");
			lobbyNameColorInput = GUI.TextField(new Rect(150f, 30f, 100f, 20f), lobbyNameColorInput);
			isLobbyNameRainbow = GUI.Toggle(new Rect(260f, 30f, 20f, 20f), isLobbyNameRainbow, "");
			GUI.Label(new Rect(280f, 30f, 60f, 20f), "Rainbow");
			if (!isLobbyNameRainbow)
			{
				if (currentLobbyNameColorPreviewColor != Color.clear)
				{
					GUI.color = currentLobbyNameColorPreviewColor;
					GUI.DrawTexture(new Rect(340f, 30f, 20f, 20f), (Texture)(object)playerLobbyColorPreviewTexture);
					GUI.color = Color.white;
				}
				else
				{
					GUI.Label(new Rect(340f, 30f, 80f, 20f), "Invalid hex");
				}
			}
			GUI.Label(new Rect(20f, 60f, 120f, 20f), "Player Name Color:");
			hexPlayerNameColorInput = GUI.TextField(new Rect(150f, 60f, 100f, 20f), hexPlayerNameColorInput);
			isPlayerNameRainbow = GUI.Toggle(new Rect(260f, 60f, 20f, 20f), isPlayerNameRainbow, "");
			GUI.Label(new Rect(280f, 60f, 60f, 20f), "Rainbow");
			if (!isPlayerNameRainbow)
			{
				if (currentPlayerNameColorPreviewColor != Color.clear)
				{
					GUI.color = currentPlayerNameColorPreviewColor;
					GUI.DrawTexture(new Rect(340f, 60f, 20f, 20f), (Texture)(object)playerNameColorPreviewTexture);
					GUI.color = Color.white;
				}
				else
				{
					GUI.Label(new Rect(340f, 60f, 80f, 20f), "Invalid hex");
				}
			}
			GUI.Label(new Rect(20f, 90f, 100f, 20f), "Custom Rank:");
			rankInput = GUI.TextField(new Rect(150f, 90f, 200f, 20f), rankInput);
			GUI.Label(new Rect(20f, 120f, 100f, 20f), "Chat Color:");
			hexMessageColorInput = GUI.TextField(new Rect(150f, 120f, 100f, 20f), hexMessageColorInput);
			isMessageColorRainbow = GUI.Toggle(new Rect(260f, 120f, 20f, 20f), isMessageColorRainbow, "");
			GUI.Label(new Rect(280f, 120f, 60f, 20f), "Rainbow");
			if (!isMessageColorRainbow)
			{
				if (currentMessageColorPreviewColor != Color.clear)
				{
					GUI.color = currentMessageColorPreviewColor;
					GUI.DrawTexture(new Rect(340f, 120f, 20f, 20f), (Texture)(object)messageColorPreviewTexture);
					GUI.color = Color.white;
				}
				else
				{
					GUI.Label(new Rect(340f, 120f, 80f, 20f), "Invalid hex");
				}
			}
			if (GUI.Button(new Rect(150f, 160f, 100f, 30f), "Apply"))
			{
				string text = lobbyNameColorInput.TrimStart('#').ToUpper();
				string text2 = hexPlayerNameColorInput.TrimStart('#').ToUpper();
				string text3 = hexMessageColorInput.TrimStart('#').ToUpper();
				Plugin.Logger.LogInfo((object)("Lobby Name Color: " + (isLobbyNameRainbow ? "RAINBOW" : ("#" + text))));
				Plugin.Logger.LogInfo((object)("Player Name Color: " + (isPlayerNameRainbow ? "RAINBOW" : ("#" + text2))));
				Plugin.Logger.LogInfo((object)("Custom Rank: " + rankInput));
				Plugin.Logger.LogInfo((object)("Chat Color: " + (isMessageColorRainbow ? "RAINBOW" : ("#" + text3))));
				ConfigManager.SetLobbyNameColor(text);
				ConfigManager.SetPlayerNameColor(text2);
				ConfigManager.SetRank(rankInput);
				ConfigManager.SetMessageColor(text3);
				ConfigManager.SetIsLobbyNameColorRainbow(isLobbyNameRainbow);
				ConfigManager.SetIsPlayerNameColorRainbow(isPlayerNameRainbow);
				ConfigManager.SetIsMessageColorRainbow(isMessageColorRainbow);
				showGUI = false;
			}
			if (GUI.Button(new Rect(260f, 160f, 100f, 30f), "Reset"))
			{
				ConfigManager.Reset();
				lobbyNameColorInput = ConfigManager.LobbyNameColor;
				hexPlayerNameColorInput = ConfigManager.PlayerNameColor;
				rankInput = ConfigManager.Rank;
				hexMessageColorInput = ConfigManager.MessageColor;
				isLobbyNameRainbow = false;
				isPlayerNameRainbow = false;
				isMessageColorRainbow = false;
				UpdateColorPreview();
			}
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
		}
	}
}
namespace AFKTextFX.Patches
{
	[HarmonyPatch(typeof(BootstrapNetworkManager), "ionknowbruhther")]
	public class IonknowbruhtherPatch
	{
		[CompilerGenerated]
		private sealed class <CustomWaitforClientToStart>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MonoBehaviour instance;

			public string PlayerName;

			private FieldInfo <cooldownField>5__1;

			private float <cooldown>5__2;

			private MethodInfo <call>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <CustomWaitforClientToStart>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<cooldownField>5__1 = null;
				<call>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!AccessTools.Property(((object)instance).GetType(), "IsClientInitialized").GetValue(instance).Equals(true))
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<cooldownField>5__1 = AccessTools.Field(((object)instance).GetType(), "cooldown");
				<cooldown>5__2 = (float)<cooldownField>5__1.GetValue(instance);
				if (Time.time - <cooldown>5__2 > 1f)
				{
					<cooldownField>5__1.SetValue(instance, Time.time);
					<call>5__3 = AccessTools.Method(((object)instance).GetType(), "ServerJoinHatsCall", (Type[])null, (Type[])null);
					MethodInfo methodInfo = <call>5__3;
					MonoBehaviour obj = instance;
					object[] obj2 = new object[3]
					{
						PlayerName,
						ConfigManager.RankToSend(),
						null
					};
					CSteamID steamID = SteamUser.GetSteamID();
					obj2[2] = ((object)(CSteamID)(ref steamID)).ToString();
					methodInfo.Invoke(obj, obj2);
					<call>5__3 = null;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static bool Prefix(object __instance, string PlayerName)
		{
			//IL_0003: 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)
			//IL_0014: Expected O, but got Unknown
			try
			{
				((MonoBehaviour)__instance).StartCoroutine(CustomWaitforClientToStart((MonoBehaviour)__instance, PlayerName));
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("Error in [AFKTextFX] - IonknowbruhtherPatch: " + ex.Message));
				return true;
			}
		}

		[IteratorStateMachine(typeof(<CustomWaitforClientToStart>d__1))]
		private static IEnumerator CustomWaitforClientToStart(MonoBehaviour instance, string PlayerName)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <CustomWaitforClientToStart>d__1(0)
			{
				instance = instance,
				PlayerName = PlayerName
			};
		}
	}
	[HarmonyPatch(typeof(MainMenuManagerNetworked), "JoinTeam")]
	public class JoinTeamPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(MainMenuManagerNetworked __instance, string playername, int teamtojoin)
		{
			try
			{
				AccessTools.Field(typeof(MainMenuManagerNetworked), "localplayername").SetValue(__instance, playername);
				int num = (int)AccessTools.Field(typeof(MainMenuManagerNetworked), "currentLocalTeam").GetValue(__instance);
				if (teamtojoin != num)
				{
					string text = ConfigManager.RankToSendJoinTeam();
					MethodInfo methodInfo = AccessTools.Method(typeof(MainMenuManagerNetworked), "ServerJoinTeam", (Type[])null, (Type[])null);
					methodInfo.Invoke(__instance, new object[3] { playername, teamtojoin, text });
				}
				else
				{
					__instance.mmm.hasSwappedteam = true;
				}
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("Error in [AFKTextFX] - JoinTeamPatch: " + ex.Message));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(BootstrapManager), "OnLobbyCreated")]
	public class OnLobbyCreatedPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(BootstrapManager __instance, LobbyCreated_t callback)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_007b: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//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)
			try
			{
				Plugin.Logger.LogInfo((object)("Starting lobby creation: " + ((object)(EResult)(ref callback.m_eResult)).ToString()));
				if ((int)callback.m_eResult != 1)
				{
					Plugin.Logger.LogDebug((object)"[AFKTextFX] Lobby creation failed.");
					return true;
				}
				Type type = ((object)__instance).GetType();
				AccessTools.Field(type, "haslobbyStarted")?.SetValue(__instance, false);
				CSteamID val = default(CSteamID);
				((CSteamID)(ref val))..ctor(callback.m_ulSteamIDLobby);
				AccessTools.Field(type, "CurrentLobbyID")?.SetValue(__instance, callback.m_ulSteamIDLobby);
				CSteamID val2 = val;
				CSteamID steamID = SteamUser.GetSteamID();
				SteamMatchmaking.SetLobbyData(val2, "HostAddress", ((object)(CSteamID)(ref steamID)).ToString());
				string version = Application.version;
				SteamMatchmaking.SetLobbyData(val, "Version", version);
				string lobbyData = SteamMatchmaking.GetLobbyData(val, "Version");
				Plugin.Logger.LogDebug((object)("[AFKTextFX] Set version: " + version + " | Confirmed: " + lobbyData));
				SteamMatchmaking.SetLobbyData(val, "name", ConfigManager.LobbyName());
				if (AccessTools.Field(type, "CurrentLobbyNamesToSteamIDs")?.GetValue(__instance) is IDictionary dictionary)
				{
					dictionary[SteamUser.GetSteamID()] = SteamFriends.GetPersonaName();
				}
				bool flag = (bool)(AccessTools.Field(type, "islobbyprivate")?.GetValue(__instance) ?? ((object)false));
				SteamMatchmaking.SetLobbyData(val, "closed", flag ? "2" : "0");
				object obj = AccessTools.Field(type, "_fishySteamworks")?.GetValue(__instance);
				if (obj != null)
				{
					MethodInfo methodInfo = AccessTools.Method(obj.GetType(), "SetClientAddress", (Type[])null, (Type[])null);
					if ((object)methodInfo != null)
					{
						object[] array = new object[1];
						steamID = SteamUser.GetSteamID();
						array[0] = ((object)(CSteamID)(ref steamID)).ToString();
						methodInfo.Invoke(obj, array);
					}
					AccessTools.Method(obj.GetType(), "StartConnection", (Type[])null, (Type[])null)?.Invoke(obj, new object[1] { true });
				}
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("Error in [AFKTextFX] - OnLobbyCreatedPatch: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(MainMenuManager), "SendLobbyChatMessage")]
	public class SendLobbyChatMessagePatch
	{
		[HarmonyPrefix]
		public static bool Prefix(MainMenuManagerNetworked __instance, ref float ___chatcd, TMP_InputField ___chatInputFieldText)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Time.time - ___chatcd > 0.1f && !string.IsNullOrWhiteSpace(___chatInputFieldText.text))
				{
					___chatcd = Time.time;
					string messageColor = ConfigManager.MessageColor;
					string text = ___chatInputFieldText.text;
					string s = (ConfigManager.IsMessageColorRainbow ? RichTextUtils.ToRainbowRichText(text) : ((!(messageColor == ConfigManager.DEFAULT_COLOR)) ? ("<color=#" + messageColor + ">" + text + "</color>") : text));
					byte[] bytes = Encoding.UTF8.GetBytes(s);
					SteamMatchmaking.SendLobbyChatMsg(new CSteamID(BootstrapManager.CurrentLobbyID), bytes, bytes.Length);
					___chatInputFieldText.text = "";
				}
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("Error in [AFKTextFX] - JoinTeamPatch: " + ex.Message));
				return true;
			}
		}
	}
}
namespace AFKTextFX.Data
{
	public static class BannedWordsManager
	{
		private static HashSet<string> bannedWords = new HashSet<string>();

		private static HashSet<string> heavyFilteringBannedWords = new HashSet<string>();

		private static readonly Dictionary<char, char> substitutionMap = new Dictionary<char, char>
		{
			{ '0', 'o' },
			{ '1', 'i' },
			{ '3', 'e' },
			{ '4', 'a' },
			{ '5', 's' },
			{ '7', 't' },
			{ '8', 'b' },
			{ '9', 'g' },
			{ '@', 'a' },
			{ '$', 's' },
			{ '!', 'i' },
			{ '|', 'i' },
			{ '6', 'g' },
			{ '2', 'z' },
			{ '+', 't' },
			{ '(', 'c' },
			{ 'α', 'a' },
			{ 'β', 'b' },
			{ 'ε', 'e' },
			{ 'ο', 'o' },
			{ 'ρ', 'p' },
			{ 'σ', 's' },
			{ 'τ', 't' },
			{ 'υ', 'u' },
			{ 'ν', 'v' },
			{ 'κ', 'k' },
			{ 'η', 'n' },
			{ 'μ', 'm' }
		};

		public static void LoadBannedWords()
		{
			LoadWordList("AFKTextFX.banned_words.txt", bannedWords);
			LoadWordList("AFKTextFX.heavy_filtered_banned_words.txt", heavyFilteringBannedWords);
		}

		private static void LoadWordList(string resourceName, HashSet<string> targetSet)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			using Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
			if (stream == null)
			{
				Plugin.Logger.LogError((object)("Could not find embedded resource: " + resourceName));
				return;
			}
			using StreamReader streamReader = new StreamReader(stream);
			while (!streamReader.EndOfStream)
			{
				string text = streamReader.ReadLine()?.Trim();
				if (!string.IsNullOrEmpty(text) && !text.StartsWith("#"))
				{
					string[] array = NormalizeMessage(text.ToLower()).Split(' ');
					foreach (string item in array)
					{
						targetSet.Add(item);
					}
				}
			}
		}

		public static bool ContainsBannedWord(string message)
		{
			string text = NormalizeMessage(message);
			string[] array = text.Split(' ', StringSplitOptions.RemoveEmptyEntries);
			foreach (string text2 in array)
			{
				if (bannedWords.Contains(text2) || bannedWords.Contains(RemoveConsecutiveDuplicates(text2)))
				{
					return true;
				}
			}
			foreach (string heavyFilteringBannedWord in heavyFilteringBannedWords)
			{
				if (RemoveConsecutiveDuplicates(text).Contains(heavyFilteringBannedWord))
				{
					return true;
				}
			}
			foreach (string heavyFilteringBannedWord2 in heavyFilteringBannedWords)
			{
				if (IsSubsequence(heavyFilteringBannedWord2, RemoveConsecutiveDuplicates(text)))
				{
					return true;
				}
			}
			return false;
		}

		private static bool IsSubsequence(string word, string input)
		{
			int num = 0;
			foreach (char c in input)
			{
				if (c == word[num])
				{
					num++;
					if (num == word.Length)
					{
						return true;
					}
				}
			}
			return false;
		}

		private static string RemoveConsecutiveDuplicates(string input)
		{
			if (string.IsNullOrEmpty(input))
			{
				return input;
			}
			StringBuilder stringBuilder = new StringBuilder();
			char c = '\0';
			foreach (char c2 in input)
			{
				if (c2 != c)
				{
					stringBuilder.Append(c2);
					c = c2;
				}
			}
			return stringBuilder.ToString();
		}

		private static string NormalizeMessage(string input)
		{
			input = Regex.Replace(input, "<.*?>", "");
			input = input.ToLowerInvariant();
			input = input.Normalize(NormalizationForm.FormD);
			StringBuilder stringBuilder = new StringBuilder();
			string text = input;
			foreach (char c in text)
			{
				UnicodeCategory unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
				if (unicodeCategory != UnicodeCategory.NonSpacingMark)
				{
					if (substitutionMap.TryGetValue(c, out var value))
					{
						stringBuilder.Append(value);
					}
					else
					{
						stringBuilder.Append(c);
					}
				}
			}
			return Regex.Replace(stringBuilder.ToString(), "[^a-z0-9]+", "");
		}
	}
	public static class ConfigManager
	{
		public static string DEFAULT_COLOR = "A2A19A";

		private static ConfigEntry<KeyCode> _uiToggleKey;

		private static ConfigEntry<string> _rank;

		private static ConfigEntry<string> _playerNameColor;

		private static ConfigEntry<string> _lobbyNameColor;

		private static ConfigEntry<string> _messageColor;

		private static ConfigEntry<bool> _isLobbyNameColorRainbow;

		private static ConfigEntry<bool> _isMessageColorRainbow;

		private static ConfigEntry<bool> _isPlayerNameColorRainbow;

		public static KeyCode UIToggleKey => _uiToggleKey.Value;

		public static string Rank => _rank.Value;

		public static string PlayerNameColor => _playerNameColor.Value;

		public static string LobbyNameColor => _lobbyNameColor.Value;

		public static string MessageColor => _messageColor.Value;

		public static bool IsLobbyNameColorRainbow => _isLobbyNameColorRainbow.Value;

		public static bool IsPlayerNameColorRainbow => _isPlayerNameColorRainbow.Value;

		public static bool IsMessageColorRainbow => _isMessageColorRainbow.Value;

		public static void Init(ConfigFile config)
		{
			_uiToggleKey = config.Bind<KeyCode>("AFKTextFX", "UIToggleKey", (KeyCode)282, "Key to toggle the AFKTextFX UI");
			_rank = config.Bind<string>("AFKTextFX", "CustomRank", getDefaultRankText(), "Rank");
			_playerNameColor = config.Bind<string>("AFKTextFX", "PlayerNameColor", DEFAULT_COLOR, "Player name color");
			_lobbyNameColor = config.Bind<string>("AFKTextFX", "LobbyNameColor", DEFAULT_COLOR, "Lobby name color");
			_messageColor = config.Bind<string>("AFKTextFX", "MessageColor", DEFAULT_COLOR, "Color of chat messages sent");
			_isLobbyNameColorRainbow = config.Bind<bool>("AFKTextFX", "IsLobbyNameColorRainbow", false, "If true, lobby name will be rainbow colored");
			_isMessageColorRainbow = config.Bind<bool>("AFKTextFX", "IsMessageColorRainbow", false, "If true, chat messages will be rainbow colored");
			_isPlayerNameColorRainbow = config.Bind<bool>("AFKTextFX", "IsPlayerNameColorRainbow", false, "If true, player name will be rainbow colored");
		}

		public static string RankToSendJoinTeam()
		{
			if (PlayerNameColor == DEFAULT_COLOR && !IsPlayerNameColorRainbow)
			{
				return Rank;
			}
			string text = getDefaultPlayerName();
			if (IsPlayerNameColorRainbow)
			{
				text = RichTextUtils.ToRainbowRichText(getDefaultPlayerName());
			}
			return "<b><size=29><color=#" + PlayerNameColor + ">" + text + "</color></size></b>\n" + Rank + "\n\n";
		}

		public static string RankToSend()
		{
			if (PlayerNameColor == DEFAULT_COLOR && !IsPlayerNameColorRainbow)
			{
				return Rank;
			}
			string text = getDefaultPlayerName();
			if (IsPlayerNameColorRainbow)
			{
				text = RichTextUtils.ToRainbowRichText(getDefaultPlayerName());
			}
			return "<b><size=21><color=#" + PlayerNameColor + ">" + text + "</color></size></b>\n" + Rank + "\n\n";
		}

		public static string LobbyName()
		{
			if (IsLobbyNameColorRainbow)
			{
				return RichTextUtils.ToRainbowRichText(getDefaultLobbyName());
			}
			if (LobbyNameColor != DEFAULT_COLOR)
			{
				return "<color=" + LobbyNameColor + ">" + getDefaultLobbyName() + "</color>";
			}
			return getDefaultLobbyName();
		}

		public static void SetRank(string rank)
		{
			if (BannedWordsManager.ContainsBannedWord(rank))
			{
				_rank.Value = "RankContainsBannedWord";
			}
			else
			{
				_rank.Value = rank;
			}
		}

		public static void SetPlayerNameColor(string hexColor)
		{
			Color val = default(Color);
			if (ColorUtility.TryParseHtmlString("#" + hexColor.TrimStart('#'), ref val))
			{
				_playerNameColor.Value = hexColor;
				SetRank(Rank);
				return;
			}
			throw new ArgumentException("Invalid color format. Use hex format like 'FFFFFF'.");
		}

		public static void SetLobbyNameColor(string hexColor)
		{
			Color val = default(Color);
			if (ColorUtility.TryParseHtmlString("#" + hexColor.TrimStart('#'), ref val))
			{
				_lobbyNameColor.Value = hexColor;
				return;
			}
			throw new ArgumentException("Invalid color format. Use hex format like 'FFFFFF'.");
		}

		public static void SetMessageColor(string hexColor)
		{
			Color val = default(Color);
			if (ColorUtility.TryParseHtmlString("#" + hexColor.TrimStart('#'), ref val))
			{
				_messageColor.Value = hexColor;
				return;
			}
			throw new ArgumentException("Invalid color format. Use hex format like 'FFFFFF'.");
		}

		public static void SetIsLobbyNameColorRainbow(bool isRainbow)
		{
			_isLobbyNameColorRainbow.Value = isRainbow;
		}

		public static void SetIsPlayerNameColorRainbow(bool isRainbow)
		{
			_isPlayerNameColorRainbow.Value = isRainbow;
		}

		public static void SetIsMessageColorRainbow(bool isRainbow)
		{
			_isMessageColorRainbow.Value = isRainbow;
		}

		private static string getDefaultLobbyName()
		{
			return getDefaultPlayerName() + "'s Lobby";
		}

		private static string getDefaultPlayerName()
		{
			try
			{
				return SteamFriends.GetPersonaName();
			}
			catch (Exception)
			{
				return "DefaultPlayerName";
			}
		}

		private static string getDefaultRankText()
		{
			try
			{
				string text = "lvl ";
				int num = default(int);
				text = ((!SteamUserStats.GetStat("level", ref num)) ? (text + 0) : (text + num));
				Type typeFromHandle = typeof(BootstrapNetworkManager);
				Type nestedType = typeFromHandle.GetNestedType("WizardRank", BindingFlags.NonPublic);
				int num2 = default(int);
				return (!SteamUserStats.GetStat("rank", ref num2)) ? (text + " Lacky") : (text + " " + Enum.ToObject(nestedType, Mathf.Clamp(num2, 0, 9)));
			}
			catch (Exception)
			{
				return "DefaultRank";
			}
		}

		public static void Reset()
		{
			_rank.Value = getDefaultRankText();
			_playerNameColor.Value = DEFAULT_COLOR;
			_lobbyNameColor.Value = DEFAULT_COLOR;
			_messageColor.Value = DEFAULT_COLOR;
			_isLobbyNameColorRainbow.Value = false;
			_isPlayerNameColorRainbow.Value = false;
			_isMessageColorRainbow.Value = false;
		}
	}
}