private void Handle_NameQuery(WoWReader wr)
        {
            WoWGuid guid   = new WoWGuid(wr.ReadUInt64());
            string  name   = wr.ReadString();
            UInt16  unk    = wr.ReadByte();
            UInt32  Race   = wr.ReadUInt32();
            UInt32  Gender = wr.ReadUInt32();
            UInt32  Level  = wr.ReadUInt32();

            BoogieCore.Log(LogType.NeworkComms, "Got NameQuery Response - GUID: {4} Name: {0} - Race: {1} - Gender: {2} - Level: {3}", name, Race, Gender, Level, BitConverter.ToUInt64(guid.GetNewGuid(), 0));

            Object obj = BoogieCore.world.getObject(guid);

            if (obj != null)    // Update existing object
            {
                obj.Name   = name;
                obj.Race   = Race;
                obj.Gender = Gender;
                obj.Level  = Level;
                BoogieCore.world.updateObject(obj);
            }
            else                // Create new Object        -- FIXME: Add to new 'names only' list?
            {
                obj        = new Object();
                obj.GUID   = guid;
                obj.Name   = name;
                obj.Race   = Race;
                obj.Gender = Gender;
                obj.Level  = Level;
                BoogieCore.world.newObject(obj, true);
            }

            /* Process chat message if we looked them up now */
            for (int i = 0; i < ChatQueued.Count; i++)
            {
                ChatQueue message = (ChatQueue)ChatQueued[i];
                if (message.GUID.GetOldGuid() == guid.GetOldGuid())
                {
                    BoogieCore.Event(new Event(EventType.EVENT_CHAT, Time.GetTime(), message, name));
                    ChatQueued.Remove(message);
                }
            }

            // WoWChat uses this to retrive names on friends and ignore list.
            BoogieCore.Event(new Event(EventType.EVENT_NAMEQUERY_RESPONSE, Time.GetTime(), guid, name));
        }
        private void ParseCommands(ChatQueue queue, string username)
        {
            if ((ChatMsg)queue.Type == ChatMsg.CHAT_MSG_SAY)
            {
                if (queue.Message == "face")
                {
                    Object obj = BoogieCore.world.getObject(queue.GUID);
                    if (obj != null)
                    {
                        Object player = BoogieCore.world.getPlayerObject();
                        player.SetOrientation(player.CalculateAngle(obj.GetPositionX(), obj.GetPositionY()));
                        SendMoveHeartBeat();
                        string message = String.Format("Facing {0}", obj.Name);
                        SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, message);
                        return;
                    }
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, String.Format("Unable to find {0} in obj list", username));
                }

                if (queue.Message == "track")
                {
                    Object obj = BoogieCore.world.getObject(queue.GUID);
                    if (obj != null)
                    {
                        TrackObject(obj);
                        string message = String.Format("Tracking {0}", obj.Name);
                        SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, message);
                        return;
                    }
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, String.Format("Unable to find {0} in obj list", username));
                }
                if (queue.Message == "come")
                {
                    Object obj = BoogieCore.world.getObject(queue.GUID);
                    if (obj != null)
                    {
                        string message = String.Format("Approaching {0}", obj.Name);
                        SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, message);
                        TrackObject(obj);
                        //pather.Approach(obj, false, 20000);
                        StopTrack();

                        return;
                    }
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, String.Format("Unable to find {0} in obj list", username));
                }

                if (queue.Message == "t")
                {
                    StartTurn();
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, "Turning.");
                }
                if (queue.Message == "run")
                {
                    StartMoveForward();
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, "Running...");
                }
                if (queue.Message == "stop")
                {
                    StopTrack();
                    StopMoveForward();
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, "stopping...");
                }
            }
        }
        private void ParseCommands(ChatQueue queue, string username)
        {
            if ((ChatMsg)queue.Type == ChatMsg.CHAT_MSG_SAY)
            {
                if (queue.Message == "face")
                {
                    Object obj = BoogieCore.world.getObject(queue.GUID);
                    if (obj != null)
                    {
                            Object player = BoogieCore.world.getPlayerObject();
                            player.SetOrientation(player.CalculateAngle(obj.GetPositionX(), obj.GetPositionY()) );
                            SendMoveHeartBeat();
                            string message = String.Format("Facing {0}", obj.Name);
                            SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, message);
                            return;
                    }
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, String.Format("Unable to find {0} in obj list", username));
                }

                if (queue.Message == "track")
                {
                    Object obj = BoogieCore.world.getObject(queue.GUID);
                    if (obj != null)
                    {
                        TrackObject(obj);
                        string message = String.Format("Tracking {0}", obj.Name);
                        SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, message);
                        return;
                    }
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, String.Format("Unable to find {0} in obj list", username));
                }
                if (queue.Message == "come")
                {

                    Object obj = BoogieCore.world.getObject(queue.GUID);
                    if (obj != null)
                    {

                        string message = String.Format("Approaching {0}", obj.Name);
                        SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, message);
                        TrackObject(obj);
                        //pather.Approach(obj, false, 20000);
                        StopTrack();

                        return;
                    }
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, String.Format("Unable to find {0} in obj list", username));
                }

                if (queue.Message == "t")
                {
                    StartTurn();
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, "Turning.");
                }
                if (queue.Message == "run")
                {
                    StartMoveForward();
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, "Running...");

                }
                if (queue.Message == "stop")
                {
                    StopTrack();
                    StopMoveForward();
                    SendChatMsg(ChatMsg.CHAT_MSG_SAY, Languages.LANG_UNIVERSAL, "stopping...");
                }

            }
        }
        private void Handle_MessageChat(WoWReader wr)
        {
            string  channel = null;
            UInt64  guid = 0;
            WoWGuid fguid = null, fguid2 = null;


            byte   Type     = wr.ReadByte();
            UInt32 Language = wr.ReadUInt32();

            fguid = new WoWGuid(wr.ReadUInt64());
            wr.ReadUInt32(); // rank?

            if ((ChatMsg)Type == ChatMsg.CHAT_MSG_CHANNEL)
            {
                channel = wr.ReadString();
                //pvp_rank = wr.ReadUInt32();
            }

            //if (Type == 0 || Type == 1 || Type == 5 || Type == 0x53)
            //{
            fguid2 = new WoWGuid(wr.ReadUInt64());

            //}

            UInt32 Length  = wr.ReadUInt32();
            string Message = wr.ReadString();
            byte   afk     = wr.ReadByte();


            string username = null;


            ChatQueue que = new ChatQueue();

            que.GUID     = fguid;
            que.Type     = Type;
            que.Language = Language;
            if ((ChatMsg)Type == ChatMsg.CHAT_MSG_CHANNEL)
            {
                que.Channel = channel;
            }
            que.Length  = Length;
            que.Message = Message;
            que.AFK     = afk;

            if (fguid.GetOldGuid() == 0)
            {
                username = "******";
            }
            else
            {
                username = BoogieCore.world.getObjectName(fguid);
            }

            if (username == null)
            {
                ChatQueued.Add(que);
                QueryName(guid);
                return;
            }
            ParseCommands(que, username);

            BoogieCore.Event(new Event(EventType.EVENT_CHAT, Time.GetTime(), que, username));
        }
        private void Handle_MessageChat(WoWReader wr)
        {
            string channel = null;
            UInt64 guid = 0;
            WoWGuid fguid = null, fguid2 = null;

            byte Type = wr.ReadByte();
            UInt32 Language = wr.ReadUInt32();

            fguid = new WoWGuid(wr.ReadUInt64());
            wr.ReadUInt32(); // rank?

            if ((ChatMsg)Type == ChatMsg.CHAT_MSG_CHANNEL)
            {
                channel = wr.ReadString();
                //pvp_rank = wr.ReadUInt32();
            }

            //if (Type == 0 || Type == 1 || Type == 5 || Type == 0x53)
            //{
                fguid2 = new WoWGuid(wr.ReadUInt64());

            //}

            UInt32 Length = wr.ReadUInt32();
            string Message = wr.ReadString();
            byte afk = wr.ReadByte();

            string username = null;

            ChatQueue que = new ChatQueue();
            que.GUID = fguid;
            que.Type = Type;
            que.Language = Language;
            if ((ChatMsg)Type == ChatMsg.CHAT_MSG_CHANNEL)
                que.Channel = channel;
            que.Length = Length;
            que.Message = Message;
            que.AFK = afk;

            if (fguid.GetOldGuid() == 0)
            {
                username = "******";
            }
            else
            {
                username = BoogieCore.world.getObjectName(fguid);
            }

            if (username == null)
            {
                ChatQueued.Add(que);
                QueryName(guid);
                return;
            }
            ParseCommands(que, username);

            BoogieCore.Event(new Event(EventType.EVENT_CHAT, Time.GetTime(), que, username));
        }