public bool Equals(Chat.WorldTextInstance other) { return(GameObject?.GetInstanceID() == other.m_go?.GetInstanceID() && SenderID == other.m_talkerID && Position == other.m_position && Type == other.m_type && string.Equals(User, other.m_name, StringComparison.CurrentCultureIgnoreCase) && string.Equals(Text, other.m_text, StringComparison.CurrentCultureIgnoreCase) ); }
// Token: 0x060004B1 RID: 1201 RVA: 0x00025BF8 File Offset: 0x00023DF8 private void UpdateWorldTextField(Chat.WorldTextInstance wt) { string text = ""; if (wt.m_type == Talker.Type.Shout || wt.m_type == Talker.Type.Ping) { text = wt.m_name + ": "; } text += wt.m_text; wt.m_textField.text = text; }
private static void Prefix(ref Chat __instance, ref Chat.WorldTextInstance wt) { // Apply floating text and colour. // This item gets added in Chat.AddInworldText, but there's a lot of code to handle if I were to intercept it, Postfix on that method works too but for I feel like the update method makes sense. foreach (var messageInfoPair in VChatPlugin.ReceivedMessageInfo.ToList()) { var messageInfo = messageInfoPair.Value; if (messageInfo?.Equals(wt) == true) { wt.m_text = messageInfo.Text; wt.m_textField.color = VChatPlugin.GetTextColor(new CombinedMessageType(wt.m_type)); // Not required but setting the floating text anyway. wt.m_textField.text = messageInfo.Text; VChatPlugin.ReceivedMessageInfo.TryRemove(messageInfoPair.Key, out UserMessageInfo _); return; } } }
// Token: 0x060004B0 RID: 1200 RVA: 0x00025AAC File Offset: 0x00023CAC private void AddInworldText(GameObject go, long senderID, Vector3 position, Talker.Type type, string user, string text) { Chat.WorldTextInstance worldTextInstance = this.FindExistingWorldText(senderID); if (worldTextInstance == null) { worldTextInstance = new Chat.WorldTextInstance(); worldTextInstance.m_talkerID = senderID; worldTextInstance.m_gui = UnityEngine.Object.Instantiate <GameObject>(this.m_worldTextBase, base.transform); worldTextInstance.m_gui.gameObject.SetActive(true); worldTextInstance.m_textField = worldTextInstance.m_gui.transform.Find("Text").GetComponent <Text>(); this.m_worldTexts.Add(worldTextInstance); } worldTextInstance.m_name = user; worldTextInstance.m_type = type; worldTextInstance.m_go = go; worldTextInstance.m_position = position; Color color; switch (type) { case Talker.Type.Whisper: color = new Color(1f, 1f, 1f, 0.75f); text = text.ToLowerInvariant(); goto IL_104; case Talker.Type.Shout: color = Color.yellow; text = text.ToUpper(); goto IL_104; case Talker.Type.Ping: color = new Color(0.6f, 0.7f, 1f, 1f); text = "PING"; goto IL_104; } color = Color.white; IL_104: worldTextInstance.m_textField.color = color; worldTextInstance.m_textField.GetComponent <Outline>().enabled = (type > Talker.Type.Whisper); worldTextInstance.m_timer = 0f; worldTextInstance.m_text = text; this.UpdateWorldTextField(worldTextInstance); }
// Token: 0x060004AF RID: 1199 RVA: 0x00025784 File Offset: 0x00023984 private void UpdateWorldTexts(float dt) { Chat.WorldTextInstance worldTextInstance = null; Camera mainCamera = Utils.GetMainCamera(); if (mainCamera == null) { return; } foreach (Chat.WorldTextInstance worldTextInstance2 in this.m_worldTexts) { worldTextInstance2.m_timer += dt; if (worldTextInstance2.m_timer > this.m_worldTextTTL && worldTextInstance == null) { worldTextInstance = worldTextInstance2; } Chat.WorldTextInstance worldTextInstance3 = worldTextInstance2; worldTextInstance3.m_position.y = worldTextInstance3.m_position.y + dt * 0.15f; Vector3 vector = Vector3.zero; if (worldTextInstance2.m_go) { Character component = worldTextInstance2.m_go.GetComponent <Character>(); if (component) { vector = component.GetHeadPoint() + Vector3.up * 0.3f; } else { vector = worldTextInstance2.m_go.transform.position + Vector3.up * 0.3f; } } else { vector = worldTextInstance2.m_position + Vector3.up * 0.3f; } Vector3 vector2 = mainCamera.WorldToScreenPoint(vector); if (vector2.x < 0f || vector2.x > (float)Screen.width || vector2.y < 0f || vector2.y > (float)Screen.height || vector2.z < 0f) { Vector3 vector3 = vector - mainCamera.transform.position; bool flag = Vector3.Dot(mainCamera.transform.right, vector3) < 0f; Vector3 vector4 = vector3; vector4.y = 0f; float magnitude = vector4.magnitude; float y = vector3.y; Vector3 a = mainCamera.transform.forward; a.y = 0f; a.Normalize(); a *= magnitude; Vector3 b = a + Vector3.up * y; vector2 = mainCamera.WorldToScreenPoint(mainCamera.transform.position + b); vector2.x = (float)(flag ? 0 : Screen.width); } RectTransform rectTransform = worldTextInstance2.m_gui.transform as RectTransform; vector2.x = Mathf.Clamp(vector2.x, rectTransform.rect.width / 2f, (float)Screen.width - rectTransform.rect.width / 2f); vector2.y = Mathf.Clamp(vector2.y, rectTransform.rect.height / 2f, (float)Screen.height - rectTransform.rect.height); vector2.z = Mathf.Min(vector2.z, 100f); worldTextInstance2.m_gui.transform.position = vector2; } if (worldTextInstance != null) { UnityEngine.Object.Destroy(worldTextInstance.m_gui); this.m_worldTexts.Remove(worldTextInstance); } }