Exemplo n.º 1
0
        public static void Handle(Player player, byte[] buffer)
        {
            try
            {
                fixed(byte *p = buffer)
                {
                    var packet = *(MsgWalk *)p;

                    BufferPool.RecycleBuffer(buffer);

                    if (player.UniqueId == packet.UniqueId)
                    {
                        player.CurrentTarget = null;
                        player.RemoveSpawnProtection();
                        player.Direction = (Direction)((byte)packet.Direction % 8);

                        player.Location.X += (ushort)Constants.DeltaX[(sbyte)player.Direction];
                        player.Location.Y += (ushort)Constants.DeltaY[(sbyte)player.Direction];
                        player.Emote       = Emote.Stand;
                        ScreenSystem.Send(player, packet, true, true, packet.Size);
                        ScreenSystem.Update(player);
                        if (TeamSystem.Teams.ContainsKey(player.UniqueId))
                        {
                            TeamSystem.Teams[player.UniqueId].UpdateLeaderPosition(player);
                        }
                    }
                    else if (packet.UniqueId == player.Pet?.UniqueId)
                    {
                        player.Pet.Direction = (Direction)((byte)packet.Direction % 8);

                        player.Pet.Location.X += (ushort)Constants.DeltaX[(sbyte)player.Direction];
                        player.Pet.Location.Y += (ushort)Constants.DeltaY[(sbyte)player.Direction];
                        ScreenSystem.Send(player.Pet, packet, false, true, packet.Size);
                        ScreenSystem.Update(player.Pet);
                    }
                }
            }
            catch (Exception e)
            {
                Output.WriteLine(e);
            }
        }