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); }
public static string ToClientJson(this ChatlineObject chat) { var clientsideChat = new { chatline = chat.ChatFragments, timestamp = TimeKeeper.GetUnixTime() }; return(LowercaseContractResolver.SerializeObject(clientsideChat)); }
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)); }
/// <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); }
public void AddUserChat(ChatlineObject chatline, string userInput) { AddChat(chatline); LastUserInputs.Add(userInput); }
public void AddChat(ChatlineObject chatline) { Chats.Add(chatline); }
public PlayerChatAction(ChatMetaData metaData, ChatlineObject chatline) { MetaData = metaData; Chatline = chatline; }
public static List <OutboundChatMessage> BuildReplyAllChatList(this ChatMetaData meta, ChatlineObject chatLine, int?playerIDToIgnore) { return(BuildReplyAllChatList(meta.Area, meta.Player.Id, chatLine)); }
public static List <OutboundChatMessage> ReplyResponse(this ChatMetaData meta, ChatlineObject chatLine) { return(new List <OutboundChatMessage>() { new OutboundChatMessage(meta.Player, chatLine) }); }
public OutboundChatMessage(Player destination, ChatlineObject chat) { DestinationPlayer = destination; ChatMessage = chat; }
public OutboundChatMessage(Player destination, ChatlineObject chat, Dictionary <string, string> meta) : this(destination, chat) { Metadata = meta; }