The BepInEx console will not appear when launching like it does for other games on Thunderstore (you can turn it back on in your BepInEx.cfg file). If your PEAK crashes on startup, add -dx12 to your launch parameters.
Decompiled source of PeakTextChat v1.2.2
PeakTextChat.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; using UnityEngine.UI.ProceduralImage; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PeakTextChat")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.2.2.0")] [assembly: AssemblyInformationalVersion("1.2.2+294b86105193f376de5023dc0878acf0099ffba5")] [assembly: AssemblyProduct("PeakTextChat")] [assembly: AssemblyTitle("PeakTextChat")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.2.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 PeakTextChat { public class BarGroupChildWatcher : MonoBehaviour { public Transform textChatDummyTransform; private void OnTransformChildrenChanged() { if ((Object)(object)textChatDummyTransform != (Object)null && textChatDummyTransform.GetSiblingIndex() > 0) { textChatDummyTransform.SetAsFirstSibling(); } } } public class TextChatDisplay : MonoBehaviour { public class ChatMessage { public string message; public GameObject textObj; public TMP_Text text; private Color textColor; private float hideDelay = 40f; private float hideTime = 10f; private float hideTimer = -1f; private float hide = 0f; public void Update() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) hideTimer -= Time.deltaTime; if (hideTimer <= 0f && hide < 1f) { hide += Time.deltaTime / hideTime; ((Graphic)text).color = new Color(textColor.r, textColor.g, textColor.b, 1f - hide); } } public ChatMessage(string message, GameObject textObject, float hideDelay) { //IL_0055: 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) this.message = message; textObj = textObject; text = textObject.GetComponent<TMP_Text>(); textColor = ((Graphic)text).color; this.hideDelay = hideDelay; hideTimer = hideDelay; } } private int maxMessages = 30; private Vector2 boxSize = new Vector2(500f, 300f); private float fadeInTime = 0.03f; private float fadeOutTime = 5f; private float hideTime = 5f; private float fadeOutDelay = 15f; private float hideDelay = 40f; private float messageHideDelay = 40f; private float fontSize = 25f; private bool usingIMGUI = false; private TMP_InputField inputField; private RectTransform chatLogViewportTransform; private RectTransform baseTransform; private CanvasGroup canvasGroup; private float fade = 1f; private float fadeTimer = -1f; private float hide = 0f; private float hideTimer = -1f; private KeysHelper.KeyCodeInfo keyInfo; private Color offWhite = new Color(0.87f, 0.85f, 0.76f); private Color red = new Color(0.99f, 0.33f, 0f); private List<ChatMessage> messages = new List<ChatMessage>(); public bool isBlockingInput = false; public int framesSinceInputBlocked = 0; public static TextChatDisplay instance; private string imguiFieldString = ""; private bool imguiTyping = false; private GameObject currentSelection; private void Awake() { instance = this; } private void Start() { //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) keyInfo = KeysHelper.GetKeyCodeShortInfo(PeakTextChatPlugin.configKey.Value); fontSize = ((PeakTextChatPlugin.configFontSize.Value < 0f) ? 1E+09f : PeakTextChatPlugin.configFontSize.Value); hideDelay = ((PeakTextChatPlugin.configHideDelay.Value < 0f) ? float.PositiveInfinity : PeakTextChatPlugin.configHideDelay.Value); fadeOutDelay = Mathf.Min((PeakTextChatPlugin.configFadeDelay.Value < 0f) ? float.PositiveInfinity : PeakTextChatPlugin.configFadeDelay.Value, hideDelay); messageHideDelay = ((PeakTextChatPlugin.configMessageFadeDelay.Value < 0f) ? float.PositiveInfinity : PeakTextChatPlugin.configMessageFadeDelay.Value); usingIMGUI = PeakTextChatPlugin.configIMGUI.Value; string[] array = PeakTextChatPlugin.configChatSize.Value.Split(':'); if (array.Length >= 2) { string s = array[0].Replace(" ", ""); string s2 = array[1].Replace(" ", ""); if (float.TryParse(s, out var result) && float.TryParse(s2, out var result2)) { boxSize = new Vector2(Mathf.Max(result, 10f), Mathf.Max(result2, 10f)); } else { boxSize = new Vector2(500f, 300f); } } ResetTimers(); SetupChatGUI(); } private void Update() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (isBlockingInput) { framesSinceInputBlocked = -1; } else { framesSinceInputBlocked = Mathf.Min(framesSinceInputBlocked + 1, 50); } if (!((Component)this).gameObject.activeInHierarchy) { isBlockingInput = false; return; } if ((Object)(object)currentSelection != (Object)(object)EventSystem.current.currentSelectedGameObject) { currentSelection = EventSystem.current.currentSelectedGameObject; if ((Object)(object)currentSelection != (Object)(object)((Component)inputField).gameObject) { isBlockingInput = false; } } if (!GUIManager.instance.windowBlockingInput && Input.GetKeyDown(keyInfo.key) && (Object)(object)inputField != (Object)null && (Object)(object)EventSystem.current != (Object)null) { if (usingIMGUI) { imguiTyping = true; GUI.FocusControl("ptctf"); } else { EventSystem.current.SetSelectedGameObject(((Component)inputField).gameObject, (BaseEventData)null); inputField.ActivateInputField(); } isBlockingInput = true; } if (isBlockingInput) { ResetTimers(); } if (PeakTextChatPlugin.configPos.Value == PeakTextChatPlugin.TextChatPosition.BottomLeft) { UpdatePosition(isBottomLeft: true); } fade = Mathf.Clamp((fadeTimer <= 0f) ? (fade - Time.deltaTime / fadeOutTime) : (fade + Time.deltaTime / fadeInTime), 0f, 1f); hide = Mathf.Clamp((hideTimer <= 0f) ? (hide + Time.deltaTime / hideTime) : (hide - Time.deltaTime / fadeInTime), 0f, 1f); fadeTimer -= Time.deltaTime; hideTimer -= Time.deltaTime; if ((Object)(object)canvasGroup != (Object)null) { canvasGroup.alpha = fade * 0.5f + (1f - hide) * 0.5f; } foreach (ChatMessage message in messages) { message.Update(); } } private void SetupChatGUI() { //IL_0049: 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: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Expected O, but got Unknown //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Expected O, but got Unknown //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) GUIManager val = GUIManager.instance; baseTransform = ((Component)this).gameObject.GetComponent<RectTransform>() ?? ((Component)this).gameObject.AddComponent<RectTransform>(); ((Transform)baseTransform).SetParent(((Component)this).transform, false); UpdatePosition(); baseTransform.sizeDelta = boxSize; canvasGroup = ((Component)this).gameObject.AddComponent<CanvasGroup>(); canvasGroup.alpha = 1f; canvasGroup.blocksRaycasts = true; canvasGroup.interactable = true; canvasGroup.ignoreParentGroups = false; GameObject val2 = new GameObject("Shadow"); val2.transform.SetParent((Transform)(object)baseTransform, false); RectTransform val3 = val2.AddComponent<RectTransform>(); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.offsetMin = Vector2.zero; val3.offsetMax = Vector2.zero; ProceduralImage val4 = val2.AddComponent<ProceduralImage>(); ((Graphic)val4).color = new Color(0f, 0f, 0f, 0.3f); val4.FalloffDistance = 10f; val4.SetModifierType<UniformModifier>().Radius = fontSize / 4f + 10f; GameObject val5 = new GameObject("ChatLog"); RectTransform val6 = val5.AddComponent<RectTransform>(); ((Transform)val6).SetParent((Transform)(object)baseTransform, false); val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; val6.offsetMin = new Vector2(0f, fontSize * 2f); val6.offsetMax = Vector2.zero; val5.AddComponent<RectMask2D>(); GameObject val7 = new GameObject("Viewport"); chatLogViewportTransform = val7.AddComponent<RectTransform>(); ((Transform)chatLogViewportTransform).SetParent((Transform)(object)val6, false); chatLogViewportTransform.pivot = new Vector2(0.5f, 0f); chatLogViewportTransform.anchorMin = Vector2.zero; chatLogViewportTransform.anchorMax = new Vector2(1f, 0f); chatLogViewportTransform.offsetMin = Vector2.zero; chatLogViewportTransform.offsetMax = new Vector2(0f, 5000f); inputField = CreateInputField(); RectTransform val8 = (RectTransform)((Component)inputField).transform; val8.pivot = new Vector2(0.5f, 0f); val8.anchorMin = new Vector2(0f, 0f); val8.anchorMax = new Vector2(1f, 0f); val8.offsetMin = new Vector2(5f, 5f); val8.offsetMax = new Vector2(-5f, fontSize * 1.75f); ((Transform)val8).SetParent((Transform)(object)baseTransform, false); VerticalLayoutGroup val9 = val7.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val9).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val9).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)val9).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val9).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val9).childScaleWidth = false; ((HorizontalOrVerticalLayoutGroup)val9).childScaleHeight = false; ((LayoutGroup)val9).childAlignment = (TextAnchor)7; ((LayoutGroup)val9).padding = new RectOffset((int)(fontSize * 0.6f), (int)(fontSize * 0.6f), (int)(fontSize / 20f), (int)(fontSize / 20f)); ((HorizontalOrVerticalLayoutGroup)val9).spacing = (0f - fontSize) / 8f; ((UnityEvent<string>)(object)inputField.onSubmit).AddListener((UnityAction<string>)delegate(string e) { inputField.text = ""; inputField.textComponent.text = ""; TextChatManager.instance?.SendChatMessage(e); }); ((UnityEvent<string>)(object)inputField.onEndEdit).AddListener((UnityAction<string>)delegate { EventSystem.current.SetSelectedGameObject((GameObject)null); isBlockingInput = false; }); GameObject val10 = new GameObject("Border"); val10.transform.SetParent((Transform)(object)baseTransform, false); RectTransform val11 = val10.AddComponent<RectTransform>(); val11.anchorMin = Vector2.zero; val11.anchorMax = Vector2.one; val11.offsetMin = Vector2.zero; val11.offsetMax = Vector2.zero; ProceduralImage val12 = val10.AddComponent<ProceduralImage>(); ((Graphic)val12).color = offWhite; val12.BorderWidth = 2f; val12.SetModifierType<UniformModifier>().Radius = fontSize / 4f + 5f; } private TMP_InputField CreateInputField() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("InputField"); TMP_InputField val2 = val.AddComponent<TMP_InputField>(); ((Behaviour)val2).enabled = false; ProceduralImage val4 = (ProceduralImage)(object)(((Selectable)val2).targetGraphic = (Graphic)(object)((Component)val2).gameObject.AddComponent<ProceduralImage>()); ((Graphic)val4).color = offWhite; val4.SetModifierType<UniformModifier>().Radius = fontSize / 4f; GameObject val5 = new GameObject("Text Area"); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMax = Vector2.one; val6.anchorMin = Vector2.zero; val6.offsetMax = new Vector2((0f - fontSize) / 2f, (0f - fontSize) * 0.3f); val6.offsetMin = new Vector2(fontSize / 2f, fontSize * 0.3f); ((Transform)val6).SetParent(((Component)val2).transform, false); RectMask2D val7 = val5.AddComponent<RectMask2D>(); val7.padding = new Vector4((0f - fontSize) * 0.4f, (0f - fontSize) / 4f, (0f - fontSize) * 0.4f, (0f - fontSize) / 4f); TMP_Text val8 = CreateText((Transform)(object)val6); ((Graphic)val8).color = new Color(0f, 0f, 0f, 0.6f); val8.text = "Press " + keyInfo.keyText + " to chat"; ((Object)val8).name = "Placeholder"; TMP_Text val9 = CreateText((Transform)(object)val6); ((Graphic)val9).color = new Color(0f, 0f, 0f, 1f); val2.textViewport = val6; val2.textComponent = val9; val2.placeholder = (Graphic)(object)val8; val2.richText = false; val2.restoreOriginalTextOnEscape = false; ((Behaviour)val2).enabled = true; return val2; } private TMP_Text CreateText(Transform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: 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_0036: 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) GameObject val = new GameObject("Text"); RectTransform val2 = val.AddComponent<RectTransform>(); val2.anchorMax = Vector2.one; val2.anchorMin = Vector2.zero; val2.offsetMax = new Vector2(-2f, 0f); val2.offsetMin = new Vector2(2f, 4f); ((Transform)val2).SetParent(parent, false); TextMeshProUGUI val3 = val.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val3).text = "New Text"; if ((Object)(object)GUIManagerPatch.darumaDropOneFont != (Object)null) { ((TMP_Text)val3).font = GUIManagerPatch.darumaDropOneFont; } ((TMP_Text)val3).fontSize = fontSize; ((TMP_Text)val3).horizontalAlignment = (HorizontalAlignmentOptions)1; ((TMP_Text)val3).verticalAlignment = (VerticalAlignmentOptions)512; return (TMP_Text)(object)val3; } public void AddMessage(string message) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)chatLogViewportTransform != (Object)null)) { return; } TMP_Text val = CreateText((Transform)(object)chatLogViewportTransform); val.text = message; ((Graphic)val).color = offWhite; val.lineSpacing = (0f - fontSize) * 0.75f; Vector2 preferredValues = val.GetPreferredValues(message, boxSize.x - 24f, 1000f); ((RectTransform)val.transform).sizeDelta = new Vector2(0f, preferredValues.y); ChatMessage item = new ChatMessage(message, ((Component)val).gameObject, messageHideDelay); messages.Add(item); if (messages.Count > maxMessages) { ChatMessage chatMessage = messages[0]; if (chatMessage != null && (Object)(object)chatMessage.textObj != (Object)null) { Object.Destroy((Object)(object)chatMessage.textObj); } messages.RemoveAt(0); } ResetTimers(); } public void AddMessage(TextChatManager.Message messageData) { //IL_0049: 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_004e: 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) if ((Object)(object)chatLogViewportTransform != (Object)null) { Color val = (Color)(((Object)(object)messageData.character != (Object)null) ? messageData.character.refs.customization.PlayerColor : new Color(0.64f, 0.69f, 0.83f)); string[] obj = new string[5] { "<color=#", ColorUtility.ToHtmlStringRGB(val), ">[", null, null }; Character character = messageData.character; obj[3] = ((character != null) ? character.characterName : null) ?? "Unknown"; obj[4] = "]</color>"; string text = string.Concat(obj); string text2 = messageData.message; if (!PeakTextChatPlugin.configRichTextEnabled.Value) { text2 = Regex.Replace(text2, "<.*?>", string.Empty); } AddMessage(text + ": " + text2); } } private void ResetTimers() { fadeTimer = fadeOutDelay; hideTimer = hideDelay; } private void UpdatePosition(bool isBottomLeft = false) { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00ab: Unknown result type (might be due to invalid IL or missing references) if (isBottomLeft || PeakTextChatPlugin.configPos.Value == PeakTextChatPlugin.TextChatPosition.BottomLeft) { if ((Object)(object)baseTransform != (Object)null && (Object)(object)StaminaBarPatch.barGroupChildWatcher.textChatDummyTransform != (Object)null) { baseTransform.pivot = Vector2.zero; baseTransform.anchorMax = Vector2.zero; baseTransform.anchorMin = Vector2.zero; ((Transform)baseTransform).position = StaminaBarPatch.barGroupChildWatcher.textChatDummyTransform.position; RectTransform obj = baseTransform; obj.anchoredPosition += new Vector2(0f, 40f); } } else if (PeakTextChatPlugin.configPos.Value == PeakTextChatPlugin.TextChatPosition.TopLeft) { baseTransform.pivot = new Vector2(0f, 1f); baseTransform.anchorMax = new Vector2(0f, 1f); baseTransform.anchorMin = new Vector2(0f, 1f); baseTransform.anchoredPosition = new Vector2(64f, -62f); } else if (PeakTextChatPlugin.configPos.Value == PeakTextChatPlugin.TextChatPosition.TopRight) { baseTransform.pivot = Vector2.one; baseTransform.anchorMax = Vector2.one; baseTransform.anchorMin = Vector2.one; baseTransform.anchoredPosition = new Vector2(-64f, -62f); } } private void OnGUI() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Invalid comparison between Unknown and I4 if (imguiTyping) { GUI.SetNextControlName("ptctf"); GUIStyle val = new GUIStyle(); val.fontSize = (int)(fontSize * 0.8f); val.clipping = (TextClipping)1; val.padding = new RectOffset((int)(fontSize * 0.7f), (int)(fontSize * 0.7f), (int)(fontSize * 0.24f), 0); Rect val2 = RectTransformToScreenSpace((RectTransform)((Component)inputField).transform); PeakTextChatPlugin.Logger.LogInfo((object)(((Rect)(ref val2)).xMin + " " + ((Rect)(ref val2)).yMin)); imguiFieldString = GUI.TextArea(val2, imguiFieldString, val); inputField.text = " "; if (GUI.GetNameOfFocusedControl() != "ptctf") { GUI.FocusControl("ptctf"); } if (imguiFieldString.Contains("\n")) { TextChatManager.instance?.SendChatMessage(imguiFieldString.Replace("\n", "")); imguiFieldString = ""; GUI.FocusControl(""); Event.current.Use(); imguiTyping = false; isBlockingInput = false; inputField.text = ""; } else if (Event.current.isKey && (int)Event.current.keyCode == 27) { GUI.FocusControl(""); imguiTyping = false; inputField.text = imguiFieldString; isBlockingInput = false; Event.current.Use(); } } } public static Rect RectTransformToScreenSpace(RectTransform transform) { //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) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0034: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) Rect rect = transform.rect; Vector2 val = Vector2.Scale(((Rect)(ref rect)).size, Vector2.op_Implicit(((Transform)transform).lossyScale)); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(((Transform)transform).position.x, (float)Screen.height - ((Transform)transform).position.y); return new Rect(val2 - val * new Vector2(0.5f, 1f), val); } } public class TextChatManager : MonoBehaviour { public class Message { public Character character; public string message; public bool isDead; public Message(string userId, string message, bool isDead) { character = Character.AllCharacters.Find(delegate(Character c) { PhotonView photonView = ((MonoBehaviourPun)c).photonView; object obj; if (photonView == null) { obj = null; } else { Player owner = photonView.Owner; obj = ((owner != null) ? owner.UserId : null); } return (string?)obj == userId; }); this.message = message; this.isDead = isDead; } } public static TextChatManager instance; private Character character; private byte chatEventCode = 81; private void Start() { instance = this; character = ((Component)this).GetComponent<Character>(); } private void OnEnable() { PhotonNetwork.NetworkingClient.EventReceived += OnEventReceived; } private void OnDisable() { PhotonNetwork.NetworkingClient.EventReceived -= OnEventReceived; } private void OnEventReceived(EventData eventData) { if (eventData.Code == chatEventCode) { object[] array = (object[])eventData.CustomData; if (array.Length >= 4) { string text = array[0]?.ToString() ?? "???"; string message = array[1]?.ToString() ?? ""; string userId = array[2]?.ToString() ?? ""; bool result; bool isDead = bool.TryParse(array[3]?.ToString(), out result) && result; ReceiveChatMessage(userId, message, isDead); } } } public void ReceiveChatMessage(string userId, string message, bool isDead) { if ((Object)(object)TextChatDisplay.instance != (Object)null) { TextChatDisplay.instance.AddMessage(new Message(userId, message, isDead)); } } public void SendChatMessage(string message) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown if (!string.IsNullOrWhiteSpace(message)) { bool flag = false; if ((Object)(object)Character.localCharacter?.data != (Object)null) { flag = Character.localCharacter.data.dead; } object[] array = new object[4] { PhotonNetwork.LocalPlayer.NickName, message, PhotonNetwork.LocalPlayer.UserId, flag }; PhotonNetwork.RaiseEvent(chatEventCode, (object)array, new RaiseEventOptions { Receivers = (ReceiverGroup)1 }, SendOptions.SendReliable); } } public static void CleanupObjects() { if ((Object)(object)instance != (Object)null) { Object.Destroy((Object)(object)((Component)instance).gameObject); } } } public static class KeysHelper { public class KeyCodeInfo { public KeyCodeShort shortKey; public KeyCode key; public string keyText; public KeyCodeInfo(KeyCodeShort shortKey, KeyCode key, string keyText) { //IL_0010: 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) this.shortKey = shortKey; this.key = key; this.keyText = keyText; } } public static List<KeyCodeInfo> infos = new List<KeyCodeInfo> { new KeyCodeInfo(KeyCodeShort.A, (KeyCode)97, "A"), new KeyCodeInfo(KeyCodeShort.B, (KeyCode)98, "B"), new KeyCodeInfo(KeyCodeShort.C, (KeyCode)99, "C"), new KeyCodeInfo(KeyCodeShort.D, (KeyCode)100, "D"), new KeyCodeInfo(KeyCodeShort.E, (KeyCode)101, "E"), new KeyCodeInfo(KeyCodeShort.F, (KeyCode)102, "F"), new KeyCodeInfo(KeyCodeShort.G, (KeyCode)103, "G"), new KeyCodeInfo(KeyCodeShort.H, (KeyCode)104, "H"), new KeyCodeInfo(KeyCodeShort.I, (KeyCode)105, "I"), new KeyCodeInfo(KeyCodeShort.J, (KeyCode)106, "J"), new KeyCodeInfo(KeyCodeShort.K, (KeyCode)107, "K"), new KeyCodeInfo(KeyCodeShort.L, (KeyCode)108, "L"), new KeyCodeInfo(KeyCodeShort.M, (KeyCode)109, "M"), new KeyCodeInfo(KeyCodeShort.N, (KeyCode)110, "N"), new KeyCodeInfo(KeyCodeShort.O, (KeyCode)111, "O"), new KeyCodeInfo(KeyCodeShort.P, (KeyCode)112, "P"), new KeyCodeInfo(KeyCodeShort.Q, (KeyCode)113, "Q"), new KeyCodeInfo(KeyCodeShort.R, (KeyCode)114, "R"), new KeyCodeInfo(KeyCodeShort.S, (KeyCode)115, "S"), new KeyCodeInfo(KeyCodeShort.T, (KeyCode)116, "T"), new KeyCodeInfo(KeyCodeShort.U, (KeyCode)117, "U"), new KeyCodeInfo(KeyCodeShort.V, (KeyCode)118, "V"), new KeyCodeInfo(KeyCodeShort.W, (KeyCode)119, "W"), new KeyCodeInfo(KeyCodeShort.X, (KeyCode)120, "X"), new KeyCodeInfo(KeyCodeShort.Y, (KeyCode)121, "Y"), new KeyCodeInfo(KeyCodeShort.Z, (KeyCode)122, "Z"), new KeyCodeInfo(KeyCodeShort.One, (KeyCode)49, "1"), new KeyCodeInfo(KeyCodeShort.Two, (KeyCode)50, "2"), new KeyCodeInfo(KeyCodeShort.Three, (KeyCode)51, "3"), new KeyCodeInfo(KeyCodeShort.Four, (KeyCode)52, "4"), new KeyCodeInfo(KeyCodeShort.Five, (KeyCode)53, "5"), new KeyCodeInfo(KeyCodeShort.Six, (KeyCode)54, "6"), new KeyCodeInfo(KeyCodeShort.Seven, (KeyCode)55, "7"), new KeyCodeInfo(KeyCodeShort.Eight, (KeyCode)56, "8"), new KeyCodeInfo(KeyCodeShort.Nine, (KeyCode)57, "9"), new KeyCodeInfo(KeyCodeShort.Zero, (KeyCode)48, "0"), new KeyCodeInfo(KeyCodeShort.Minus, (KeyCode)45, "-"), new KeyCodeInfo(KeyCodeShort.Equals, (KeyCode)61, "="), new KeyCodeInfo(KeyCodeShort.Tab, (KeyCode)9, "Tab"), new KeyCodeInfo(KeyCodeShort.LeftBracket, (KeyCode)91, "["), new KeyCodeInfo(KeyCodeShort.RightBracket, (KeyCode)93, "]"), new KeyCodeInfo(KeyCodeShort.Semicolon, (KeyCode)59, ";"), new KeyCodeInfo(KeyCodeShort.Quote, (KeyCode)39, "'"), new KeyCodeInfo(KeyCodeShort.Backslash, (KeyCode)92, "\\"), new KeyCodeInfo(KeyCodeShort.Comma, (KeyCode)44, ","), new KeyCodeInfo(KeyCodeShort.Period, (KeyCode)46, "."), new KeyCodeInfo(KeyCodeShort.Slash, (KeyCode)47, "/"), new KeyCodeInfo(KeyCodeShort.Numpad0, (KeyCode)256, "Num0"), new KeyCodeInfo(KeyCodeShort.Numpad1, (KeyCode)257, "Num1"), new KeyCodeInfo(KeyCodeShort.Numpad2, (KeyCode)258, "Num2"), new KeyCodeInfo(KeyCodeShort.Numpad3, (KeyCode)259, "Num3"), new KeyCodeInfo(KeyCodeShort.Numpad4, (KeyCode)260, "Num4"), new KeyCodeInfo(KeyCodeShort.Numpad5, (KeyCode)261, "Num5"), new KeyCodeInfo(KeyCodeShort.Numpad6, (KeyCode)262, "Num6"), new KeyCodeInfo(KeyCodeShort.Numpad7, (KeyCode)263, "Num7"), new KeyCodeInfo(KeyCodeShort.Numpad8, (KeyCode)264, "Num8"), new KeyCodeInfo(KeyCodeShort.Numpad9, (KeyCode)265, "Num9") }; public static KeyCodeInfo GetKeyCodeShortInfo(KeyCodeShort key) { return infos.Find((KeyCodeInfo i) => i.shortKey == key); } } public enum KeyCodeShort { A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Zero, Tab, Minus, Equals, LeftBracket, RightBracket, Semicolon, Quote, Backslash, Comma, Period, Slash, Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9 } public static class ProceduralImageExtensions { public static T SetModifierType<T>(this ProceduralImage image) where T : ProceduralImageModifier { image.ModifierType = typeof(T); return ((Component)image).gameObject.GetComponent<T>() ?? ((Component)image).gameObject.AddComponent<T>(); } } public static class GameUtilsPatch { [HarmonyPatch(typeof(GameUtils), "Awake")] [HarmonyPostfix] public static void AwakePatch(GameUtils __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject("TextChatManager"); val.transform.SetParent(((Component)__instance).transform, false); val.AddComponent<TextChatManager>(); } } [HarmonyPatch(typeof(StaminaBar), "Start")] public static class StaminaBarPatch { public static BarGroupChildWatcher barGroupChildWatcher; [HarmonyPostfix] public static void Postfix(StaminaBar __instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GUIManager.instance != (Object)null) { GameObject val = new GameObject("TextChatPos"); RectTransform val2 = (RectTransform)((Component)__instance).transform.parent; val2.offsetMax = new Vector2(val2.offsetMax.x, 1000f); val.transform.SetParent((Transform)(object)val2); RectTransform val3 = val.AddComponent<RectTransform>(); ((Transform)val3).SetAsFirstSibling(); val3.sizeDelta = Vector2.zero; barGroupChildWatcher = ((Component)val2).gameObject.AddComponent<BarGroupChildWatcher>(); barGroupChildWatcher.textChatDummyTransform = val.transform; } } public static void CleanupObjects() { Object.Destroy((Object)(object)barGroupChildWatcher.textChatDummyTransform); Object.Destroy((Object)(object)barGroupChildWatcher); } } public static class GUIManagerPatch { public static Canvas textChatCanvas; public static TMP_FontAsset darumaDropOneFont; private static bool isHUDActive = true; [HarmonyPatch(typeof(GUIManager), "Start")] [HarmonyPostfix] public static void StartPostfix(GUIManager __instance) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown Transform transform = ((Component)__instance).transform; GameObject val = new GameObject("TextChatCanvas"); val.transform.SetParent(transform, false); textChatCanvas = val.AddComponent<Canvas>(); textChatCanvas.renderMode = (RenderMode)1; CanvasScaler val2 = ((Component)textChatCanvas).gameObject.GetComponent<CanvasScaler>() ?? ((Component)textChatCanvas).gameObject.AddComponent<CanvasScaler>(); val2.referencePixelsPerUnit = 100f; val2.matchWidthOrHeight = 1f; val2.referenceResolution = new Vector2(1920f, 1080f); val2.scaleFactor = 1f; val2.screenMatchMode = (ScreenMatchMode)0; val2.uiScaleMode = (ScaleMode)1; GameObject val3 = new GameObject("TextChat"); val3.transform.SetParent(((Component)textChatCanvas).transform, false); val3.AddComponent<TextChatDisplay>(); Canvas hudCanvas = __instance.hudCanvas; object obj; if (hudCanvas == null) { obj = null; } else { Transform obj2 = ((Component)hudCanvas).transform.Find("Notification/Fog"); obj = ((obj2 != null) ? ((Component)obj2).gameObject.GetComponent<TMP_Text>() : null); } TMP_Text val4 = (TMP_Text)obj; if ((Object)(object)val4 != (Object)null) { darumaDropOneFont = val4.font; } } [HarmonyPatch(typeof(GUIManager), "LateUpdate")] [HarmonyPostfix] public static void LateUpdatePostfix(GUIManager __instance) { if (isHUDActive != ((Component)__instance.hudCanvas).gameObject.activeInHierarchy) { isHUDActive = ((Component)__instance.hudCanvas).gameObject.activeInHierarchy; ((Component)textChatCanvas).gameObject.SetActive(isHUDActive); } } [HarmonyPatch(typeof(GUIManager), "UpdatePaused")] [HarmonyPrefix] public static bool UpdatePausedPrefix(GUIManager __instance) { TextChatDisplay instance = TextChatDisplay.instance; if (instance != null && instance.framesSinceInputBlocked <= 1 && !__instance.pauseMenu.isOpen) { return false; } return true; } } public static class InputBlockingPatches { private static readonly MethodInfo windowBlockingInput = AccessTools.PropertySetter(typeof(GUIManager), "windowBlockingInput"); [HarmonyPatch(typeof(GUIManager), "UpdateWindowStatus")] [HarmonyPostfix] public static void UpdateWindowStatusPatch() { TextChatDisplay instance = TextChatDisplay.instance; if (instance != null && instance.isBlockingInput) { windowBlockingInput?.Invoke(GUIManager.instance, new object[1] { true }); } } [HarmonyPatch(typeof(CinemaCamera), "Update")] [HarmonyPrefix] public static bool UpdateCinemaCamPatch(CinemaCamera __instance) { GUIManager instance = GUIManager.instance; if (instance != null && instance.windowBlockingInput && !__instance.on) { return false; } return true; } } [BepInPlugin("com.borealityy.peaktextchat", "PeakTextChat", "1.2.2")] public class PeakTextChatPlugin : BaseUnityPlugin { public enum TextChatPosition { BottomLeft, TopLeft, TopRight } internal static ManualLogSource Logger; private Harmony harmony; public static ConfigEntry<float> configFontSize; public static ConfigEntry<string> configChatSize; public static ConfigEntry<float> configMessageFadeDelay; public static ConfigEntry<float> configFadeDelay; public static ConfigEntry<float> configHideDelay; public static ConfigEntry<KeyCodeShort> configKey; public static ConfigEntry<TextChatPosition> configPos; public static ConfigEntry<bool> configRichTextEnabled; public static ConfigEntry<bool> configIMGUI; private void Awake() { //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"PeakTextChat is loaded!"); configKey = ((BaseUnityPlugin)this).Config.Bind<KeyCodeShort>("Display", "ChatKey", KeyCodeShort.Slash, "The key that activates typing in chat"); configIMGUI = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "UseIMGUI", false, "Use IMGUI for the text field (use if you're having problems with typing)"); configPos = ((BaseUnityPlugin)this).Config.Bind<TextChatPosition>("Display", "ChatPosition", TextChatPosition.BottomLeft, "The position of the text chat"); configChatSize = ((BaseUnityPlugin)this).Config.Bind<string>("Display", "ChatSize", "500:300", "The size of the text chat (formatted X:Y)"); configFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ChatFontSize", 20f, "Size of the chat's text"); configRichTextEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ChatRichText", true, "Whether rich text tags get parsed in messages (e.g. <b> for bold text)"); configFadeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ChatFadeDelay", 15f, "How long before the chat fades out (a negative number means never)"); configHideDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ChatHideDelay", 40f, "How long before the chat hides completely (a negative number means never)"); configMessageFadeDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ChatMessageHideDelay", 40f, "How long before a chat message disappears (a negative number means never)"); harmony = new Harmony("com.borealityy.peaktextchat"); harmony.PatchAll(typeof(GameUtilsPatch)); harmony.PatchAll(typeof(StaminaBarPatch)); harmony.PatchAll(typeof(GUIManagerPatch)); harmony.PatchAll(typeof(InputBlockingPatches)); } private void OnDestroy() { if ((Object)(object)TextChatDisplay.instance != (Object)null) { Object.Destroy((Object)(object)((Component)TextChatDisplay.instance).gameObject); } if ((Object)(object)GUIManagerPatch.textChatCanvas != (Object)null) { Object.Destroy((Object)(object)GUIManagerPatch.textChatCanvas); } TextChatManager.CleanupObjects(); StaminaBarPatch.CleanupObjects(); harmony.UnpatchSelf(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "PeakTextChat"; public const string PLUGIN_NAME = "PeakTextChat"; public const string PLUGIN_VERSION = "1.2.2"; } }