// Token: 0x060004BC RID: 1212 RVA: 0x000262E8 File Offset: 0x000244E8 public void SetNpcText(GameObject talker, Vector3 offset, float cullDistance, float ttl, string topic, string text, bool large) { Chat.NpcText npcText = this.FindNpcText(talker); if (npcText != null) { this.ClearNpcText(npcText); } npcText = new Chat.NpcText(); npcText.m_go = talker; npcText.m_gui = UnityEngine.Object.Instantiate <GameObject>(large ? this.m_npcTextBaseLarge : this.m_npcTextBase, base.transform); npcText.m_gui.SetActive(true); npcText.m_animator = npcText.m_gui.GetComponent <Animator>(); npcText.m_topicField = npcText.m_gui.transform.Find("Topic").GetComponent <Text>(); npcText.m_textField = npcText.m_gui.transform.Find("Text").GetComponent <Text>(); npcText.m_ttl = ttl; npcText.m_timeout = (ttl > 0f); npcText.m_offset = offset; npcText.m_cullDistance = cullDistance; if (topic.Length > 0) { npcText.m_textField.text = "<color=orange>" + Localization.instance.Localize(topic) + "</color>\n" + Localization.instance.Localize(text); } else { npcText.m_textField.text = Localization.instance.Localize(text); } this.m_npcTexts.Add(npcText); }
// Token: 0x060004BB RID: 1211 RVA: 0x000260BC File Offset: 0x000242BC private void UpdateNpcTexts(float dt) { Chat.NpcText npcText = null; Camera mainCamera = Utils.GetMainCamera(); foreach (Chat.NpcText npcText2 in this.m_npcTexts) { if (!npcText2.m_go) { npcText2.m_gui.SetActive(false); if (npcText == null) { npcText = npcText2; } } else { if (npcText2.m_timeout) { npcText2.m_ttl -= dt; if (npcText2.m_ttl <= 0f) { npcText2.SetVisible(false); if (!npcText2.IsVisible()) { npcText = npcText2; continue; } continue; } } Vector3 vector = npcText2.m_go.transform.position + npcText2.m_offset; 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) { npcText2.SetVisible(false); } else { npcText2.SetVisible(true); RectTransform rectTransform = npcText2.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); npcText2.m_gui.transform.position = vector2; } if (Vector3.Distance(mainCamera.transform.position, vector) > npcText2.m_cullDistance) { npcText2.SetVisible(false); if (npcText == null && !npcText2.IsVisible()) { npcText = npcText2; } } } } if (npcText != null) { this.ClearNpcText(npcText); } }
// Token: 0x060004BE RID: 1214 RVA: 0x0002643C File Offset: 0x0002463C public void ClearNpcText(GameObject talker) { Chat.NpcText npcText = this.FindNpcText(talker); if (npcText != null) { this.ClearNpcText(npcText); } }
// Token: 0x060004BF RID: 1215 RVA: 0x0002645B File Offset: 0x0002465B private void ClearNpcText(Chat.NpcText npcText) { UnityEngine.Object.Destroy(npcText.m_gui); this.m_npcTexts.Remove(npcText); }
// Token: 0x060004BD RID: 1213 RVA: 0x0002641C File Offset: 0x0002461C public bool IsDialogVisible(GameObject talker) { Chat.NpcText npcText = this.FindNpcText(talker); return(npcText != null && npcText.IsVisible()); }
public static bool Prefix(Chat __instance, List <Chat.NpcText> ___m_npcTexts, float dt) { Chat.NpcText npcText = null; Camera mainCamera = Utils.GetMainCamera(); foreach (Chat.NpcText mNpcText in ___m_npcTexts) { if (mNpcText.m_go) { if (mNpcText.m_timeout) { mNpcText.m_ttl -= dt; if (mNpcText.m_ttl <= 0f) { mNpcText.SetVisible(false); if (mNpcText.IsVisible()) { continue; } npcText = mNpcText; continue; } } Vector3 mGo = mNpcText.m_go.transform.position + mNpcText.m_offset; Vector3 screenPoint = mainCamera.WorldToScreenPoint(mGo); if (screenPoint.x < 0f || screenPoint.x > (float)mainCamera.pixelWidth || screenPoint.y < 0f || screenPoint.y > (float)mainCamera.pixelHeight || screenPoint.z < 0f) { mNpcText.SetVisible(false); } else { mNpcText.SetVisible(true); RectTransform mGui = mNpcText.m_gui.transform as RectTransform; float screenpointX = screenPoint.x; Rect rect = mGui.rect; float halfWidth = rect.width / 2f; float screenWidth = (float)Screen.width; rect = mGui.rect; screenPoint.x = Mathf.Clamp(screenpointX, halfWidth, screenWidth - halfWidth); float screenpointY = screenPoint.y; rect = mGui.rect; float halfHeight = rect.height / 2f; float screenHeight = (float)Screen.height; rect = mGui.rect; screenPoint.y = Mathf.Clamp(screenpointY, halfHeight, screenHeight - rect.height); screenPoint.z = 0f; mNpcText.m_gui.transform.position = screenPoint; } if (Vector3.Distance(mainCamera.transform.position, mGo) <= mNpcText.m_cullDistance) { continue; } mNpcText.SetVisible(false); if (npcText != null || mNpcText.IsVisible()) { continue; } npcText = mNpcText; } else { mNpcText.m_gui.SetActive(false); if (npcText != null) { continue; } npcText = mNpcText; } } if (npcText != null) { Chat_ClearNpcText_ReversePatch.ReversePatchClearNpcText(__instance, npcText); } return(false); }
public static void ReversePatchClearNpcText(object instance, Chat.NpcText npcText) { throw new NotImplementedException("Stub for reverse patch."); }