From daad9e0e6d90eae50464bb7c7a99da14bed22f62 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Sat, 26 Oct 2024 16:54:37 -0500 Subject: [PATCH] Fix chat theme and errors --- Patches/ChatPatch.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Patches/ChatPatch.cs b/Patches/ChatPatch.cs index b48edfd..cee0abc 100644 --- a/Patches/ChatPatch.cs +++ b/Patches/ChatPatch.cs @@ -105,7 +105,8 @@ class ChatPatch [HarmonyPostfix] public static void AddChat_Postfix(ChatController __instance, [HarmonyArgument(0)] PlayerControl sourcePlayer, [HarmonyArgument(1)] string chatText) { - ChatBubble chatBubble = SetChatPoolTheme(); + ChatBubble? chatBubble = SetChatPoolTheme(); + if (chatBubble == null) return; StringBuilder sbTag = new StringBuilder(); StringBuilder sbInfo = new StringBuilder(); @@ -178,7 +179,7 @@ class ChatPatch chatBubble.NameText.text = playerName; chatBubble.ColorBlindName.color = Palette.PlayerColors[sourcePlayer.Data.DefaultOutfit.ColorId]; - if (sourcePlayer.IsAlive()) + if (sourcePlayer.IsAlive() || !PlayerControl.LocalPlayer.IsAlive()) { Logger.Log($"{sourcePlayer.Data.PlayerName} -> {chatText}", "ChatLog"); } @@ -234,7 +235,7 @@ class ChatPatch } // Set chat theme - public static ChatBubble SetChatPoolTheme(ChatBubble? asChatBubble = null) + public static ChatBubble? SetChatPoolTheme(ChatBubble? asChatBubble = null) { ChatBubble Get() => HudManager.Instance.Chat.chatBubblePool.activeChildren.ToArray() .Select(c => c.GetComponent()) @@ -242,6 +243,8 @@ class ChatPatch ChatBubble chatBubble = asChatBubble ??= Get(); + if (chatBubble == null) return chatBubble; + if (Main.ChatDarkMode.Value) { chatBubble.transform.Find("ChatText (TMP)").GetComponent().color = new Color(1f, 1f, 1f, 1f);