private void HandleMapCheck(PacketReceivedEventArgs args)
{
var player = this.GetPlayer(args.Connection.RemoteUniqueIdentifier);
var response = args.Message.ReadBoolean();
if (response == false)
{
Packet packet = new Packet(PacketType.MapDataPacket);
packet.Message.Write(player.Map.GetMapData());
player.Connection.SendMessage(packet.Message, NetDeliveryMethod.ReliableOrdered, (int)ChannelTypes.WORLD);
return;
}
// The player is now in the map.
// Set their inMap variable to true.
// This is to make sure they're able to actually see the map before any map updates occur.
player.InMap = true;
player.SendPlayerData();
// Send all of the players...
foreach (var mapPlayer in player.Map.GetPlayers())
{
if (mapPlayer == player) continue;
Packet packet = new Packet(PacketType.PlayerDataPacket);
packet.Message.Write(mapPlayer.GetPlayerData());
player.Connection.SendMessage(packet.Message, NetDeliveryMethod.ReliableOrdered, (int)ChannelTypes.WORLD);
}
// Send all of the items currently spawned in the map.
foreach (var mapItem in player.Map.GetMapItems())
{
Packet packet = new Packet(PacketType.SpawnMapItemPacket);
packet.Message.Write(mapItem.Item.Name);
packet.Message.Write(mapItem.Item.TextureNumber);
packet.Message.Write(mapItem.Position);
packet.Message.Write(mapItem.SpawnDuration);
player.Connection.SendMessage(packet.Message, NetDeliveryMethod.ReliableOrdered, (int)ChannelTypes.WORLD);
}
}