public void OnNewFactionMessage(long factionId1, long factionId2, long senderId, bool showNotification) { var localFactionId = MySession.Static.Factions.TryGetPlayerFaction(MySession.LocalPlayerId); if (localFactionId == null) { Debug.Fail("OnNewFactionMessage should not be triggered if local player is not a member of a faction, or if this is DedicatedServer"); return; } long otherFactionId = factionId1 == localFactionId.FactionId ? factionId2 : factionId1; var handler = FactionMessageReceived; if (handler != null) { handler(otherFactionId); } else if (senderId != MySession.LocalPlayerId && showNotification) { var faction = MySession.Static.Factions.TryGetFactionById(otherFactionId); if (faction != null) { var chatHistory = MyChatSystem.GetFactionChatHistory(MySession.LocalPlayerId, faction.FactionId); if (chatHistory != null) { chatHistory.UnreadMessageCount++; } m_newFactionMessageNotification.SetTextFormatArguments(faction.Name); ShowNewMessageHudNotification(m_newFactionMessageNotification); } } }
public void OnNewPlayerMessage(long playerId, long senderId) { var handler = PlayerMessageReceived; if (handler != null) { handler(playerId); } else if (senderId != MySession.LocalPlayerId) { var identity = MySession.Static.Players.TryGetIdentity(senderId); if (identity != null) { MyPlayerChatHistory chatHistory = MyChatSystem.GetPlayerChatHistory(MySession.LocalPlayerId, senderId); if (chatHistory != null) { chatHistory.UnreadMessageCount++; } m_newPlayerMessageNotification.SetTextFormatArguments(identity.DisplayName); ShowNewMessageHudNotification(m_newPlayerMessageNotification); } } }