Example #1
0
        public List <OutboundChatMessage> ParseChatline(ChatMetaData meta)
        {
            if (meta.Arguments == null || meta.Arguments.Trim().Length == 0)
            {
                return(new List <OutboundChatMessage>()
                {
                    new OutboundChatMessage(meta.Player, new ChatlineObject("Invalid shout command.", ChatlineColor.White))
                });
            }

            var actionText = meta.Player.Username + " " + ChatText.Shout.ToString() + ": ";

            var message = new ChatlineObject(new List <ChatlineFragment>()
            {
                new ChatlineFragment(actionText, ChatlineColor.Lime),
                new ChatlineFragment(meta.Arguments, ChatlineColor.White)
            });

            NetworkMessageContainer msg = new NetworkMessageContainer();

            msg.MessageData = new MessageRedisShout(meta.Player.Id, message.ToClientJson());
            msg.MessageType = MessageTypes.Redis_Shout;

            _redisServer.PublishObject(
                MessageTypes.Redis_Shout,
                msg
                );

            return(null);
        }
Example #2
0
        public static string ToClientJson(this ChatlineObject chat)
        {
            var clientsideChat = new
            {
                chatline  = chat.ChatFragments,
                timestamp = TimeKeeper.GetUnixTime()
            };

            return(LowercaseContractResolver.SerializeObject(clientsideChat));
        }
Example #3
0
        public List <OutboundChatMessage> ParseChatline(ChatMetaData meta)
        {
            var fragments = new List <ChatlineFragment>()
            {
                new ChatlineFragment(meta.Player.Username + " radios: ", ChatlineColor.Pink),
                new ChatlineFragment(meta.Arguments, ChatlineColor.White)
            };

            var chatline = new ChatlineObject(fragments);

            return(meta.BuildReplyAllChatList(chatline, null));
        }
Example #4
0
        /// <summary>
        /// Builds a list of OutboundChatMessage objects. Leave playerIDToIgnore null if the message should go to all players.
        /// </summary>
        /// <param name="area"></param>
        /// <param name="playerIDToIgnore"></param>
        /// <param name="chatLine"></param>
        /// <returns></returns>
        public static List <OutboundChatMessage> BuildReplyAllChatList(
            this IArea area,
            int?playerIDToIgnore,
            ChatlineObject chatLine)
        {
            var replies = new List <OutboundChatMessage>();

            replies.AddRange(
                area.GetOnlinePlayers()
                .Select(kvp => kvp.Value)
                .Where(p => p.Id != playerIDToIgnore && p.PlayerType == PlayerTypes.Human)
                .Select(p => new OutboundChatMessage(p, chatLine))
                );

            return(replies);
        }
Example #5
0
 public void AddUserChat(ChatlineObject chatline, string userInput)
 {
     AddChat(chatline);
     LastUserInputs.Add(userInput);
 }
Example #6
0
 public void AddChat(ChatlineObject chatline)
 {
     Chats.Add(chatline);
 }
Example #7
0
 public PlayerChatAction(ChatMetaData metaData, ChatlineObject chatline)
 {
     MetaData = metaData;
     Chatline = chatline;
 }
Example #8
0
 public static List <OutboundChatMessage> BuildReplyAllChatList(this ChatMetaData meta, ChatlineObject chatLine, int?playerIDToIgnore)
 {
     return(BuildReplyAllChatList(meta.Area, meta.Player.Id, chatLine));
 }
Example #9
0
 public static List <OutboundChatMessage> ReplyResponse(this ChatMetaData meta, ChatlineObject chatLine)
 {
     return(new List <OutboundChatMessage>()
     {
         new OutboundChatMessage(meta.Player, chatLine)
     });
 }
Example #10
0
 public OutboundChatMessage(Player destination, ChatlineObject chat)
 {
     DestinationPlayer = destination;
     ChatMessage       = chat;
 }
Example #11
0
 public OutboundChatMessage(Player destination, ChatlineObject chat, Dictionary <string, string> meta)
     : this(destination, chat)
 {
     Metadata = meta;
 }