Exemple #1
0
        private void LogClientMessage(ChatMessage message)
        {
            Optional <RemotePlayer> remotePlayer = remotePlayerManager.Find(message.PlayerId);

            if (remotePlayer.IsPresent())
            {
                RemotePlayer remotePlayerInstance = remotePlayer.Get();
                ChatLogEntry chatLogEntry         = new ChatLogEntry(remotePlayerInstance.PlayerName, message.Text, remotePlayerInstance.PlayerSettings.PlayerColor);
                playerChat.WriteChatLogEntry(chatLogEntry);
                playerChat.ShowLog();
            }
        }
        private void LogClientMessage(ChatMessage message)
        {
            Optional <RemotePlayer> remotePlayer = remotePlayerManager.Find(message.PlayerId);

            if (!remotePlayer.IsPresent())
            {
                string playerTableFormatted = string.Join("\n", remotePlayerManager.GetAll().Select(ply => $"Name: '{ply.PlayerName}', Id: {ply.PlayerId}"));
                throw new Exception($"Tried to add chat message for remote player that could not be found with id '${message.PlayerId}' and message: '{message.Text}'.\nAll remote players right now:\n{playerTableFormatted}");
            }

            RemotePlayer remotePlayerInstance = remotePlayer.Get();

            playerChat.AddMessage(remotePlayerInstance.PlayerName, message.Text, remotePlayerInstance.PlayerSettings.PlayerColor);
            playerChat.ShowLog();
        }