Decompiled source of Chatter v2.9.0
Chatter.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using ComfyLib; using GUIFramework; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Chatter")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Chatter")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("801a13e7-7e13-469e-924d-e74cad364371")] [assembly: AssemblyFileVersion("2.9.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.9.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 Chatter { public static class ChatPanelController { public static ChatPanel ChatPanel { get; private set; } public static GuiInputField VanillaInputField { get; set; } public static void ToggleChatter(bool toggleOn) { ToggleChatter(Chat.m_instance, toggleOn); } public static void ToggleChatter(Chat chat, bool toggleOn) { TerminalCommands.ToggleCommands(toggleOn); if (Object.op_Implicit((Object)(object)chat)) { ToggleVanillaChat(chat, !toggleOn); ToggleChatPanel(chat, toggleOn); ((Terminal)chat).m_input = (toggleOn ? ChatPanel.TextInput.InputField : VanillaInputField); } } public static void ToggleVanillaChat(Chat chat, bool toggleOn) { Image[] componentsInChildren = ((Component)((Terminal)chat).m_chatWindow).GetComponentsInChildren<Image>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.SetActive(toggleOn); } ((Behaviour)((Component)((Terminal)chat).m_chatWindow).GetComponent<RectMask2D>()).enabled = toggleOn; ((Component)((Terminal)chat).m_output).gameObject.SetActive(toggleOn); } public static void ToggleChatPanel(Chat chat, bool toggleOn) { //IL_003f: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ChatPanel?.Panel)) { ChatPanel = new ChatPanel(((Transform)((Terminal)chat).m_chatWindow).parent); ((Transform)ChatPanel.Panel.GetComponent<RectTransform>().SetAnchorMin(Vector2.right).SetAnchorMax(Vector2.right) .SetPivot(Vector2.right) .SetPosition(PluginConfig.ChatPanelPosition.Value) .SetSizeDelta(PluginConfig.ChatPanelSizeDelta.Value)).SetAsFirstSibling(); ChatPanel.PanelDragger.OnEndDragEvent += OnChatterChatPanelEndDrag; ChatPanel.PanelResizer.OnEndDragEvent += OnChatterChatPanelEndResize; ((UnityEvent<string>)(object)((TMP_InputField)ChatPanel.TextInput.InputField).onSubmit).AddListener((UnityAction<string>)OnChatterTextInputFieldSubmit); ChatPanel.SetChatTextInputPrefix(PluginConfig.ChatPanelDefaultMessageTypeToUse.Value); ChatPanel.SetupContentRowToggles(PluginConfig.ChatPanelContentRowTogglesToEnable.Value); ChatPanel.SetContentSpacing(); ContentRowManager.RebuildContentRows(); } ChatPanel.Panel.SetActive(toggleOn); } private static void OnChatterChatPanelEndDrag(object sender, Vector3 position) { //IL_0005: 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) PluginConfig.ChatPanelPosition.Value = Vector2.op_Implicit(position); } private static void OnChatterChatPanelEndResize(object send, Vector2 sizeDelta) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) PluginConfig.ChatPanelSizeDelta.Value = sizeDelta; } private static void OnChatterTextInputFieldSubmit(string input) { Chat.m_instance.SendInput(); } } public static class ChatPanelUtils { public static void ShowOrHideChatPanel(this ChatPanel chatPanel, bool isVisible) { if (isVisible != chatPanel.PanelCanvasGroup.blocksRaycasts) { if (isVisible) { chatPanel.PanelCanvasGroup.SetAlpha(1f).SetBlocksRaycasts(blocksRaycasts: true); return; } chatPanel.PanelCanvasGroup.SetAlpha(Hud.IsUserHidden() ? 0f : PluginConfig.HideChatPanelAlpha.Value).SetBlocksRaycasts(blocksRaycasts: false); chatPanel.SetContentVerticalScrollPosition(0f); } } public static void EnableOrDisableChatPanel(this ChatPanel chatPanel, bool isEnabled) { chatPanel.TextInput.InputField.Ref<GuiInputField>()?.SetEnabled<GuiInputField>(isEnabled); } public static void SetContentSpacing(this ChatPanel chatPanel) { if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.WithHeaderRow) { chatPanel.ContentLayoutGroup.SetSpacing(PluginConfig.ChatPanelContentSpacing.Value); } else { chatPanel.ContentLayoutGroup.SetSpacing(PluginConfig.ChatPanelContentSingleRowSpacing.Value); } } public static void SetContentFontAsset(this ChatPanel chatPanel, TMP_FontAsset fontAsset) { if (Object.op_Implicit((Object)(object)chatPanel?.Content) && Object.op_Implicit((Object)(object)fontAsset)) { TMP_Text[] componentsInChildren = chatPanel.Content.GetComponentsInChildren<TMP_Text>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].font = fontAsset; } } } public static void SetContentFontSize(this ChatPanel chatPanel, float fontSize) { if (Object.op_Implicit((Object)(object)chatPanel?.Content)) { TMP_Text[] componentsInChildren = chatPanel.Content.GetComponentsInChildren<TMP_Text>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].fontSize = fontSize; } } } public static void SetupContentRowToggles(this ChatPanel chatPanel, ChatMessageType togglesToEnable) { ToggleRow messageTypeToggleRow = chatPanel.MessageTypeToggleRow; ((UnityEvent<bool>)(object)messageTypeToggleRow.SayToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.Say); }); ((UnityEvent<bool>)(object)messageTypeToggleRow.ShoutToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.Shout); }); ((UnityEvent<bool>)(object)messageTypeToggleRow.PingToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.Ping); }); ((UnityEvent<bool>)(object)messageTypeToggleRow.WhisperToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.Whisper); }); ((UnityEvent<bool>)(object)messageTypeToggleRow.MessageHudToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.HudCenter); }); ((UnityEvent<bool>)(object)messageTypeToggleRow.TextToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { ContentRowManager.ToggleContentRows(isOn, ChatMessageType.Text); }); messageTypeToggleRow.SayToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.Say)); messageTypeToggleRow.ShoutToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.Shout)); messageTypeToggleRow.PingToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.Ping)); messageTypeToggleRow.WhisperToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.Whisper)); messageTypeToggleRow.MessageHudToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.HudCenter)); messageTypeToggleRow.TextToggle.Toggle.SetIsOn(togglesToEnable.HasFlag(ChatMessageType.Text)); } public static bool IsMessageTypeToggleActive(this ChatPanel chatPanel, ChatMessageType messageType) { ToggleRow messageTypeToggleRow = chatPanel.MessageTypeToggleRow; return messageType switch { ChatMessageType.Text => messageTypeToggleRow.TextToggle.Toggle.isOn, ChatMessageType.HudCenter => messageTypeToggleRow.MessageHudToggle.Toggle.isOn, ChatMessageType.Say => messageTypeToggleRow.SayToggle.Toggle.isOn, ChatMessageType.Shout => messageTypeToggleRow.ShoutToggle.Toggle.isOn, ChatMessageType.Whisper => messageTypeToggleRow.WhisperToggle.Toggle.isOn, ChatMessageType.Ping => messageTypeToggleRow.PingToggle.Toggle.isOn, _ => true, }; } } public static class ChatTextInputUtils { public static string ChatTextInputPrefix { get; private set; } = "say "; public static void SetChatTextInputPrefix(this ChatPanel chatPanel, Type talkerType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_006e: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_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_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) string chatTextInputPrefix = (((int)talkerType == 0) ? "w " : (((int)talkerType != 2) ? "say " : "s ")); ChatTextInputPrefix = chatTextInputPrefix; chatTextInputPrefix = (((int)talkerType == 0) ? "/whisper" : (((int)talkerType != 2) ? "/say " : "/shout")); string text = chatTextInputPrefix; Color val = (((int)talkerType == 0) ? PluginConfig.ChatMessageTextWhisperColor.Value : (((int)talkerType != 2) ? PluginConfig.ChatMessageTextSayColor.Value : PluginConfig.ChatMessageTextShoutColor.Value)); Color color = val; ((Graphic)((TMP_InputField)chatPanel.TextInput.InputField).textComponent).color = color; ((TMP_Text)chatPanel.TextInput.InputFieldPlaceholder).text = text; ((Graphic)chatPanel.TextInput.InputFieldPlaceholder).color = color.SetAlpha(0.3f); } } public sealed class ChatMessage { public ChatMessageType MessageType { get; set; } = ChatMessageType.Text; public DateTime Timestamp { get; set; } = DateTime.MinValue; public long SenderId { get; set; } public Vector3 Position { get; set; } = Vector3.zero; public Type TalkerType { get; set; } = (Type)1; public string Username { get; set; } = string.Empty; public string Text { get; set; } = string.Empty; } [BepInPlugin("redseiko.valheim.chatter", "Chatter", "2.9.0")] public sealed class Chatter : BaseUnityPlugin { public const string PluginGuid = "redseiko.valheim.chatter"; public const string PluginName = "Chatter"; public const string PluginVersion = "2.9.0"; private void Awake() { PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.chatter"); } } public static class ChatMessageUtils { public static readonly CircularQueue<ChatMessage> MessageHistory = new CircularQueue<ChatMessage>(50, delegate { }); public static bool IsChatMessageQueued { get; set; } public static bool IsChatMessageFiltered { get; set; } public static bool AddChatMessage(ChatMessage message) { if (ShouldShowText(message.MessageType, message.Text)) { MessageHistory.EnqueueItem(message); ContentRowManager.CreateContentRow(message); return true; } return false; } public static ChatMessageType GetChatMessageType(Type talkerType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected I4, but got Unknown return (int)talkerType switch { 1 => ChatMessageType.Say, 2 => ChatMessageType.Shout, 0 => ChatMessageType.Whisper, 3 => ChatMessageType.Ping, _ => ChatMessageType.Text, }; } public static string GetContentRowBodyText(ChatMessage message) { if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { return JoinIgnoringEmpty(PluginConfig.ChatMessageShowTimestamp.Value ? GetTimestampText(message.Timestamp) : string.Empty, GetUsernameText(message.Username), GetMessageText(message)); } return GetMessageText(message); } private static string JoinIgnoringEmpty(params string[] values) { return string.Join(" ", values.Where((string value) => !string.IsNullOrEmpty(value))); } public static string GetUsernameText(string username) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (username.Length == 0) { return string.Empty; } return PluginConfig.ChatMessageLayout.Value switch { MessageLayoutType.WithHeaderRow => PluginConfig.ChatMessageUsernamePrefix.Value + username + PluginConfig.ChatMessageUsernamePostfix.Value, MessageLayoutType.SingleRow => "[ <color=#" + ColorUtility.ToHtmlStringRGBA(PluginConfig.ChatMessageUsernameColor.Value) + ">" + username + "</color> ]", _ => username, }; } public static string GetTimestampText(DateTime timestamp) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { return PluginConfig.ChatMessageShowTimestamp.Value ? $"<color=#{ColorUtility.ToHtmlStringRGBA(PluginConfig.ChatMessageTimestampColor.Value)}>{timestamp:t}</color>" : string.Empty; } return timestamp.ToString("T"); } public static string GetMessageText(ChatMessage message) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) string text = ((message.MessageType != ChatMessageType.Ping) ? message.Text : $"Ping! {message.Position}"); string text2 = text; if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { return "<color=#" + ColorUtility.ToHtmlStringRGBA(GetMessageTextColor(message.MessageType)) + ">" + text2 + "</color>"; } return text2; } public static Color GetMessageTextColor(ChatMessageType messageType) { //IL_0067: 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_0033: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) return (Color)(messageType switch { ChatMessageType.Text => PluginConfig.ChatMessageTextDefaultColor.Value, ChatMessageType.HudCenter => PluginConfig.ChatMessageTextMessageHudColor.Value, ChatMessageType.Say => PluginConfig.ChatMessageTextSayColor.Value, ChatMessageType.Shout => PluginConfig.ChatMessageTextShoutColor.Value, ChatMessageType.Whisper => PluginConfig.ChatMessageTextWhisperColor.Value, ChatMessageType.Ping => PluginConfig.ChatMessageTextPingColor.Value, _ => PluginConfig.ChatMessageTextDefaultColor.Value, }); } public static bool ShouldShowText(ChatMessageType messageType, string text) { return messageType switch { ChatMessageType.Say => ShouldShowText(text, PluginConfig.SayTextFilterList.CachedValues), ChatMessageType.Shout => ShouldShowText(text, PluginConfig.ShoutTextFilterList.CachedValues), ChatMessageType.Whisper => ShouldShowText(text, PluginConfig.WhisperTextFilterList.CachedValues), ChatMessageType.HudCenter => ShouldShowText(text, PluginConfig.HudCenterTextFilterList.CachedValues), ChatMessageType.Text => ShouldShowText(text, PluginConfig.OtherTextFilterList.CachedValues), _ => true, }; } public static bool ShouldShowText(string text, List<string> filters) { if (filters.Count == 0) { return true; } int i = 0; for (int count = filters.Count; i < count; i++) { if (text.IndexOf(filters[i], 0, StringComparison.OrdinalIgnoreCase) >= 0) { return false; } } return true; } } public static class ContentRowManager { public static CircularQueue<ContentRow> MessageRows { get; } = new CircularQueue<ContentRow>(50, DestroyContentRow); public static void CreateContentRow(ChatMessage message) { if (!Object.op_Implicit((Object)(object)ChatPanelController.ChatPanel?.Content)) { return; } if (ShouldCreateContentRow(message)) { ContentRow contentRow = new ContentRow(message, PluginConfig.ChatMessageLayout.Value, ChatPanelController.ChatPanel.Content.transform); MessageRows.EnqueueItem(contentRow); SetupContentRow(contentRow); bool flag = ChatPanelController.ChatPanel.IsMessageTypeToggleActive(message.MessageType); GameObject obj = contentRow.Divider.Ref<GameObject>(); if (obj != null) { obj.SetActive(flag && PluginConfig.ShowChatPanelMessageDividers.Value); } contentRow.Row.SetActive(flag); } TextMeshProUGUI obj2 = MessageRows.LastItem.AddBodyLabel(message); ((TMP_Text)obj2).font = UIResources.GetFontAssetByName(PluginConfig.ChatMessageFontAsset.Value); ((TMP_Text)obj2).fontSize = PluginConfig.ChatMessageFontSize.Value; } public static bool ShouldCreateContentRow(ChatMessage message) { if (PluginConfig.ChatMessageLayout.Value != MessageLayoutType.SingleRow && !MessageRows.IsEmpty && MessageRows.LastItem != null && MessageRows.LastItem.Message?.MessageType == message.MessageType && MessageRows.LastItem.Message?.SenderId == message.SenderId) { return MessageRows.LastItem.Message?.Username != message.Username; } return true; } public static void DestroyContentRow(ContentRow row) { if (Object.op_Implicit((Object)(object)row.Row)) { Object.Destroy((Object)(object)row.Row); } if (Object.op_Implicit((Object)(object)row.Divider)) { Object.Destroy((Object)(object)row.Divider); } } public static void RebuildContentRows() { MessageRows.ClearItems(); if (!Object.op_Implicit((Object)(object)ChatPanelController.ChatPanel?.Panel)) { return; } foreach (ChatMessage item in ChatMessageUtils.MessageHistory) { CreateContentRow(item); } } public static void SetupContentRow(ContentRow row) { //IL_0060: 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) if (row.LayoutType == MessageLayoutType.WithHeaderRow) { ((TMP_Text)row.HeaderLeftLabel).font = UIResources.GetFontAssetByName(PluginConfig.ChatMessageFontAsset.Value); ((TMP_Text)row.HeaderLeftLabel).fontSize = PluginConfig.ChatMessageFontSize.Value; ((TMP_Text)row.HeaderLeftLabel).text = ChatMessageUtils.GetUsernameText(row.Message.Username); ((Graphic)row.HeaderLeftLabel).color = PluginConfig.ChatMessageUsernameColor.Value; ((TMP_Text)row.HeaderRightLabel).font = UIResources.GetFontAssetByName(PluginConfig.ChatMessageFontAsset.Value); ((TMP_Text)row.HeaderRightLabel).fontSize = PluginConfig.ChatMessageFontSize.Value; ((TMP_Text)row.HeaderRightLabel).text = ChatMessageUtils.GetTimestampText(row.Message.Timestamp); ((Graphic)row.HeaderRightLabel).color = PluginConfig.ChatMessageTimestampColor.Value; ((Component)row.HeaderRightLabel).gameObject.SetActive(PluginConfig.ChatMessageShowTimestamp.Value); row.RowLayoutGroup.SetSpacing(PluginConfig.ChatPanelContentRowSpacing.Value); } else if (row.LayoutType == MessageLayoutType.SingleRow) { row.RowLayoutGroup.SetSpacing(PluginConfig.ChatPanelContentSingleRowSpacing.Value); } } public static void ToggleContentRows(bool toggleOn, ChatMessageType messageType) { foreach (ContentRow messageRow in MessageRows) { if (messageRow.Message.MessageType == messageType) { GameObject obj = messageRow.Row.Ref<GameObject>(); if (obj != null) { obj.SetActive(toggleOn); } GameObject obj2 = messageRow.Divider.Ref<GameObject>(); if (obj2 != null) { obj2.SetActive(toggleOn); } } } } public static void SetContentRowSpacing(float spacing) { foreach (ContentRow messageRow in MessageRows) { messageRow?.RowLayoutGroup.Ref<VerticalLayoutGroup>()?.SetSpacing(spacing); } } public static void SetMessageTextColor(Color color, ChatMessageType messageType) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (TMP_Text item in from label in MessageRows.Where(delegate(ContentRow row) { ChatMessage message = row.Message; return message != null && message.MessageType == messageType && Object.op_Implicit((Object)(object)row.Row); }).SelectMany((ContentRow row) => row.Row.GetComponentsInChildren<TMP_Text>(true)) where ((Object)label).name == "BodyLabel" select label) { ((Graphic)item).color = color; } } public static void SetUsernameTextColor(Color color) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (ContentRow messageRow in MessageRows) { messageRow?.HeaderLeftLabel.Ref<TextMeshProUGUI>()?.SetColor<TextMeshProUGUI>(color); } } public static void SetTimestampTextColor(Color color) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (ContentRow messageRow in MessageRows) { messageRow?.HeaderRightLabel.Ref<TextMeshProUGUI>()?.SetColor<TextMeshProUGUI>(color); } } public static void ToggleShowTimestamp(bool toggleOn) { if (PluginConfig.ChatMessageLayout.Value == MessageLayoutType.SingleRow) { RebuildContentRows(); return; } foreach (ContentRow messageRow in MessageRows) { if (messageRow != null) { TextMeshProUGUI headerRightLabel = messageRow.HeaderRightLabel; if (headerRightLabel != null) { ((Component)headerRightLabel).gameObject.SetActive(toggleOn); } } } } public static void ToggleMessageDividers(bool toggleOn) { foreach (ContentRow messageRow in MessageRows) { if (messageRow != null) { GameObject obj = messageRow.Divider.Ref<GameObject>(); if (obj != null) { obj.SetActive(toggleOn); } } } } } [Flags] public enum ChatMessageType { None = 0, Text = 1, HudCenter = 2, Say = 4, Shout = 8, Whisper = 0x10, Ping = 0x20 } public enum MessageLayoutType { WithHeaderRow, SingleRow } public static class WorldTextUtils { public static GameObject CreateWorldTextTemplate(Transform parentTransform) { //IL_0018: 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) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown GameObject val = new GameObject("WorldText", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0f)).SetAnchorMax(new Vector2(0.5f, 0f)) .SetPivot(new Vector2(0.5f, 0f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(400f, 100f)); TextMeshProUGUI obj = UIBuilder.CreateLabel(val.transform); ((Object)obj).name = "Text"; ((TMP_Text)obj).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).fontSize = 18f; return val; } } [HarmonyPatch(typeof(Menu))] internal static class MenuPatch { [HarmonyPostfix] [HarmonyPatch("Show")] private static void ShowPostfix() { if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)ChatPanelController.ChatPanel?.Panel)) { Chat.m_instance.m_hideTimer = 0f; ChatPanelController.ChatPanel.EnableOrDisableChatPanel(isEnabled: true); ChatPanelController.ChatPanel.ToggleGrabber(toggleOn: true); } } [HarmonyPostfix] [HarmonyPatch("Hide")] private static void HidePostfix() { if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)ChatPanelController.ChatPanel?.Panel)) { ChatPanelController.ChatPanel.SetContentVerticalScrollPosition(0f); ChatPanelController.ChatPanel.ToggleGrabber(toggleOn: false); } } } [HarmonyPatch(typeof(MessageHud))] internal static class MessageHudPatch { [HarmonyPostfix] [HarmonyPatch("ShowMessage")] private static void ShowMessagePostfix(MessageType type, string text) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if (PluginConfig.IsModEnabled.Value && (int)type == 2 && PluginConfig.ShowMessageHudCenterMessages.Value) { ChatMessageUtils.AddChatMessage(new ChatMessage { MessageType = ChatMessageType.HudCenter, Timestamp = DateTime.Now, Text = text }); } } } public sealed class InputFieldCell { public GameObject Cell { get; private set; } public Image Background { get; private set; } public GuiInputField InputField { get; private set; } public TextMeshProUGUI InputFieldPlaceholder { get; private set; } public InputFieldCell(Transform parentTransform) { Cell = CreateChildCell(parentTransform); Background = Cell.GetComponent<Image>(); InputField = CreateChildInputField(Cell.transform); InputFieldPlaceholder = ((Component)((TMP_InputField)InputField).placeholder).GetComponent<TextMeshProUGUI>(); InputField.SetTargetGraphic<GuiInputField>((Graphic)(object)Background).SetTransition<GuiInputField>((Transition)1).SetNavigationMode<GuiInputField>((Mode)0); } private GameObject CreateChildCell(Transform parentTransform) { //IL_0018: 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) //IL_0025: Expected O, but got Unknown //IL_0026: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown GameObject val = new GameObject("Cell", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateSuperellipse(128, 128, 10f)) .SetColor(new Color(0.1f, 0.1f, 0.1f, 0.3f)); val.AddComponent<RectMask2D>(); return val; } private GuiInputField CreateChildInputField(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_002d: 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_004b: 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_0069: 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_009c: 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_00b0: 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_010f: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Text Area", new Type[1] { typeof(RectTransform) }); val.SetParent(parentTransform); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetSizeDelta(new Vector2(-16f, -8f)) .SetPosition(Vector2.zero); TextMeshProUGUI val2 = UIBuilder.CreateLabel(val.transform); val2.SetName<TextMeshProUGUI>("Text"); ((TMP_Text)val2).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetSizeDelta(Vector2.zero) .SetPosition(Vector2.zero); ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val2).overflowMode = (TextOverflowModes)2; ((TMP_Text)val2).richText = false; ((TMP_Text)val2).alignment = (TextAlignmentOptions)513; ((Graphic)val2).color = Color.white; ((TMP_Text)val2).text = string.Empty; TextMeshProUGUI val3 = UIBuilder.CreateLabel(val.transform); val3.SetName<TextMeshProUGUI>("Placeholder"); ((TMP_Text)val3).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetSizeDelta(Vector2.zero) .SetPosition(Vector2.zero); ((TMP_Text)val3).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val3).overflowMode = (TextOverflowModes)2; ((TMP_Text)val3).richText = true; ((TMP_Text)val3).alignment = (TextAlignmentOptions)513; ((Graphic)val3).color = new Color(1f, 1f, 1f, 0.3f); ((TMP_Text)val3).text = "..."; GuiInputField obj = ((Component)parentTransform).gameObject.AddComponent<GuiInputField>(); ((TMP_InputField)obj).textViewport = val.GetComponent<RectTransform>(); ((TMP_InputField)obj).textComponent = (TMP_Text)(object)val2; ((TMP_InputField)obj).placeholder = (Graphic)(object)val3; ((TMP_InputField)obj).onFocusSelectAll = false; obj.OnInputLayoutChanged(); ((TMP_InputField)obj).MoveToStartOfLine(false, false); return obj; } } public sealed class ContentRow { public ChatMessage Message { get; private set; } public MessageLayoutType LayoutType { get; private set; } public GameObject Row { get; private set; } public VerticalLayoutGroup RowLayoutGroup { get; private set; } public GameObject Divider { get; private set; } public GameObject Header { get; private set; } public TextMeshProUGUI HeaderLeftLabel { get; private set; } public TextMeshProUGUI HeaderRightLabel { get; private set; } public ContentRow(ChatMessage message, MessageLayoutType layoutType, Transform parentTransform) { Message = message; LayoutType = layoutType; if (layoutType == MessageLayoutType.WithHeaderRow) { Divider = CreateDivider(parentTransform); } Row = CreateChildRow(parentTransform); RowLayoutGroup = Row.GetComponent<VerticalLayoutGroup>(); if (layoutType == MessageLayoutType.WithHeaderRow) { (Header, HeaderLeftLabel, HeaderRightLabel) = CreateHeader(Row.transform); } } public TextMeshProUGUI AddBodyLabel(ChatMessage message) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = CreateChildBodyLabel(Row.transform); ((TMP_Text)val).text = ChatMessageUtils.GetContentRowBodyText(message); if (LayoutType == MessageLayoutType.WithHeaderRow) { ((Graphic)val).color = ChatMessageUtils.GetMessageTextColor(message.MessageType); } return val; } private GameObject CreateChildRow(Transform parentTransform) { //IL_0018: 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) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_006b: Expected O, but got Unknown GameObject val = new GameObject("Message", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetSizeDelta(Vector2.zero); val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(true, false) .SetSpacing(2f); return val; } private GameObject CreateDivider(Transform parentTransform) { //IL_0018: 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) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown GameObject val = new GameObject("Divider", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.AddComponent<Image>().SetSprite(UIBuilder.CreateRect(10, 10, Color32.op_Implicit(Color.white))).SetType((Type)3) .SetColor(new Color(1f, 1f, 1f, 0.0625f)) .SetRaycastTarget(raycastTarget: true) .SetMaskable(maskable: true); LayoutElement layoutElement = val.AddComponent<LayoutElement>().SetFlexible(1f); float? height = 1f; layoutElement.SetPreferred(null, height); return val; } private (GameObject header, TextMeshProUGUI leftCell, TextMeshProUGUI rightCell) CreateHeader(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown GameObject val = new GameObject("Header", new Type[1] { typeof(RectTransform) }); val.SetParent(parentTransform); val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false) .SetPadding(0, 0, 0, 0); TextMeshProUGUI val2 = UIBuilder.CreateLabel(val.transform); ((Object)val2).name = "HeaderLeftLabel"; ((TMP_Text)val2).text = "LeftLabel"; ((TMP_Text)val2).alignment = (TextAlignmentOptions)513; GameObject val3 = new GameObject("Spacer", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val3, val.transform); val3.AddComponent<LayoutElement>().SetFlexible(1f); TextMeshProUGUI val4 = UIBuilder.CreateLabel(val.transform); ((Object)val4).name = "HeaderRightLabel"; ((TMP_Text)val4).text = "RightLabel"; ((TMP_Text)val4).alignment = (TextAlignmentOptions)516; return (val, val2, val4); } private TextMeshProUGUI CreateChildBodyLabel(Transform parentTransform) { TextMeshProUGUI obj = UIBuilder.CreateLabel(parentTransform); ((Object)obj).name = "BodyLabel"; ((TMP_Text)obj).alignment = (TextAlignmentOptions)513; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)1; return obj; } } public sealed class ResizeCell { public GameObject Cell { get; private set; } public Image Background { get; private set; } public TMP_Text Label { get; private set; } public ResizeCell(Transform parentTransform) { Cell = CreateChildCell(parentTransform); Background = Cell.GetComponent<Image>(); Label = CreateChildLabel(Cell.transform); } private GameObject CreateChildCell(Transform parentTransform) { //IL_0018: 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) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0072: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown GameObject val = new GameObject("Resizer", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); GameObjectExtensions.RectTransform(val).SetAnchorMin(new Vector2(0f, 0.5f)).SetAnchorMax(new Vector2(0f, 0.5f)) .SetPivot(new Vector2(0f, 0.5f)) .SetSizeDelta(new Vector2(42.5f, 42.5f)) .SetPosition(new Vector2(5f, 0f)); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("button")) .SetColor(new Color(1f, 1f, 1f, 0.95f)); return val; } private TMP_Text CreateChildLabel(Transform parentTransform) { //IL_000c: 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) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = UIBuilder.CreateLabel(parentTransform); ((Component)obj).GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetSizeDelta(Vector2.zero); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).fontSize = 24f; ((TMP_Text)obj).text = "<rotate=45>↔</rotate>"; return (TMP_Text)(object)obj; } } public sealed class ToggleCell { public GameObject Cell { get; private set; } public Image Background { get; private set; } public TextMeshProUGUI Label { get; private set; } public Toggle Toggle { get; private set; } public ToggleCell(Transform parentTransform) { Cell = CreateChildCell(parentTransform); Background = Cell.Image(); Label = CreateChildLabel(Cell.transform); Toggle = Cell.AddComponent<Toggle>(); ((UnityEvent<bool>)(object)Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool isOn) { OnToggleValueChanged(isOn); }); Toggle.SetNavigationMode<Toggle>((Mode)0).SetTargetGraphic<Toggle>((Graphic)(object)Background).SetIsOn(isOn: false); Cell.AddComponent<DummyIgnoreDrag>(); } private GameObject CreateChildCell(Transform parentTransform) { //IL_0018: 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) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown GameObject val = new GameObject("Toggle", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetSizeDelta(Vector2.zero); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("button")) .SetColor(new Color(1f, 1f, 1f, 0.95f)); return val; } private TextMeshProUGUI CreateChildLabel(Transform parentTransform) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = UIBuilder.CreateLabel(parentTransform); ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).fontSize = 14f; ((Graphic)obj).color = new Color(1f, 1f, 1f, 0.9f); ((TMP_Text)obj).text = "Toggle"; ((TMP_Text)obj).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetSizeDelta(Vector2.zero) .SetPosition(Vector2.zero); return obj; } private void OnToggleValueChanged(bool isOn) { //IL_0038: 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) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) ((Graphic)Background).color = (isOn ? new Color(1f, 1f, 1f, 0.95f) : new Color(0.5f, 0.5f, 0.5f, 0.95f)); ((Graphic)Label).color = (isOn ? Color.white : Color.gray); } } public sealed class ToggleRow { public GameObject Row { get; private set; } public Image Background { get; private set; } public ToggleCell SayToggle { get; private set; } public ToggleCell ShoutToggle { get; private set; } public ToggleCell WhisperToggle { get; private set; } public ToggleCell PingToggle { get; private set; } public ToggleCell MessageHudToggle { get; private set; } public ToggleCell TextToggle { get; private set; } public ToggleRow(Transform parentTransform) { Row = CreateChildRow(parentTransform); Background = Row.Image(); SayToggle = CreateChildToggle(Row.transform, "Say"); ShoutToggle = CreateChildToggle(Row.transform, "Shout"); WhisperToggle = CreateChildToggle(Row.transform, "Whisper"); PingToggle = CreateChildToggle(Row.transform, "Ping"); MessageHudToggle = CreateChildToggle(Row.transform, "Hud"); TextToggle = CreateChildToggle(Row.transform, "Text"); } private GameObject CreateChildRow(Transform parentTransform) { //IL_0018: 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) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0072: 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_00b4: 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_0116: Expected O, but got Unknown GameObject val = new GameObject("ToggleRow", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.right) .SetPivot(new Vector2(0.5f, 0f)) .SetPosition(new Vector2(0f, -55f)) .SetSizeDelta(new Vector2(0f, 45f)); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateRoundedCornerSprite(256, 256, 16, (FilterMode)1)) .SetColor(new Color(0.5f, 0.5f, 0.5f, 0.25f)); val.AddComponent<HorizontalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false) .SetSpacing(5f) .SetPadding(5, 5, 4, 4) .SetChildAlignment((TextAnchor)5); return val; } private ToggleCell CreateChildToggle(Transform parentTransform, string toggleText) { ToggleCell toggleCell = new ToggleCell(parentTransform); ((TMP_Text)toggleCell.Label).text = toggleText; LayoutElement layoutElement = toggleCell.Cell.AddComponent<LayoutElement>().SetPreferred(((TMP_Text)toggleCell.Label).GetPreferredWidth() + 25f); float? height = 0.9f; layoutElement.SetFlexible(null, height); return toggleCell; } } [HarmonyPatch(typeof(Chat))] internal static class ChatPatch { private static bool _isChatMessageFiltered; [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix(Chat __instance) { ContentRowManager.MessageRows.ClearItems(); ChatPanelController.VanillaInputField = ((Terminal)__instance).m_input; ChatPanelController.ToggleChatter(__instance, PluginConfig.IsModEnabled.Value); SetupWorldText(__instance); } private static void SetupWorldText(Chat chat) { chat.m_worldTextBase = WorldTextUtils.CreateWorldTextTemplate(chat.m_worldTextBase.transform.parent); chat.m_worldTextBase.SetActive(false); } [HarmonyTranspiler] [HarmonyPatch("InputText")] private static IEnumerable<CodeInstruction> InputTextTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"say ", (string)null) }).Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<string, string>>((Func<string, string>)PrefixSayDelegate) }) .InstructionEnumeration(); } private static string PrefixSayDelegate(string value) { if (!PluginConfig.IsModEnabled.Value) { return value; } return ChatTextInputUtils.ChatTextInputPrefix; } [HarmonyPrefix] [HarmonyPatch("OnNewChatMessage")] private static void OnNewChatMessagePrefix(Chat __instance, long senderID, Vector3 pos, Type type, UserInfo user, string text, ref float __state) { //IL_0013: 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_0038: Unknown result type (might be due to invalid IL or missing references) if (PluginConfig.IsModEnabled.Value) { ChatMessage message = new ChatMessage { MessageType = ChatMessageUtils.GetChatMessageType(type), Timestamp = DateTime.Now, SenderId = senderID, Position = pos, TalkerType = type, Username = user.Name, Text = Regex.Replace(text, "(<|>)", " ") }; ChatMessageUtils.IsChatMessageQueued = true; _isChatMessageFiltered = !ChatMessageUtils.AddChatMessage(message); __state = __instance.m_hideTimer; } } [HarmonyPostfix] [HarmonyPatch("OnNewChatMessage")] private static void OnNewChatMessagePostfix(ref Chat __instance, float __state) { if (PluginConfig.IsModEnabled.Value) { ChatMessageUtils.IsChatMessageQueued = false; if (_isChatMessageFiltered) { __instance.m_hideTimer = __state; } } } [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler1(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0026: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Chat), "m_hideTimer"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Chat), "m_hideDelay"), (string)null), new CodeMatch((OpCode?)OpCodes.Clt, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch Chat.Update()! (HideChatPanel)") .Advance(6) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Chat), "m_hideTimer")), Transpilers.EmitDelegate<Action<float>>((Action<float>)HideChatPanelDelegate) }) .InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler2(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0026: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[7] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Terminal), "m_input"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Component), "get_gameObject", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Chat), "m_doubleOpenForVirtualKeyboard"), (string)null) }).ThrowIfInvalid("Could not patch Chat.Update()! (EnableChatPanel)") .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Action>((Action)EnableChatPanelDelegate) }) .InstructionEnumeration(); } [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler3(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0026: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[8] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Terminal), "m_input"), (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Component), "get_gameObject", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null), (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(Terminal), "m_focused"), (string)null) }).ThrowIfInvalid("Could not patch Chat.Update()! (DisableChatPanel)") .Advance(4) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)DisableChatPanelDelegate) }) .InstructionEnumeration(); } private static void HideChatPanelDelegate(float hideTimer) { if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)ChatPanelController.ChatPanel?.Panel)) { bool isVisible = (hideTimer < (float)PluginConfig.HideChatPanelDelay.Value || Menu.IsVisible()) && !Hud.IsUserHidden(); ChatPanelController.ChatPanel.ShowOrHideChatPanel(isVisible); } } private static void EnableChatPanelDelegate() { if (PluginConfig.IsModEnabled.Value) { ChatPanelController.ChatPanel?.EnableOrDisableChatPanel(isEnabled: true); } } private static bool DisableChatPanelDelegate(bool active) { if (PluginConfig.IsModEnabled.Value) { if (!Menu.IsVisible()) { ChatPanelController.ChatPanel?.EnableOrDisableChatPanel(isEnabled: false); } return true; } return active; } [HarmonyPostfix] [HarmonyPatch("Update")] private static void UpdatePostfix(Chat __instance) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)ChatPanelController.ChatPanel?.Panel)) { KeyboardShortcut value = PluginConfig.ScrollContentUpShortcut.Value; if (((KeyboardShortcut)(ref value)).IsDown() && ChatPanelController.ChatPanel.Panel.activeInHierarchy) { ChatPanelController.ChatPanel.OffsetContentVerticalScrollPosition(PluginConfig.ScrollContentOffsetInterval.Value); __instance.m_hideTimer = 0f; } value = PluginConfig.ScrollContentDownShortcut.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ChatPanelController.ChatPanel.OffsetContentVerticalScrollPosition(0f - PluginConfig.ScrollContentOffsetInterval.Value); __instance.m_hideTimer = 0f; } } } [HarmonyTranspiler] [HarmonyPatch("SendInput")] private static IEnumerable<CodeInstruction> SendInputTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch Chat.SendInput()! (SetActive)") .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { Transpilers.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)DisableChatPanelDelegate) }) .InstructionEnumeration(); } [HarmonyPostfix] [HarmonyPatch("SendInput")] private static void SendInputPostfix() { if (PluginConfig.IsModEnabled.Value) { ChatPanelController.ChatPanel?.SetContentVerticalScrollPosition(0f); } } [HarmonyPostfix] [HarmonyPatch("HasFocus")] private static void HasFocusPostfix(ref Chat __instance, ref bool __result) { if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)ChatPanelController.ChatPanel?.Panel)) { __result = ChatPanelController.ChatPanel.Panel.activeInHierarchy && ((TMP_InputField)((Terminal)__instance).m_input).isFocused; } } [HarmonyPrefix] [HarmonyPatch("AddInworldText")] private static bool AddInworldTextPrefix(string text) { if (PluginConfig.IsModEnabled.Value && PluginConfig.FilterInWorldShoutText.Value) { return ChatMessageUtils.ShouldShowText(ChatMessageType.Shout, text); } return true; } [HarmonyTranspiler] [HarmonyPatch("AddInworldText")] private static IEnumerable<CodeInstruction> AddInworldTextTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(string), "ToUpper", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch Chat.AddInworldText()! (ToUpper)") .SetInstructionAndAdvance(Transpilers.EmitDelegate<Func<string, string>>((Func<string, string>)ToUpperDelegate)) .InstructionEnumeration(); } private static string ToUpperDelegate(string text) { if (!PluginConfig.IsModEnabled.Value) { return text.ToUpper(); } return text; } } [HarmonyPatch(typeof(Terminal))] internal static class TerminalPatch { [HarmonyPatch] [HarmonyAfter(new string[] { "redseiko.valheim.chatter" })] private static class SayDelegatePatch { [HarmonyTargetMethod] private static MethodBase FindSayDelegateMethod() { return _sayMethodDelegate; } [HarmonyPostfix] private static void SayDelegatePostfix(ref object __result) { if (PluginConfig.IsModEnabled.Value && !(bool)__result) { ChatPanelController.ChatPanel?.SetChatTextInputPrefix((Type)1); __result = true; } } } [HarmonyPatch] [HarmonyAfter(new string[] { "redseiko.valheim.chatter" })] private static class ShoutDelegatePatch { [HarmonyTargetMethod] private static MethodBase FindShoutDelegateMethod() { return _shoutMethodDelegate; } [HarmonyPostfix] private static void ShoutDelegatePostfix(ref object __result) { if (PluginConfig.IsModEnabled.Value && !(bool)__result) { ChatPanelController.ChatPanel?.SetChatTextInputPrefix((Type)2); __result = true; } } } [HarmonyPatch] [HarmonyAfter(new string[] { "redseiko.valheim.chatter" })] private static class WhisperDelegatePatch { [HarmonyTargetMethod] private static MethodBase FindWhisperDelegateMethod() { return _whisperMethodDelegate; } [HarmonyPostfix] private static void WhisperDelegatePostfix(ref object __result) { if (PluginConfig.IsModEnabled.Value && !(bool)__result) { ChatPanelController.ChatPanel?.SetChatTextInputPrefix((Type)0); __result = true; } } } private static MethodInfo _sayMethodDelegate; private static MethodInfo _shoutMethodDelegate; private static MethodInfo _whisperMethodDelegate; [HarmonyPostfix] [HarmonyPatch("AddString", new Type[] { typeof(string) })] private static void AddStringPostfix(Terminal __instance, string text) { if (PluginConfig.IsModEnabled.Value && __instance is Chat && !ChatMessageUtils.IsChatMessageQueued) { ChatMessageUtils.AddChatMessage(new ChatMessage { MessageType = ChatMessageType.Text, Timestamp = DateTime.Now, Text = text }); } } [HarmonyTranspiler] [HarmonyPatch("InitTerminal")] private static IEnumerable<CodeInstruction> InitTerminalTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchCommandDelegate("say").CopyOperand<MethodInfo>(out _sayMethodDelegate) .Start() .MatchCommandDelegate("s") .CopyOperand<MethodInfo>(out _shoutMethodDelegate) .Start() .MatchCommandDelegate("w") .CopyOperand<MethodInfo>(out _whisperMethodDelegate) .InstructionEnumeration(); } private static CodeMatcher MatchCommandDelegate(this CodeMatcher matcher, string command) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown return matcher.MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)command, (string)null), new CodeMatch((OpCode?)OpCodes.Ldstr, (object)null, (string)null) }).ThrowIfInvalid("Could not patch Terminal.InitTerminal()! (ldstr-" + command + ")").MatchStartForward((CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldftn, (object)null, (string)null) }) .ThrowIfInvalid("Could not patch Terminal.InitTerminal()! (ldftn-" + command) .Advance(1); } } public static class PluginConfig { [HarmonyPatch(typeof(FejdStartup))] private static class FejdStartupPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix() { while (_fejdStartupBindConfigQueue.Count > 0) { _fejdStartupBindConfigQueue.Dequeue()?.Invoke(Config); } } } private static readonly Queue<Action<ConfigFile>> _fejdStartupBindConfigQueue = new Queue<Action<ConfigFile>>(); public static ConfigFile Config { get; private set; } public static ConfigEntry<bool> IsModEnabled { get; private set; } public static ConfigEntry<Vector2> ChatPanelPosition { get; private set; } public static ConfigEntry<Vector2> ChatPanelSizeDelta { get; private set; } public static ConfigEntry<Color> ChatPanelBackgroundColor { get; private set; } public static ConfigEntry<int> HideChatPanelDelay { get; private set; } public static ConfigEntry<float> HideChatPanelAlpha { get; private set; } public static ConfigEntry<KeyboardShortcut> ScrollContentUpShortcut { get; private set; } public static ConfigEntry<KeyboardShortcut> ScrollContentDownShortcut { get; private set; } public static ConfigEntry<float> ScrollContentOffsetInterval { get; private set; } public static ConfigEntry<bool> ShowMessageHudCenterMessages { get; private set; } public static ConfigEntry<bool> ShowChatPanelMessageDividers { get; private set; } public static ConfigEntry<float> ChatPanelContentSpacing { get; private set; } public static ConfigEntry<float> ChatPanelContentRowSpacing { get; private set; } public static ConfigEntry<float> ChatPanelContentSingleRowSpacing { get; private set; } public static ConfigEntry<Type> ChatPanelDefaultMessageTypeToUse { get; private set; } public static ConfigEntry<ChatMessageType> ChatPanelContentRowTogglesToEnable { get; private set; } public static ConfigEntry<MessageLayoutType> ChatMessageLayout { get; private set; } public static ConfigEntry<bool> ChatMessageShowTimestamp { get; private set; } public static ConfigEntry<Color> ChatMessageTextDefaultColor { get; private set; } public static ConfigEntry<Color> ChatMessageTextSayColor { get; private set; } public static ConfigEntry<Color> ChatMessageTextShoutColor { get; private set; } public static ConfigEntry<Color> ChatMessageTextWhisperColor { get; private set; } public static ConfigEntry<Color> ChatMessageTextPingColor { get; private set; } public static ConfigEntry<Color> ChatMessageTextMessageHudColor { get; private set; } public static ConfigEntry<Color> ChatMessageUsernameColor { get; private set; } public static ConfigEntry<Color> ChatMessageTimestampColor { get; private set; } public static ConfigEntry<string> ChatMessageUsernamePrefix { get; private set; } public static ConfigEntry<string> ChatMessageUsernamePostfix { get; private set; } public static StringListConfigEntry SayTextFilterList { get; private set; } public static StringListConfigEntry ShoutTextFilterList { get; private set; } public static StringListConfigEntry WhisperTextFilterList { get; private set; } public static StringListConfigEntry HudCenterTextFilterList { get; private set; } public static StringListConfigEntry OtherTextFilterList { get; private set; } public static ConfigEntry<bool> FilterInWorldShoutText { get; private set; } public static ConfigEntry<string> ChatMessageFontAsset { get; private set; } public static ConfigEntry<float> ChatMessageFontSize { get; private set; } public static void BindConfig(ConfigFile config) { //IL_005b: 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_0115: 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_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0596: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_0701: Unknown result type (might be due to invalid IL or missing references) //IL_0706: Unknown result type (might be due to invalid IL or missing references) Config = config; IsModEnabled = config.Bind<bool>("_Global", "isModEnabled", true, "Globally enable or disable this mod."); IsModEnabled.OnSettingChanged<bool>(ChatPanelController.ToggleChatter); ChatPanelPosition = config.BindInOrder<Vector2>("ChatPanel", "chatPanelPosition", new Vector2(-10f, 125f), "The Vector2 position of the ChatPanel."); ChatPanelPosition.OnSettingChanged(delegate(Vector2 position) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ChatPanelController.ChatPanel?.PanelRectTransform.SetPosition(position); }); ChatPanelSizeDelta = config.BindInOrder<Vector2>("ChatPanel", "chatPanelSizeDelta", new Vector2(500f, 500f), "The size (width, height) of the ChatPanel."); ChatPanelSizeDelta.OnSettingChanged(delegate(Vector2 sizeDelta) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ChatPanelController.ChatPanel?.PanelRectTransform.SetSizeDelta(sizeDelta); }); ChatPanelBackgroundColor = config.BindInOrder<Color>("ChatPanel", "chatPanelBackgroundColor", new Color(0f, 0f, 0f, 0.125f), "The background color for the ChatPanel."); ChatPanelBackgroundColor.OnSettingChanged(delegate(Color color) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ChatPanelController.ChatPanel?.PanelBackground.SetColor(color); }); HideChatPanelDelay = config.BindInOrder("ChatPanel.Behaviour", "hideChatPanelDelay", 5, "Delay (in seconds) before hiding the ChatPanel.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 180)); HideChatPanelAlpha = config.BindInOrder("ChatPanel.Behaviour", "hideChatPanelAlpha", 0f, "Color alpha (in %) for the ChatPanel when hidden.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f)); ScrollContentUpShortcut = config.BindInOrder<KeyboardShortcut>("ChatPanel.Scrolling", "scrollContentUpShortcut", new KeyboardShortcut((KeyCode)280, Array.Empty<KeyCode>()), "Keyboard shortcut to scroll the ChatPanel content up."); ScrollContentDownShortcut = config.BindInOrder<KeyboardShortcut>("ChatPanel.Scrolling", "scrollContentDownShortcut", new KeyboardShortcut((KeyCode)281, Array.Empty<KeyCode>()), "Keyboard shortcut to scroll the ChatPanel content down."); ScrollContentOffsetInterval = config.BindInOrder("ChatPanel.Scrolling", "scrollContentOffsetInterval", 200f, "Interval (in pixels) to scroll the ChatPanel content up/down.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1000f, 1000f)); ShowMessageHudCenterMessages = config.BindInOrder("ChatPanel.Content", "showMessageHudCenterMessages", defaultValue: true, "Show messages from the MessageHud that display in the top-center (usually boss messages)."); ShowChatPanelMessageDividers = config.BindInOrder("ChatPanel.Content", "showChatPanelMessageDividers", defaultValue: true, "Show the horizontal dividers between groups of messages."); ShowChatPanelMessageDividers.OnSettingChanged<bool>(ContentRowManager.ToggleMessageDividers); ChatPanelContentSpacing = config.BindInOrder("ChatPanel.Spacing", "chatPanelContentSpacing", 10f, "Spacing (px) between `Content.Row` when using 'WithRowHeader` layout.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f)); ChatPanelContentSpacing.OnSettingChanged<float>((Action)delegate { ChatPanelController.ChatPanel?.SetContentSpacing(); }); ChatPanelContentRowSpacing = config.BindInOrder("ChatPanel.Spacing", "chatPanelContentRowSpacing", 2f, "Spacing (px) between `Content.Row.Body` when using 'WithRowHeader' layout.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f)); ChatPanelContentRowSpacing.OnSettingChanged<float>(ContentRowManager.SetContentRowSpacing); ChatPanelContentSingleRowSpacing = config.BindInOrder("ChatPanel.Spacing", "chatPanelContentSingleRowSpacing", 10f, "Spacing (in pixels) to use between rows when using 'SingleRow' layout.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f)); ChatPanelContentSingleRowSpacing.OnSettingChanged<float>((Action)delegate { ChatPanelController.ChatPanel?.SetContentSpacing(); }); ChatPanelDefaultMessageTypeToUse = config.BindInOrder<Type>("ChatPanel.Defaults", "chatPanelDefaultMessageTypeToUse", (Type)1, "ChatPanel input default message type to use on game start. Ping value is ignored."); ChatPanelContentRowTogglesToEnable = config.BindInOrder("ChatPanel.Defaults", "chatPanelContentRowTogglesToEnable", ChatMessageType.Text | ChatMessageType.HudCenter | ChatMessageType.Say | ChatMessageType.Shout | ChatMessageType.Whisper, "ChatPanel content row toggles to enable on game start."); ChatMessageLayout = config.BindInOrder("ChatMessage.Layout", "chatMessageLayout", MessageLayoutType.WithHeaderRow, "Determines which layout to use when displaying a chat message."); ChatMessageLayout.OnSettingChanged<MessageLayoutType>(ContentRowManager.RebuildContentRows); ChatMessageShowTimestamp = config.BindInOrder("ChatMessage.Layout", "chatMessageShowTimestamp", defaultValue: true, "Show a timestamp for each group of chat messages (except system/default)."); ChatMessageShowTimestamp.OnSettingChanged<bool>(ContentRowManager.ToggleShowTimestamp); ChatMessageTextDefaultColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextDefaultColor", Color.white, "Color for default/system chat messages."); ChatMessageTextDefaultColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.Text); }); ChatMessageTextSayColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextSayColor", Color.white, "Color for 'normal/say' chat messages."); ChatMessageTextSayColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.Say); }); ChatMessageTextShoutColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextShoutColor", Color.yellow, "Color for 'shouting' chat messages."); ChatMessageTextShoutColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.Shout); }); ChatMessageTextWhisperColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextWhisperColor", new Color(0.502f, 0f, 0.502f, 1f), "Color for 'whisper' chat messages."); ChatMessageTextWhisperColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.Whisper); }); ChatMessageTextPingColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextPingColor", Color.cyan, "Color for 'ping' chat messages."); ChatMessageTextPingColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.Ping); }); ChatMessageTextMessageHudColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTextMessageHudColor", new Color(1f, 0.807f, 0f, 1f), "Color for 'MessageHud' chat messages."); ChatMessageTextMessageHudColor.OnSettingChanged(delegate(Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ContentRowManager.SetMessageTextColor(color, ChatMessageType.HudCenter); }); ChatMessageUsernameColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageUsernameColor", new Color(1f, 0.647f, 0f), "Color for the username shown in chat messages."); ChatMessageUsernameColor.OnSettingChanged((Action<Color>)ContentRowManager.SetUsernameTextColor); ChatMessageTimestampColor = config.BindInOrder<Color>("ChatMessage.Text.Colors", "chatMessageTimestampColor", Color32.op_Implicit(new Color32((byte)244, (byte)246, (byte)247, byte.MaxValue)), "Color for any timestamp shown in the chat messages."); ChatMessageTimestampColor.OnSettingChanged((Action<Color>)ContentRowManager.SetTimestampTextColor); ChatMessageUsernamePrefix = ConfigFileExtensions.BindInOrder(config, "ChatMessage.WithHeaderRow", "chatMessageUsernamePrefix", string.Empty, "If non-empty, adds the text to the beginning of a ChatMesage username in 'WithHeaderRow' mode."); ChatMessageUsernamePostfix = ConfigFileExtensions.BindInOrder(config, "ChatMessage.WithHeaderRow", "chatMessageUsernamePostfix", string.Empty, "If non-empty, adds the text to the end of a ChatMessage username in 'WithHeaderRow' mode."); BindFilters(config); LateBindConfig(BindChatMessageFontConfig); } private static void BindFilters(ConfigFile config) { SayTextFilterList = config.BindInOrder("Filters", "sayTextFilterList", "Filter list for Say message texts.", "\t"); ShoutTextFilterList = config.BindInOrder("Filters", "shoutTextFilterList", "Filter list for Shout message texts.", "\t"); FilterInWorldShoutText = config.BindInOrder("Filters", "filterInWorldShoutText", defaultValue: false, "If true, will also filter in-world Shout message texts."); WhisperTextFilterList = config.BindInOrder("Filters", "whisperTextFilterList", "Filter list for Whipser message texts.", "\t"); HudCenterTextFilterList = config.BindInOrder("Filters", "messageHudTextFilterList", "Filter list for MessageHud.Center message texts.", "\t"); OtherTextFilterList = config.BindInOrder("Filters", "otherHudTextFilterList", "Filter list for all other message texts.", "\t"); } public static void BindChatMessageFontConfig(ConfigFile config) { string[] array = (from f in Resources.FindObjectsOfTypeAll<TMP_FontAsset>() select ((Object)f).name into f orderby f select f).Distinct().ToArray(); ChatMessageFontAsset = config.BindInOrder("ChatMessage.Text.Font", "chatMessageTextFontAsset", "Valheim-AveriaSansLibre", "FontAsset (TMP) to use for ChatMessage text.", (AcceptableValueBase)(object)new AcceptableValueList<string>(array)); ChatMessageFontAsset.OnSettingChanged(delegate(string fontName) { ChatPanelController.ChatPanel?.SetContentFontAsset(UIResources.GetFontAssetByName(fontName)); }); ChatMessageFontSize = config.BindInOrder("ChatMessage.Text.Font", "chatMessageTextFontSize", 16f, "The font size to use for chat messages.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(6f, 64f)); ChatMessageFontSize.OnSettingChanged(delegate(float fontSize) { ChatPanelController.ChatPanel?.SetContentFontSize(fontSize); }); } public static void LateBindConfig(Action<ConfigFile> lateBindConfigAction) { _fejdStartupBindConfigQueue.Enqueue(lateBindConfigAction); } } public sealed class ChatPanel { public GameObject Panel { get; private set; } public RectTransform PanelRectTransform { get; private set; } public Image PanelBackground { get; private set; } public CanvasGroup PanelCanvasGroup { get; private set; } public RectTransformDragger PanelDragger { get; private set; } public GameObject ContentViewport { get; private set; } public GameObject Content { get; private set; } public VerticalLayoutGroup ContentLayoutGroup { get; private set; } public ScrollRect ContentScrollRect { get; private set; } public InputFieldCell TextInput { get; private set; } public ToggleRow MessageTypeToggleRow { get; private set; } public ResizeCell ResizerCell { get; private set; } public RectTransformResizer PanelResizer { get; private set; } public ChatPanel(Transform parentTransform) { Panel = CreateChildPanel(parentTransform); PanelRectTransform = Panel.GetComponent<RectTransform>(); PanelBackground = Panel.GetComponent<Image>(); PanelCanvasGroup = Panel.GetComponent<CanvasGroup>(); PanelDragger = Panel.GetComponent<RectTransformDragger>(); ContentViewport = CreateChildViewport(Panel.transform); Content = CreateChildContent(ContentViewport.transform); ContentLayoutGroup = Content.GetComponent<VerticalLayoutGroup>(); ContentScrollRect = CreateChildScrollRect(ContentViewport, Content); TextInput = new InputFieldCell(Panel.transform); LayoutElement layoutElement = TextInput.Cell.AddComponent<LayoutElement>().SetFlexible(1f); float? height = 35f; layoutElement.SetPreferred(null, height); MessageTypeToggleRow = new ToggleRow(Panel.transform); MessageTypeToggleRow.Row.AddComponent<LayoutElement>().SetIgnoreLayout(ignoreLayout: true); ResizerCell = new ResizeCell(MessageTypeToggleRow.Row.transform); ResizerCell.Cell.AddComponent<LayoutElement>().SetIgnoreLayout(ignoreLayout: true); PanelResizer = ResizerCell.Cell.AddComponent<RectTransformResizer>().SetTargetRectTransform(Panel.GetComponent<RectTransform>()); } private GameObject CreateChildPanel(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0069: 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_0111: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ChatPanel", new Type[1] { typeof(RectTransform) }); val.SetParent(parentTransform); val.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(400f, 400f)); val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false) .SetPadding(8, 8, 8, 8) .SetSpacing(10f); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIBuilder.CreateSuperellipse(400, 400, 15f)) .SetColor(new Color(0f, 0f, 0f, 0.4f)); val.AddComponent<CanvasGroup>().SetAlpha(1f).SetBlocksRaycasts(blocksRaycasts: true); val.AddComponent<RectTransformDragger>().SetTargetRectTransform(val.GetComponent<RectTransform>()); return val; } private GameObject CreateChildViewport(Transform parentTransform) { //IL_0018: 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) //IL_0025: Expected O, but got Unknown //IL_0026: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown GameObject val = new GameObject("Viewport", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.AddComponent<Image>().SetType((Type)3).SetColor(Color.clear); val.AddComponent<RectMask2D>(); val.AddComponent<LayoutElement>().SetFlexible(1f, 1f); return val; } private GameObject CreateChildContent(Transform parentTransform) { //IL_0018: 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) //IL_0025: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_004a: 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) //IL_005f: 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_00c9: Expected O, but got Unknown GameObject val = new GameObject("Content", new Type[1] { typeof(RectTransform) }); GameObjectExtensions.SetParent(val, parentTransform); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.right) .SetPivot(Vector2.zero) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); val.AddComponent<VerticalLayoutGroup>().SetChildControl(true, true).SetChildForceExpand(false, false) .SetPadding(8, 8) .SetSpacing(10f); val.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)0).SetVerticalFit((FitMode)2); return val; } private ScrollRect CreateChildScrollRect(GameObject viewport, GameObject content) { ScrollRect obj = viewport.AddComponent<ScrollRect>(); obj.viewport = viewport.GetComponent<RectTransform>(); obj.content = content.GetComponent<RectTransform>(); obj.horizontal = false; obj.vertical = true; obj.movementType = (MovementType)1; obj.scrollSensitivity = 20f; return obj; } public void OffsetContentVerticalScrollPosition(float offset) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) Transform transform = Content.transform; float num = offset / ((RectTransform)((transform is RectTransform) ? transform : null)).sizeDelta.y; ScrollRect contentScrollRect = ContentScrollRect; contentScrollRect.verticalNormalizedPosition += num; } public void SetContentVerticalScrollPosition(float position) { ContentScrollRect.verticalNormalizedPosition = position; } public void ToggleGrabber(bool toggleOn) { MessageTypeToggleRow.Row.SetActive(toggleOn); } } public sealed class RectTransformDragger : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { private Vector2 _lastMousePosition; [field: SerializeField] public RectTransform TargetRectTransform { get; private set; } public event EventHandler<Vector3> OnEndDragEvent; public RectTransformDragger SetTargetRectTransform(RectTransform rectTransform) { TargetRectTransform = rectTransform; return this; } public void OnBeginDrag(PointerEventData eventData) { //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) _lastMousePosition = eventData.position; } public void OnDrag(PointerEventData eventData) { //IL_0001: 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) //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector2 val = eventData.position - _lastMousePosition; RectTransform targetRectTransform = TargetRectTransform; ((Transform)targetRectTransform).position = ((Transform)targetRectTransform).position + new Vector3(val.x, val.y, 0f); _lastMousePosition = eventData.position; } public void OnEndDrag(PointerEventData eventData) { //IL_0012: 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) this.OnEndDragEvent?.Invoke(this, Vector2.op_Implicit(TargetRectTransform.anchoredPosition)); } } public sealed class RectTransformResizer : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { private Vector2 _lastMousePosition; [field: SerializeField] public RectTransform TargetRectTransform { get; private set; } public event EventHandler<Vector2> OnEndDragEvent; public RectTransformResizer SetTargetRectTransform(RectTransform rectTransform) { TargetRectTransform = rectTransform; return this; } public void OnBeginDrag(PointerEventData eventData) { //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) _lastMousePosition = eventData.position; } public void OnDrag(PointerEventData eventData) { //IL_0001: 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) //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Vector2 val = _lastMousePosition - eventData.position; RectTransform targetRectTransform = TargetRectTransform; targetRectTransform.anchoredPosition += new Vector2(0f, 0f - val.y); RectTransform targetRectTransform2 = TargetRectTransform; targetRectTransform2.sizeDelta += new Vector2(val.x, val.y); _lastMousePosition = eventData.position; } public void OnEndDrag(PointerEventData eventData) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) this.OnEndDragEvent?.Invoke(this, TargetRectTransform.sizeDelta); } } public static class TerminalCommands { [CompilerGenerated] private static class <>O { public static ConsoleEvent <0>__RunShoutCommand; public static ConsoleEvent <1>__RunWhisperCommand; } private static readonly List<ConsoleCommand> _commands = new List<ConsoleCommand>(); public static void ToggleCommands(bool toggleOn) { DeregisterCommands(_commands); _commands.Clear(); if (toggleOn) { _commands.AddRange(RegisterCommands()); } UpdateCommandLists(); } private static ConsoleCommand[] RegisterCommands() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //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: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //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_0063: Expected O, but got Unknown ConsoleCommand[] array = new ConsoleCommand[2]; object obj = <>O.<0>__RunShoutCommand; if (obj == null) { ConsoleEvent val = RunShoutCommand; <>O.<0>__RunShoutCommand = val; obj = (object)val; } array[0] = new ConsoleCommand("shout", "(Chatter) shout <message>", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>O.<1>__RunWhisperCommand; if (obj2 == null) { ConsoleEvent val2 = RunWhisperCommand; <>O.<1>__RunWhisperCommand = val2; obj2 = (object)val2; } array[1] = new ConsoleCommand("whisper", "(Chatter) whisper <message>", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); return (ConsoleCommand[])(object)array; } public static void RunShoutCommand(ConsoleEventArgs args) { if (args.FullLine.Length < 7) { ChatPanelController.ChatPanel?.SetChatTextInputPrefix((Type)2); } else if (Object.op_Implicit((Object)(object)Chat.m_instance)) { Chat.m_instance.SendText((Type)2, args.FullLine.Substring(6)); } } public static void RunWhisperCommand(ConsoleEventArgs args) { if (args.FullLine.Length < 9) { ChatPanelController.ChatPanel?.SetChatTextInputPrefix((Type)0); } else if (Object.op_Implicit((Object)(object)Chat.m_instance)) { Chat.m_instance.SendText((Type)0, args.FullLine.Substring(8)); } } private static void DeregisterCommands(List<ConsoleCommand> commands) { foreach (ConsoleCommand command in commands) { if (Terminal.commands[command.Command] == command) { Terminal.commands.Remove(command.Command); } } } private static void UpdateCommandLists() { Terminal[] array = Object.FindObjectsOfType<Terminal>(true); for (int i = 0; i < array.Length; i++) { array[i].updateCommandList(); } } } } namespace ComfyLib { public static class CodeMatcherExtensions { public static CodeMatcher CopyOperand<T>(this CodeMatcher matcher, out T target) { target = (T)matcher.Operand; return matcher; } } public static class StringExtensions { public static readonly char[] CommaSeparator = new char[1] { ',' }; public static readonly char[] ColonSeparator = new char[1] { ':' }; public static bool TryParseValue<T>(this string text, out T value) { //IL_0052: 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_00c8: Unknown result type (might be due to invalid IL or missing references) try { Vector2 value2; Vector3 value3; ZDOID value4; if (typeof(T) == typeof(string)) { value = (T)(object)text; } else if (typeof(T) == typeof(Vector2) && text.TryParseVector2(out value2)) { value = (T)(object)value2; } else if (typeof(T) == typeof(Vector3) && text.TryParseVector3(out value3)) { value = (T)(object)value3; } else if (typeof(T) == typeof(ZDOID) && text.TryParseZDOID(out value4)) { value = (T)(object)value4; } else if (typeof(T).IsEnum) { value = (T)Enum.Parse(typeof(T), text); } else { value = (T)Convert.ChangeType(text, typeof(T)); } return true; } catch (Exception arg) { Debug.LogError((object)$"Failed to convert value '{text}' to type {typeof(T)}: {arg}"); } value = default(T); return false; } public static bool TryParseVector2(this string text, out Vector2 value) { //IL_0050: 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) string[] array = text.Split(CommaSeparator, 2, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 2 && float.TryParse(array[0], NumberStyles.Float, Cul