Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ChatBox v2.1.0
ChatBox.dll
Decompiled 2 weeks agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ChatBox.NonPatch; using ChatBox.Patch; using ChatBox.Single; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using TMPro; using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ChatBox")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9917392cb9b9e3d729c4d639188ce8fc3183ed3e")] [assembly: AssemblyProduct("ChatBox")] [assembly: AssemblyTitle("ChatBox")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 ChatBox { public static class API { private static bool registered; public static event Action? OnCommandRegistration; internal static void RegisterAllCommands() { if (!registered) { API.OnCommandRegistration?.Invoke(); registered = true; CommandRegistry.IsFrozen = true; } } public static string GetLocalPlayerColorSafeRelay() { if ((Object)(object)NonPatches.Instance != (Object)null) { return NonPatches.Instance.GetLocalPlayerColorSafe(); } ChatBox.logger.LogError((object)"Attempted to get local player color while the instance is null... -> Attempt blocked!"); return ""; } public static string GetLobbyPlayerNameSafeRelay(int index) { if ((Object)(object)NonPatches.Instance != (Object)null) { return NonPatches.Instance.GetLobbyPlayerNameSafe(index); } ChatBox.logger.LogError((object)"Attempted to get lobby player name while the instance is null... -> Attempt blocked!"); return ""; } public static int ConvertPlayerIdToIndexRelay(string playerId) { if ((Object)(object)NonPatches.Instance != (Object)null) { return NonPatches.Instance.ConvertPlayerIdToIndex(playerId); } ChatBox.logger.LogError((object)"Attempted to convert player id to an index/replacer while the instance is null... -> Attempt blocked!"); return 999; } public static Player GetLobbyPlayerObjSafeRelay(int index) { if ((Object)(object)NonPatches.Instance != (Object)null) { return NonPatches.Instance.GetLobbyPlayerObjSafe(index); } ChatBox.logger.LogError((object)"Attempted to get lobby player object while the instance is null... -> Attempt blocked!"); return null; } public static void AddChatMessageSystemRelay(string chatMessage, string nameHexColor, string senderName) { if ((Object)(object)NonPatches.Instance != (Object)null) { NonPatches.Instance.AddChatMessageSystem(chatMessage, nameHexColor, senderName); } else { ChatBox.logger.LogError((object)"Attempted to add a chat message while the instance is null... -> Attempt blocked!"); } } public static void AddChatMessageRelay(string chatMessage, string nameHexColor, string senderName) { if ((Object)(object)NonPatches.Instance != (Object)null) { NonPatches.Instance.AddChatMessage(chatMessage, nameHexColor, senderName); } else { ChatBox.logger.LogError((object)"Attempted to add a chat message while the instance is null... -> Attempt blocked!"); } } public static void RegisterCommand(CommandContainer container) { if (CommandRegistry.IsFrozen) { ChatBox.logger.LogError((object)"The registry is frozen... Registration attempt blocked!"); } else if (Utility.IsNullOrWhiteSpace(container.CommandKeyword)) { ChatBox.logger.LogError((object)"The command keyword is null!"); } else if (container.CommandKeyword.StartsWith('!')) { ChatBox.logger.LogError((object)"Invalid command format!"); } else if (CommandRegistry.Registry.ContainsKey(container.CommandKeyword)) { ChatBox.logger.LogError((object)"Attempted to register an already registered command... The attempt has been blocked!"); } else { CommandRegistry.Registry.Add(container.CommandKeyword, container); } } } public class CommandContainer { internal string CommandKeyword; internal Action CommandAction; internal Action<string[]> CommandActionStringArray; internal bool IsHostOnly = false; public CommandContainer(string keyword, bool hostOnly, Action action) { CommandKeyword = keyword.ToLower(); CommandAction = action; IsHostOnly = hostOnly; } public CommandContainer(string keyword, bool hostOnly, Action<string[]> action) { CommandKeyword = keyword.ToLower(); CommandActionStringArray = action; IsHostOnly = hostOnly; } } internal static class CommandRegistry { internal static Dictionary<string, CommandContainer> Registry = new Dictionary<string, CommandContainer> { { "clearchat", new CommandContainer("clearchat", hostOnly: true, (Action)delegate { NonPatches.ClearChatRpc(); }) }, { "printcodes", new CommandContainer("printcodes", hostOnly: false, (Action)delegate { NonPatches.PrintAndWritePlayerCodes(); }) }, { "whisper", new CommandContainer("whisper", hostOnly: false, delegate(string[] data) { NonPatches.DoWhisper(data); }) } }; internal static bool IsFrozen = false; internal static bool CheckForCommand(string keyword) { if (keyword.StartsWith('!')) { string[] array = keyword.Split(' '); if (!Registry.TryGetValue(array[0].Replace("!", "").ToLower(), out CommandContainer value)) { ChatBox.logger.LogError((object)"The requested command does not exist!"); return false; } List<string> list = array.ToList(); if (list.Remove(array[0])) { array = list.ToArray(); } if (value.CommandAction == null && value.CommandActionStringArray != null) { if (PhotonNetwork.IsMasterClient == value.IsHostOnly) { NonPatches.isCommand = true; value.CommandActionStringArray(array); return true; } if (PhotonNetwork.IsMasterClient && !value.IsHostOnly) { NonPatches.isCommand = true; value.CommandActionStringArray(array); return true; } } else if (value.CommandAction != null && value.CommandActionStringArray == null) { if (PhotonNetwork.IsMasterClient == value.IsHostOnly) { NonPatches.isCommand = true; value.CommandAction(); return true; } if (PhotonNetwork.IsMasterClient && !value.IsHostOnly) { NonPatches.isCommand = true; value.CommandAction(); return true; } } else { ChatBox.logger.LogError((object)"Command execution denied! -> No action defined!"); } } return false; } } internal class ConfigManager { public ExtendedConfigEntry<bool> EnableConfiguration; public ExtendedConfigEntry<bool> proximityChat; public ExtendedConfigEntry<float> proximityRange; public ExtendedConfigEntry<bool> outOfRangeMessage; public ExtendedConfigEntry<float> lateTargetAlpha; public ExtendedConfigEntry<bool> startMessageEnabled; public ExtendedConfigEntry<float> fadeDelay; public ExtendedConfigEntry<float> startAlpha; public ExtendedConfigEntry<int> messageLimit; public ExtendedConfigEntry<float> chatBox_X; public ExtendedConfigEntry<float> chatBox_Y; public ExtendedConfigEntry<bool> deadPlayerTransmitBlock; public ConfigManager() { BindConfigs(); ClearUnusedEntries(); } private void BindConfigs() { EnableConfiguration = new ExtendedConfigEntry<bool>("General Settings", "EnableConfiguration", defaultValue: false, "Enable if you want to use custom set config setting values. If disabled, the default config setting values will be used."); proximityChat = new ExtendedConfigEntry<bool>("General Settings", "ProximityChat", defaultValue: false, "If enabled, your messages will only send to players that are within the set range of your position.", useEnableConfiguration: true); proximityRange = new ExtendedConfigEntry<float>("General Settings", "ProximityRange", 20f, "Transmit range of the proximity chat.", useEnableConfiguration: true); outOfRangeMessage = new ExtendedConfigEntry<bool>("General Settings", "OutOfRangeMessage", defaultValue: false, "If message sender is further than the set range, you will receive an error message in the chat instead of the message being ignored completely.", useEnableConfiguration: true); lateTargetAlpha = new ExtendedConfigEntry<float>("General Settings", "AfterFadeVisibility", 0.2f, "How visible the chat box is going to be after fading.", useEnableConfiguration: true); startMessageEnabled = new ExtendedConfigEntry<bool>("General Settings", "StartMessageEnabled", defaultValue: true, "If enabled, TAXMAN will post 'ChatBox active!' in the chat each time a level starts.", useEnableConfiguration: true); fadeDelay = new ExtendedConfigEntry<float>("General Settings", "FadeDelay", 4f, "How long the chat box will stay visible before fading.", useEnableConfiguration: true); startAlpha = new ExtendedConfigEntry<float>("General Settings", "BeforeFadeVisibility", 1f, "How visible the chat box is going to be before fading.", useEnableConfiguration: true); messageLimit = new ExtendedConfigEntry<int>("General Settings", "MessageLimit", 4, "How many messages will be shown on the screen.", useEnableConfiguration: true); chatBox_X = new ExtendedConfigEntry<float>("General Settings", "ChatBox_X", 107f, "ChatBox X position.", useEnableConfiguration: true); chatBox_Y = new ExtendedConfigEntry<float>("General Settings", "ChatBox_Y", 100f, "ChatBox Y position.", useEnableConfiguration: true); deadPlayerTransmitBlock = new ExtendedConfigEntry<bool>("General Settings", "DeadPlayerTransmitBlock", defaultValue: false, "If enabled, you won't be able to send messages when dead.", useEnableConfiguration: true); } private void ClearUnusedEntries() { ConfigFile config = ((BaseUnityPlugin)ChatBox.Instance).Config; PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(config, null); dictionary.Clear(); config.Save(); } } internal class ExtendedConfigEntry<T> { internal ConfigEntry<T> ConfigEntry; internal Func<T> GetValue; internal Action<T> SetValue; internal bool UseEnableConfiguration = false; internal T DefaultValue => (T)((ConfigEntryBase)ConfigEntry).DefaultValue; internal T Value { get { return GetValue(); } set { SetValue(value); } } internal ExtendedConfigEntry(string section, string key, T defaultValue, string description, bool useEnableConfiguration = false) { ConfigEntry = ((BaseUnityPlugin)ChatBox.Instance).Config.Bind<T>(section, key, defaultValue, description); UseEnableConfiguration = useEnableConfiguration; Initialize(); } internal ExtendedConfigEntry(string section, string key, T defaultValue, ConfigDescription configDescription = null, bool useEnableConfiguration = false) { ConfigEntry = ((BaseUnityPlugin)ChatBox.Instance).Config.Bind<T>(section, key, defaultValue, configDescription); UseEnableConfiguration = useEnableConfiguration; Initialize(); } private void Initialize() { if (GetValue == null) { GetValue = () => (UseEnableConfiguration && !ChatBox.ConfigManager.EnableConfiguration.Value) ? DefaultValue : ConfigEntry.Value; } if (SetValue == null) { SetValue = delegate(T value) { ConfigEntry.Value = value; }; } } public void ResetToDefault() { ConfigEntry.Value = (T)((ConfigEntryBase)ConfigEntry).DefaultValue; } } [BepInPlugin("ChatBox-UnloadedHangar", "ChatBox", "2.1.0")] public class ChatBox : BaseUnityPlugin { public static class PluginInfo { public const string Guid = "ChatBox-UnloadedHangar"; public const string Name = "ChatBox"; public const string Ver = "2.1.0"; } internal static ManualLogSource logger; internal static ChatBox Instance; internal static ConfigManager ConfigManager; private Harmony _harmony; private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } logger = Logger.CreateLogSource("ChatBox-UnloadedHangar"); logger.LogInfo((object)"ChatBox-UnloadedHangar loaded"); ConfigManager = new ConfigManager(); _harmony = new Harmony("ChatBox-UnloadedHangar"); _harmony.PatchAll(typeof(Patches)); } } internal class Singleton<T> : MonoBehaviour where T : Component { private static T _instance; public static T Instance { get { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { T[] array = Object.FindObjectsOfType(typeof(T)) as T[]; if (array.Length != 0) { _instance = array[0]; } if (array.Length > 1) { ChatBox.logger.LogError((object)("There is more than one " + typeof(T).Name + " in the scene.")); } if ((Object)(object)_instance == (Object)null) { GameObject val = new GameObject(); ((Object)val).name = "_" + typeof(T).Name; _instance = val.AddComponent<T>(); } } return _instance; } } } } namespace ChatBox.NonPatch { internal class NonPatches : MonoBehaviour { internal static bool isCommand; public string lastChatMessage = ""; public List<string> ChatMessageHistory = new List<string>(); internal string MessageText = ""; internal string MessageTextInserted = ""; internal PhotonView photonView = null; internal static NonPatches Instance { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } } private void Start() { List<Patches> list = new List<Patches>(); MethodInfo[] methods = typeof(NonPatches).GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); List<MethodInfo> list2 = methods.ToList(); list2.AddRange(typeof(Patches).GetMethods(BindingFlags.Static | BindingFlags.NonPublic)); list2.AddRange(typeof(ChatObject).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)); list2.AddRange(typeof(ExtendedConfigEntry<>).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)); list2.AddRange(typeof(ConfigManager).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)); list2.AddRange(typeof(API).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)); list2.AddRange(typeof(CommandRegistry).GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)); methods = list2.ToArray(); for (int i = 0; methods.Length > i; i++) { if (Harmony.GetPatchInfo((MethodBase)methods[i]) != null) { list.Add(Harmony.GetPatchInfo((MethodBase)methods[i])); } } for (int j = 0; list.Count > j; j++) { for (int k = 0; list[j].Owners.Count > k; k++) { if (list[j] == null) { return; } Harmony.UnpatchID(list[j].Owners[k]); } } } [Obsolete("Inefficient", true)] internal int CheckMessageLimit() { if (ChatBox.ConfigManager.messageLimit.Value.ToString().Contains("-")) { ChatBox.ConfigManager.messageLimit.Value = ChatBox.ConfigManager.messageLimit.DefaultValue; ChatBox.logger.LogWarning((object)"Negative number detected in MessageLimit variable, reseting to default value to avoid conflicts..."); return 1; } return 0; } internal void AddChatMessageSystemNoReplacer(string chatMessage, string hexColorOfPlayerWhoTyped, string nameOfUserWhoTyped = "") { lastChatMessage = chatMessage; FadeChatTarget(ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>(), ChatBox.ConfigManager.fadeDelay.Value, ChatBox.ConfigManager.startAlpha.Value, ChatBox.ConfigManager.lateTargetAlpha.Value); if ((float)ChatMessageHistory.Count >= Mathf.Clamp((float)ChatBox.ConfigManager.messageLimit.Value, 4f, float.PositiveInfinity)) { ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text.Remove(0, ChatMessageHistory[0].Length); ChatMessageHistory.Remove(ChatMessageHistory[0]); } string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("<color=#" + hexColorOfPlayerWhoTyped + "> " + nameOfUserWhoTyped + " </color>: <color=white> " + chatMessage + " </color>") : ("<color=#7069ff> " + chatMessage + " </color>")); ChatMessageHistory.Add(item); ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = ""; for (int i = 0; ChatMessageHistory.Count > i; i++) { TextMeshProUGUI component = ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).text = ((TMP_Text)component).text + "\n" + ChatMessageHistory[i]; } } internal void AddChatMessage(string chatMessage, string hexColorOfPlayerWhoTyped, string nameOfUserWhoTyped = "") { if (!(lastChatMessage == chatMessage)) { lastChatMessage = chatMessage; FadeChatTarget(ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>(), ChatBox.ConfigManager.fadeDelay.Value, ChatBox.ConfigManager.startAlpha.Value, ChatBox.ConfigManager.lateTargetAlpha.Value); if ((float)ChatMessageHistory.Count >= Mathf.Clamp((float)ChatBox.ConfigManager.messageLimit.Value, 4f, float.PositiveInfinity)) { ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text.Remove(0, ChatMessageHistory[0].Length); ChatMessageHistory.Remove(ChatMessageHistory[0]); } StringBuilder stringBuilder = new StringBuilder(chatMessage); stringBuilder.Replace("@player1", GetLobbyPlayerNameSafe(0)); stringBuilder.Replace("@player2", GetLobbyPlayerNameSafe(1)); stringBuilder.Replace("@player3", GetLobbyPlayerNameSafe(2)); stringBuilder.Replace("@player4", GetLobbyPlayerNameSafe(3)); stringBuilder.Replace("@player5", GetLobbyPlayerNameSafe(4)); stringBuilder.Replace("@player6", GetLobbyPlayerNameSafe(5)); chatMessage = stringBuilder.ToString(); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("<color=#" + hexColorOfPlayerWhoTyped + "> " + nameOfUserWhoTyped + " </color>: <color=white> " + chatMessage + " </color>") : ("<color=#7069ff> " + chatMessage + " </color>")); ChatMessageHistory.Add(item); ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = ""; for (int i = 0; ChatMessageHistory.Count > i; i++) { TextMeshProUGUI component = ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).text = ((TMP_Text)component).text + "\n" + ChatMessageHistory[i]; } } } internal void AddChatMessageSystem(string chatMessage, string hexColorOfPlayerWhoTyped, string nameOfUserWhoTyped = "") { lastChatMessage = chatMessage; FadeChatTarget(ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>(), ChatBox.ConfigManager.fadeDelay.Value, ChatBox.ConfigManager.startAlpha.Value, ChatBox.ConfigManager.lateTargetAlpha.Value); if ((float)ChatMessageHistory.Count >= Mathf.Clamp((float)ChatBox.ConfigManager.messageLimit.Value, 4f, float.PositiveInfinity)) { ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text.Remove(0, ChatMessageHistory[0].Length); ChatMessageHistory.Remove(ChatMessageHistory[0]); } StringBuilder stringBuilder = new StringBuilder(chatMessage); stringBuilder.Replace("@player1", GetLobbyPlayerNameSafe(0)); stringBuilder.Replace("@player2", GetLobbyPlayerNameSafe(1)); stringBuilder.Replace("@player3", GetLobbyPlayerNameSafe(2)); stringBuilder.Replace("@player4", GetLobbyPlayerNameSafe(3)); stringBuilder.Replace("@player5", GetLobbyPlayerNameSafe(4)); stringBuilder.Replace("@player6", GetLobbyPlayerNameSafe(5)); chatMessage = stringBuilder.ToString(); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("<color=#" + hexColorOfPlayerWhoTyped + "> " + nameOfUserWhoTyped + " </color>: <color=white> " + chatMessage + " </color>") : ("<color=#7069ff> " + chatMessage + " </color>")); ChatMessageHistory.Add(item); ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = ""; for (int i = 0; ChatMessageHistory.Count > i; i++) { TextMeshProUGUI component = ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).text = ((TMP_Text)component).text + "\n" + ChatMessageHistory[i]; } } internal void AddChatMessageDead(string chatMessage, string hexColorOfPlayerWhoTyped, string nameOfUserWhoTyped = "") { if (!(lastChatMessage == chatMessage)) { lastChatMessage = chatMessage; FadeChatTarget(ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>(), ChatBox.ConfigManager.fadeDelay.Value, ChatBox.ConfigManager.startAlpha.Value, ChatBox.ConfigManager.lateTargetAlpha.Value); if ((float)ChatMessageHistory.Count >= Mathf.Clamp((float)ChatBox.ConfigManager.messageLimit.Value, 4f, float.PositiveInfinity)) { ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text.Remove(0, ChatMessageHistory[0].Length); ChatMessageHistory.Remove(ChatMessageHistory[0]); } StringBuilder stringBuilder = new StringBuilder(chatMessage); stringBuilder.Replace("@player1", GetLobbyPlayerNameSafe(0)); stringBuilder.Replace("@player2", GetLobbyPlayerNameSafe(1)); stringBuilder.Replace("@player3", GetLobbyPlayerNameSafe(2)); stringBuilder.Replace("@player4", GetLobbyPlayerNameSafe(3)); stringBuilder.Replace("@player5", GetLobbyPlayerNameSafe(4)); stringBuilder.Replace("@player6", GetLobbyPlayerNameSafe(5)); chatMessage = stringBuilder.ToString(); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("<color=#" + hexColorOfPlayerWhoTyped + "><s> " + nameOfUserWhoTyped + " </color></s>: <color=white> " + chatMessage + " </color>") : ("<color=#7069ff> " + chatMessage + " </color>")); ChatMessageHistory.Add(item); ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = ""; for (int i = 0; ChatMessageHistory.Count > i; i++) { TextMeshProUGUI component = ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).text = ((TMP_Text)component).text + "\n" + ChatMessageHistory[i]; } } } [Obsolete] private void AddChatMessageGradient(string chatMessage, string hexColorOfPlayerWhoTyped, string nameOfUserWhoTyped = "") { lastChatMessage = chatMessage; FadeChatTarget(ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>(), ChatBox.ConfigManager.fadeDelay.Value, ChatBox.ConfigManager.startAlpha.Value, ChatBox.ConfigManager.lateTargetAlpha.Value); if ((float)ChatMessageHistory.Count >= Mathf.Clamp((float)ChatBox.ConfigManager.messageLimit.Value, 4f, float.PositiveInfinity)) { ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text.Remove(0, ChatMessageHistory[0].Length); ChatMessageHistory.Remove(ChatMessageHistory[0]); } StringBuilder stringBuilder = new StringBuilder(chatMessage); stringBuilder.Replace("@player1", GetLobbyPlayerNameSafe(0)); stringBuilder.Replace("@player2", GetLobbyPlayerNameSafe(1)); stringBuilder.Replace("@player3", GetLobbyPlayerNameSafe(2)); stringBuilder.Replace("@player4", GetLobbyPlayerNameSafe(3)); stringBuilder.Replace("@player5", GetLobbyPlayerNameSafe(4)); stringBuilder.Replace("@player6", GetLobbyPlayerNameSafe(5)); chatMessage = stringBuilder.ToString(); string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("<color=#" + hexColorOfPlayerWhoTyped + "> " + nameOfUserWhoTyped + " </color>: <color=white> " + chatMessage + " </color>") : ("<color=#7069ff> " + chatMessage + " </color>")); ChatMessageHistory.Add(item); ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = ""; for (int i = 0; ChatMessageHistory.Count > i; i++) { TextMeshProUGUI component = ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).text = ((TMP_Text)component).text + "\n" + ChatMessageHistory[i]; } if (chatMessage == "/clearchat" && PhotonNetwork.MasterClient.NickName == nameOfUserWhoTyped) { ChatMessageHistory.Clear(); ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = ""; } } [PunRPC] internal void BridgedMessage(string message, string playerHexColor, string playerName, bool dead = false) { if (SemiFunc.RunIsLobby()) { Instance.AddChatMessage(message, playerHexColor, playerName); } else if (!ChatBox.ConfigManager.deadPlayerTransmitBlock.Value && dead && ChatBox.ConfigManager.proximityChat.Value && CheckDistanceOnNetworkCall(playerName)) { Instance.AddChatMessageDead(message, playerHexColor, playerName); } else if (!ChatBox.ConfigManager.deadPlayerTransmitBlock.Value && dead) { Instance.AddChatMessageDead(message, playerHexColor, playerName); } else if (!ChatBox.ConfigManager.proximityChat.Value || playerName == PlayerAvatar.instance.playerName) { Instance.AddChatMessage(message, playerHexColor, playerName); } else if (CheckDistanceOnNetworkCall(playerName)) { Instance.AddChatMessage(message, playerHexColor, playerName); } else if (!CheckDistanceOnNetworkCall(playerName) && ChatBox.ConfigManager.outOfRangeMessage.Value) { Instance.AddChatMessageSystem("<decoding failed>", "ff0000", "Unknown"); } } internal Dictionary<string, PlayerAvatar> GenerateNameDictionary() { Dictionary<string, PlayerAvatar> dictionary = new Dictionary<string, PlayerAvatar>(); for (int i = 0; GameDirector.instance.PlayerList.Count > i; i++) { dictionary.Add(GameDirector.instance.PlayerList[i].playerName, GameDirector.instance.PlayerList[i]); } return dictionary; } internal bool CheckDistanceOnNetworkCall(string playerName) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (GenerateNameDictionary().TryGetValue(playerName, out PlayerAvatar value)) { if (SemiFunc.PlayerLocalDistance(value.clientPosition) < ChatBox.ConfigManager.proximityRange.Value) { return true; } return false; } ChatBox.logger.LogError((object)"Element not found!"); return false; } [PunRPC] private void ClearChat() { Instance.ChatMessageHistory.Clear(); ((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = ""; } internal static void ClearChatRpc() { Instance.photonView.RPC("ClearChat", (RpcTarget)0, Array.Empty<object>()); } internal string GetLobbyPlayerNameSafe(int index) { try { if (GameDirector.instance.PlayerList.Count > index) { return GameDirector.instance.PlayerList[index].playerName; } return "Empty slot"; } catch (Exception ex) { ChatBox.logger.LogError((object)ex); } return null; } internal static void DoWhisper(string[] data) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_0355: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) string text = string.Empty; StringBuilder stringBuilder = new StringBuilder(text); string[] array = null; List<string> list = data.ToList(); if (data.Length < 1) { Instance.AddChatMessageSystem("Invalid command syntax!", XColor.ToHexString(Color.red), "System"); return; } if (data.Length == 1) { Instance.AddChatMessageSystem("Message content missing!", XColor.ToHexString(Color.red), "System"); return; } string playerId = data[0]; if (list.Remove(data[0])) { list.Remove(data[0]); list.Remove(data[0]); array = list.ToArray(); for (int i = 0; array.Length > i; i++) { stringBuilder.Append(array[i] + " "); } text = stringBuilder.ToString(); } string lobbyPlayerNameSafe = Instance.GetLobbyPlayerNameSafe(Instance.ConvertPlayerIdToIndex(playerId)); string lobbyPlayerNameSafe2 = Instance.GetLobbyPlayerNameSafe(0); string localPlayerColorSafe = Instance.GetLocalPlayerColorSafe(); if (Utility.IsNullOrWhiteSpace(lobbyPlayerNameSafe)) { Instance.AddChatMessageSystem("Invalid command syntax!", XColor.ToHexString(Color.red), "System"); } else if (Instance.GetLobbyPlayerObjSafe(Instance.ConvertPlayerIdToIndex(playerId)) == null) { Instance.AddChatMessageSystem("Invalid player code!", XColor.ToHexString(Color.red), "System"); } else if (ChatBox.ConfigManager.deadPlayerTransmitBlock.Value && SemiFunc.PlayerAvatarLocal().deadSet) { Instance.AddChatMessageSystem("<transmit failed> \n <color=red>Comms array offline!</color>", "FF0000", "System"); } else if (!ChatBox.ConfigManager.deadPlayerTransmitBlock.Value && SemiFunc.PlayerAvatarLocal().deadSet && ChatBox.ConfigManager.proximityChat.Value && !Instance.CheckDistanceOnNetworkCall(lobbyPlayerNameSafe)) { Instance.AddChatMessageSystem("<transmit failed> \n <color=red>SemiBot out of range!</color>", "ff0000", "Unknown"); } else if (!ChatBox.ConfigManager.deadPlayerTransmitBlock.Value && SemiFunc.PlayerAvatarLocal().deadSet) { Instance.photonView.RPC("DoWhisperRpc", Instance.GetLobbyPlayerObjSafe(Instance.ConvertPlayerIdToIndex(playerId)), new object[4] { text, localPlayerColorSafe, lobbyPlayerNameSafe2, lobbyPlayerNameSafe }); Instance.AddChatMessageSystem("Sent whisper to " + Instance.GetLobbyPlayerNameSafe(Instance.ConvertPlayerIdToIndex(playerId)) + " => " + text, XColor.ToHexString(Color.red), "System"); } else { Instance.photonView.RPC("DoWhisperRpc", Instance.GetLobbyPlayerObjSafe(Instance.ConvertPlayerIdToIndex(playerId)), new object[4] { text, localPlayerColorSafe, lobbyPlayerNameSafe2, lobbyPlayerNameSafe }); Instance.AddChatMessageSystem("Sent whisper to " + Instance.GetLobbyPlayerNameSafe(Instance.ConvertPlayerIdToIndex(playerId)) + " => " + text, XColor.ToHexString(Color.red), "System"); } } [PunRPC] internal void DoWhisperRpc(string data, string hexColor, string playerName, string target) { if (target == Instance.GetLobbyPlayerNameSafe(0)) { AddChatMessage(data, hexColor, playerName); } } internal int ConvertPlayerIdToIndex(string playerId) { return playerId switch { "@player1" => 0, "@player2" => 1, "@player3" => 2, "@player4" => 3, "@player5" => 4, "@player6" => 5, _ => 999, }; } internal Player GetLobbyPlayerObjSafe(int index) { if (GameDirector.instance.PlayerList.Count > index) { return GameDirector.instance.PlayerList[index].photonView.Controller; } return null; } internal static void PrintAndWritePlayerCodes() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Instance != (Object)null) { Instance.AddChatMessageSystemNoReplacer(Instance.GetPlayerCodes(), XColor.ToHexString(Color.red), "System"); } } internal string GetPlayerCodes() { string empty = string.Empty; StringBuilder stringBuilder = new StringBuilder(empty); stringBuilder.Append("\n'@player1' -> " + GetLobbyPlayerNameSafe(0) + "\n"); stringBuilder.Append("'@player2' -> " + GetLobbyPlayerNameSafe(1) + "\n"); stringBuilder.Append("'@player3' -> " + GetLobbyPlayerNameSafe(2) + "\n"); stringBuilder.Append("'@player4' -> " + GetLobbyPlayerNameSafe(3) + "\n"); stringBuilder.Append("'@player5' -> " + GetLobbyPlayerNameSafe(4) + "\n"); stringBuilder.Append("'@player6' -> " + GetLobbyPlayerNameSafe(5)); return stringBuilder.ToString(); } internal Color GetLobbyPlayerColorSafe(int index) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (GameDirector.instance.PlayerList.Count > index) { return MetaManager.instance.colorsUIOrder[GameDirector.instance.PlayerList[index].playerCosmetics.colorsEquipped[5]].color; } return Color.gray; } public void FadeChatTarget(TextMeshProUGUI target, float fadeDelay = 2f, float startAlpha = 1f, float lateTargetAlpha = 0.2f) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) Coroutine val = ((MonoBehaviour)this).StartCoroutine(IFadeChat(target, fadeDelay, lateTargetAlpha)); if (fadeDelay == 0f && startAlpha == lateTargetAlpha) { ((Graphic)target).color = new Color(1f, 1f, 1f, lateTargetAlpha); return; } ((Graphic)target).color = new Color(1f, 1f, 1f, startAlpha); if (val != null) { ((MonoBehaviour)this).StopCoroutine(val); } val = ((MonoBehaviour)this).StartCoroutine(IFadeChat(target, fadeDelay, lateTargetAlpha)); } private IEnumerator IFadeChat(TextMeshProUGUI target, float fadeDelay, float targetAlpha) { yield return (object)new WaitForSeconds(fadeDelay); ((Graphic)target).color = new Color(1f, 1f, 1f, targetAlpha); } internal static void SetChatObjectCoords() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) Patches.ChatObject.transform.position = new Vector3(ChatBox.ConfigManager.chatBox_X.Value, ChatBox.ConfigManager.chatBox_Y.Value, 0f); } internal static void SetChatObjectMenuCoords() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) Patches.ChatObjectMenu.transform.position = new Vector3(615f, 100f, 0f); } internal string GetLocalPlayerColorSafe() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; GameDirector.instance.PlayerList.Count > i; i++) { if (GameDirector.instance.PlayerList[i].playerName == PlayerAvatar.instance.playerName) { return XColor.ToHexString(MetaManager.instance.colorsUIOrder[GameDirector.instance.PlayerList[i].playerCosmetics.colorsEquipped[5]].color); } } return ""; } internal TMP_ColorGradient ProccessLocalPlayerColorIntoGradientSafe() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_003d: 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_0073: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; GameDirector.instance.PlayerList.Count > i; i++) { if (GameDirector.instance.PlayerList[i].playerName == PlayerAvatar.instance.playerName) { TMP_ColorGradient val = new TMP_ColorGradient(); val.colorMode = (ColorMode)2; val.topLeft = MetaManager.instance.colorsUIOrder[GameDirector.instance.PlayerList[i].playerCosmetics.colorsEquipped[5]].color; val.topRight = MetaManager.instance.colorsUIOrder[GameDirector.instance.PlayerList[i].playerCosmetics.colorsEquipped[6]].color; val.bottomLeft = MetaManager.instance.colorsUIOrder[GameDirector.instance.PlayerList[i].playerCosmetics.colorsEquipped[7]].color; val.bottomRight = MetaManager.instance.colorsUIOrder[GameDirector.instance.PlayerList[i].playerCosmetics.colorsEquipped[8]].color; return val; } } return null; } } } namespace ChatBox.Patch { [HarmonyPatch] internal class Patches : MonoBehaviour { internal static int i; internal static GameObject ChatObject; internal static GameObject ChatObjectMenu; [HarmonyPrefix] [HarmonyPatch(typeof(GameDirector), "Start")] private static void FlashlightPatch() { if (SemiFunc.IsMultiplayer() & (SemiFunc.RunIsLevel() | SemiFunc.RunIsShop() | SemiFunc.RunIsLobby())) { try { ChatObject = ((Component)Singleton<global::ChatBox.Single.ChatObject>.Instance).gameObject; ((Object)ChatObject).name = "ChatObject"; ChatObject.transform.parent = ((Component)((Component)GoalUI.instance).transform.parent).transform; ChatObject.layer = 5; ChatObject.AddComponent<RectTransform>(); return; } catch (Exception arg) { ChatBox.logger.LogError((object)$"Construction error {arg}"); return; } } if (SemiFunc.RunIsLobbyMenu()) { try { ChatObjectMenu = ((Component)Singleton<global::ChatBox.Single.ChatObject>.Instance).gameObject; ((Object)ChatObjectMenu).name = "ChatObjectMenu"; ChatObjectMenu.transform.parent = ((Component)((Component)GoalUI.instance).transform.parent).transform; ChatObjectMenu.layer = 5; ChatObjectMenu.AddComponent<RectTransform>(); } catch (Exception arg2) { ChatBox.logger.LogError((object)$"Lobby construction error {arg2}"); } } } [HarmonyPriority(700)] [HarmonyPrefix] [HarmonyPatch(typeof(PlayerAvatar), "ChatMessageSend")] private static bool CommandRpcOverridePatch(PlayerAvatar __instance, ref string _message) { if (!_message.StartsWith('/') || !Object.op_Implicit((Object)(object)DebugCommandHandler.instance) || !DebugCommandHandler.instance.Execute(_message.TrimStart('/'), false)) { bool flag = __instance.isCrouching; if (!SemiFunc.IsMultiplayer()) { __instance.ChatMessageSpeak(_message, flag); } else { if (__instance.isDisabled) { flag = true; } if (!NonPatches.isCommand) { __instance.photonView.RPC("ChatMessageSendRPC", (RpcTarget)0, new object[2] { _message, flag }); } NonPatches.isCommand = false; } } return false; } [HarmonyPrefix] [HarmonyPatch(typeof(ChatManager), "StateActive")] private static void ChatManagerPatch() { try { if (!SemiFunc.InputDown((InputKey)9) || !(ChatManager.instance.chatMessage != "")) { return; } PhotonView val = PhotonView.Get((Component)(object)NonPatches.Instance); if (!CommandRegistry.CheckForCommand(ChatManager.instance.chatMessage)) { if (ChatBox.ConfigManager.deadPlayerTransmitBlock.Value && SemiFunc.PlayerAvatarLocal().deadSet) { NonPatches.Instance.AddChatMessageSystem("<transmit failed> \n <color=red>Comms array offline!</color>", "FF0000", "System"); } else if (!ChatBox.ConfigManager.deadPlayerTransmitBlock.Value && SemiFunc.PlayerAvatarLocal().deadSet) { val.RPC("BridgedMessage", (RpcTarget)0, new object[4] { ChatManager.instance.chatMessage, NonPatches.Instance.GetLocalPlayerColorSafe(), PlayerAvatar.instance.playerName, SemiFunc.PlayerAvatarLocal().deadSet }); } else { val.RPC("BridgedMessage", (RpcTarget)0, new object[4] { ChatManager.instance.chatMessage, NonPatches.Instance.GetLocalPlayerColorSafe(), PlayerAvatar.instance.playerName, false }); } } } catch (Exception arg) { ChatBox.logger.LogError((object)$"Unsupported chat action! {arg}"); } } [HarmonyPrefix] [HarmonyPatch(typeof(GameDirector), "Start")] private static void ObjectSpawnPatch() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject("NonPatchesObj"); val.AddComponent<NonPatches>(); val.AddComponent<PhotonView>().ViewID = 789546446; NonPatches.Instance.photonView = PhotonView.Get((Component)(object)NonPatches.Instance); API.RegisterAllCommands(); } } } namespace ChatBox.Single { internal class ChatObject : MonoBehaviour { internal static GameObject ChatObjectInterface; internal static ChatObject instance { get; private set; } private void Awake() { if ((Object)(object)instance == (Object)null) { instance = this; } } private void Start() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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 if (SemiFunc.IsMultiplayer() & (SemiFunc.RunIsLevel() | SemiFunc.RunIsShop() | SemiFunc.RunIsLobby())) { ChatObjectInterface = new GameObject("ChatObjectInterface"); ChatObjectInterface.transform.parent = Patches.ChatObject.transform; ChatObjectInterface.layer = 5; ChatObjectInterface.AddComponent<RectTransform>(); ChatObjectInterface.AddComponent<TextMeshProUGUI>(); ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).fontSize = 12f; ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).characterSpacing = -3.77f; ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).lineSpacing = -10f; ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).alignment = (TextAlignmentOptions)1025; ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).enableVertexGradient = true; if (ChatBox.ConfigManager.startMessageEnabled.Value) { ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = "<color=red>TAXMAN</color>: <color=white>ChatBox active!</color> \n"; NonPatches.Instance.ChatMessageHistory.Add("<color=red>TAXMAN</color>: <color=white>ChatBox active!</color> \n"); } NonPatches.SetChatObjectCoords(); } else if (SemiFunc.RunIsLobbyMenu()) { ChatObjectInterface = new GameObject("ChatObjectInterface"); ChatObjectInterface.transform.parent = Patches.ChatObjectMenu.transform; ChatObjectInterface.layer = 5; ChatObjectInterface.AddComponent<RectTransform>(); ChatObjectInterface.AddComponent<TextMeshProUGUI>(); ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).fontSize = 12f; ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).characterSpacing = -3.77f; ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).lineSpacing = -10f; ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).alignment = (TextAlignmentOptions)1025; ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).enableVertexGradient = true; if (ChatBox.ConfigManager.startMessageEnabled.Value) { ((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = "<color=red>TAXMAN</color>: <color=white>ChatBox active!</color> \n"; NonPatches.Instance.ChatMessageHistory.Add("<color=red>TAXMAN</color>: <color=white>ChatBox active!</color> \n"); } NonPatches.SetChatObjectMenuCoords(); } } } }