public PlayerOnlineInfo GetAllInfo() { var ret = new PlayerOnlineInfo(); foreach (var player in _playerList) { ret.Player.Add(player.Value.GetSimplified(255)); } return(ret); }
public PlayerOnlineInfo GetOnlineInfo(int id) { var ret = new PlayerOnlineInfo(); foreach (var player in Main.player) { if (player.active) { var serverPlayer = player.GetServerPlayer(); ret.Player.Add(serverPlayer.GetSimplified(id)); } } return(ret); }
public void Handle(BinaryReader reader, int playerNumber) { // 服务器端 if (Main.netMode == 2) { var player = Main.player[playerNumber].GetServerPlayer(); var ret = new PlayerOnlineInfo(); foreach (var f in player.Friends) { var friend = ServerSideCharacter2.PlayerCollection.Get(f); if (friend == null) { continue; } ret.Player.Add(friend.GetSimplified(playerNumber)); } ret.Player.Add(player.GetSimplified(playerNumber)); var data = JsonConvert.SerializeObject(ret, Formatting.None); MessageSender.SendFriendsData(playerNumber, data); } }