public static bool CombatChatModule_OnChatMessage_Prefix(CombatChatModule __instance, MessageCenterMessage message, ActiveChatListView ____activeChatList, PassiveChatListView ____passiveChatList) { ChatMessage chatMessage = (ChatMessage)message; Mod.Log.Debug($"Chat message is: '{chatMessage.Message}'"); try { ____activeChatList.Add(chatMessage); ____activeChatList.ScrollToBottom(); ____activeChatList.Refresh(); } catch (Exception e) { Mod.Log.Error($"Failed to send a message:{e.Message}"); Mod.Log.Error($"{e.StackTrace}"); } return(false); }
private static void OnFloatie(MessageCenterMessage message) { FloatieMessage floatieMessage = (FloatieMessage)message; AbstractActor target = combat.FindActorByGUID(floatieMessage.affectedObjectGuid); if (target == null) { return; } if (floatieMessage.text == null) { return; } try { string senderColor; if (combat.HostilityMatrix.IsLocalPlayerEnemy(target.TeamId)) { senderColor = "#" + ColorUtility.ToHtmlStringRGBA(LazySingletonBehavior <UIManager> .Instance.UIColorRefs.redHalf); } else if (combat.HostilityMatrix.IsLocalPlayerNeutral(target.TeamId)) { senderColor = "#" + ColorUtility.ToHtmlStringRGBA(LazySingletonBehavior <UIManager> .Instance.UIColorRefs.blueHalf); } else { senderColor = "#" + ColorUtility.ToHtmlStringRGBA(LazySingletonBehavior <UIManager> .Instance.UIColorRefs.greenHalf); } string sender = (target.IsPilotable && target.GetPilot() != null) ? $"{target.GetPilot().Name}" : $"{target.DisplayName}"; string senderWithColor = $"<{senderColor}>{sender}</color>"; Mod.Log.Debug($"ChatMessage senderWithColor: '{senderWithColor}'"); string logMessage = floatieMessage.text.ToString(); switch (floatieMessage.nature) { case FloatieMessage.MessageNature.ArmorDamage: logMessage = $"{logMessage} armor damage"; break; case FloatieMessage.MessageNature.StructureDamage: logMessage = $"{logMessage} structure damage"; break; default: break; } ChatMessage chatMessage = new ChatMessage(senderWithColor, logMessage, false); Mod.Log.Debug($"Chat message is: '{chatMessage.Message}'"); try { int i = clog_count++; ChatListViewItem view = _views.GetOrCreateView(i); view.gameObject.transform.SetAsLastSibling(); view.ItemIndex = i; ChatListViewItem_SetData(view, chatMessage, (LocalizableText)lt_field_info.GetValue(view)); if (i > max_messages) { int p = i - max_messages; _views.Pool(p); } if (!CanvasUpdateRegistry.IsRebuildingLayout()) { _activeChatList.gameObject.GetComponentsInChildren <RectTransform>(false, layoutcomponents); foreach (RectTransform componentsInChild in layoutcomponents) { LayoutRebuilder.MarkLayoutForRebuild(componentsInChild); } layoutcomponents.Clear(); } _activeChatList.ScrollToBottom(); } catch (Exception e) { Mod.Log.Error($"Failed to send a message:{e.Message}"); Mod.Log.Error($"{e.StackTrace}"); } } catch (Exception e) { Mod.Log.Error($"Failed to send floatieMessage: {floatieMessage}"); Mod.Log.Error(e); } }