Пример #1
0
 /// <summary>
 /// Send Initial Player Friends List to Client
 /// </summary>
 /// <param name="Player">GamePlayer to send the list to.</param>
 private void SendPlayerFriendsList(GamePlayer Player)
 {
     Player.Out.SendAddFriends(this[Player].Where(name => {
         var player = PlayersFriendsListsCache.FirstOrDefault(kv => kv.Key != null && kv.Key.Name == name);
         return(player.Key != null && !player.Key.IsAnonymous);
     }).ToArray());
 }
Пример #2
0
        /// <summary>
        /// Send Players Friends Social Windows
        /// </summary>
        /// <param name="Player">GamePlayer to Send Friends social window to</param>
        public void SendPlayerFriendsSocial(GamePlayer Player)
        {
            if (Player == null)
            {
                throw new ArgumentNullException("Player");
            }

            // "TF" - clear friend list in social
            Player.Out.SendMessage("TF", eChatType.CT_SocialInterface, eChatLoc.CL_SystemWindow);

            var offlineFriends = this[Player].ToList();
            var index          = 0;

            foreach (var friend in this[Player].Select(name => PlayersFriendsListsCache.FirstOrDefault(kv => kv.Key.Name == name))
                     .Where(kv => kv.Key != null && !kv.Key.IsAnonymous).Select(kv => kv.Key))
            {
                offlineFriends.Remove(friend.Name);
                Player.Out.SendMessage(
                    string.Format(
                        "F,{0},{1},{2},{3},\"{4}\"",
                        index++,
                        friend.Name,
                        friend.Level,
                        friend.CharacterClass.ID,
                        friend.CurrentZone == null ? string.Empty : friend.CurrentZone.Description),
                    eChatType.CT_SocialInterface, eChatLoc.CL_SystemWindow);
            }

            // Query Offline Characters
            FriendStatus[] offline;

            if (PlayersFriendsStatusCache.TryGetValue(Player, out offline))
            {
                foreach (var friend in offline.Where(frd => offlineFriends.Contains(frd.Name)))
                {
                    Player.Out.SendMessage(
                        string.Format(
                            "F,{0},{1},{2},{3},\"{4}\"",
                            index++,
                            friend.Name,
                            friend.Level,
                            friend.ClassID,
                            friend.LastPlayed),
                        eChatType.CT_SocialInterface, eChatLoc.CL_SystemWindow);
                }
            }
        }