public void CreatureQuery(GameGuid guid, UInt32 entry)
 {
     PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_CREATURE_QUERY);
     packet.Write(entry);
     packet.Write(guid.GetOldGuid());
     Send(packet);
 }
 public void DestroyObject(PacketIn packet)
 {
     //Log.WriteLine(netLogic.Shared.LogType.Network, "SMSG_DESTROY_OBJECT {0}", packet.PacketId.RawId);
     GameGuid guid = new GameGuid(packet.ReadUInt64());
     //Destroy(GameObject.Find(guid.ToString()));
     GetInstance().ObjMgr().Remove(guid);
 }
示例#3
0
 public void Create(GameGuid _guid)
 {
     GUID = _guid;
     SetNameToObj(_guid.GetOldGuid().ToString());
     SetUInt64Value((ushort)UpdateFields.OBJECT_FIELD_GUID, _guid.GetOldGuid());
     SetUInt32Value((ushort)UpdateFields.OBJECT_FIELD_TYPE, (UInt32)_type);
 }
示例#4
0
        public void Remove(GameGuid _guid)
        {
            foreach (KeyValuePair<GameGuid, Object> entry in ObjectMap)
            {
                if (entry.Key.GetOldGuid() == _guid.GetOldGuid())
                {
                    ObjectMap.Remove(entry.Key);
                    Destroy(GameObject.Find(entry.Value.transform.name));
                }

            }
        }
示例#5
0
        public Object GetObj(GameGuid _guid)
        {
            foreach (KeyValuePair<GameGuid, Object> o in ObjectMap)
            {
                if (o.Key.GetOldGuid() == _guid.GetOldGuid())
                {
                    switch (o.Value.Get_TypeId())
                    {
                        case OBJECT_TYPE_ID.TYPEID_OBJECT:
                        //    Log.WriteLine(netLogic.Shared.LogType.Normal, "UPDATETYPE_CREATE_OBJECT Unknown updatetype {0}", objectTypeId);
                            break;

                        case OBJECT_TYPE_ID.TYPEID_ITEM:
                            return (Item)o.Value;

                        case OBJECT_TYPE_ID.TYPEID_CONTAINER:
                            return (Bag)o.Value;

                        case OBJECT_TYPE_ID.TYPEID_UNIT:
                            return (Unit)o.Value;

                        case OBJECT_TYPE_ID.TYPEID_PLAYER:
                            return (Player)o.Value;

                        case OBJECT_TYPE_ID.TYPEID_GAMEOBJECT:
                            return (GO)o.Value;

                        case OBJECT_TYPE_ID.TYPEID_DYNAMICOBJECT:
                            return (DynamicObject)o.Value;

                        case OBJECT_TYPE_ID.TYPEID_CORPSE:
                            return (Corpse)o.Value;

                        default:
                            return new Object();

                    }
                }
            }
            return null;
        }
示例#6
0
        public void HandleChat(PacketIn packet)
        {
            try
            {

                string channel = null;
                UInt64 guid = 0;
                GameGuid fguid = null, fguid2 = null;
                string username = null;

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

                guid = packet.ReadUInt64();
                fguid = new GameGuid(guid);
                packet.ReadInt32();

                if ((ChatMsg)Type == ChatMsg.CHAT_MSG_CHANNEL)
                {
                    channel = packet.ReadString();
                }

                if (Type == 47)
                    return;
                fguid2 = new GameGuid(packet.ReadUInt64());

                UInt32 Length = packet.ReadUInt32();
                string Message = Encoding.Default.GetString(packet.ReadBytes((int)Length));

                //Message = Regex.Replace(Message, @"\|H[a-zA-z0-9:].|h", ""); // Why do i should need spells and quest linked? ;>
                Message = Regex.Replace(Message, @"\|[rc]{1}[a-zA-z0-9]{0,8}", ""); // Colorfull chat message also isn't the most important thing.

                byte afk = 0;

                if (fguid.GetOldGuid() == 0)
                {
                    username = "******";
                }
                else
                {
                    //if (netLogicCore.ObjectMgr.objectExists(fguid))
                        //username = netLogicCore.ObjectMgr.GetObject(fguid).Name;
                }

                if (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;
                    ChatQueued.Add(que);
                    QueryName(guid);
                    return;
                }

                object[] param = new object[] { (ChatMsg)Type, channel, username, Message };
                netInstance.Event(new Event(EventType.EVENT_CHAT_MSG, "0", param));
                //Log.WriteLine(LogType.Chat, "[{1}] {0}", Message, username);
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogType.Error, "Exception Occured");
                Log.WriteLine(LogType.Error, "Message: {0}", ex.Message);
                Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace);
            }
        }
        private void ParseValues(BinaryReader gr)
        {
            byte mask = gr.ReadByte();

            GameGuid guid = new GameGuid(mask, gr.ReadBytes(GameGuid.BitCount8(mask)));

            var wowobj = GetInstance().ObjMgr().GetObj(guid);
            if(wowobj)
                wowobj.ReadUpd(gr);
        }
        private void ParseMovement(BinaryReader gr)
        {
            byte mask = gr.ReadByte();

            GameGuid guid = new GameGuid(mask, gr.ReadBytes(GameGuid.BitCount8(mask)));

            GetInstance().ObjMgr().GetObj(guid).ReadMov(gr);
        }
        private void ParseCreateObjects(BinaryReader gr)
        {
            byte mask = gr.ReadByte();

            GameGuid guid = new GameGuid(mask, gr.ReadBytes(GameGuid.BitCount8(mask)));

            OBJECT_TYPE_ID objectTypeId = (OBJECT_TYPE_ID)gr.ReadByte();
                switch (objectTypeId)
                {
                    case OBJECT_TYPE_ID.TYPEID_OBJECT:
                        Log.WriteLine(netLogic.Shared.LogType.Normal, "UPDATETYPE_CREATE_OBJECT Unknown updatetype {0}", objectTypeId);
                        break;

                    case OBJECT_TYPE_ID.TYPEID_ITEM:

                        GameObject _goui = GameObject.CreatePrimitive(PrimitiveType.Capsule);
                        _goui.AddComponent<Item>();

                        DontDestroyOnLoad(_goui);
                        Item item = _goui.GetComponent<Item>();
                        item.Create(guid);
                        GetInstance().ObjMgr().Add(item);
                        break;

                    case OBJECT_TYPE_ID.TYPEID_CONTAINER:

                        GameObject _goub = GameObject.CreatePrimitive(PrimitiveType.Quad);
                        _goub.AddComponent<Bag>();
                        DontDestroyOnLoad(_goub);
                        Bag b = _goub.GetComponent<Bag>();
                        b.Create(guid);
                        GetInstance().ObjMgr().Add(b);

                        break;

                    case OBJECT_TYPE_ID.TYPEID_UNIT:
                        GameObject _unit = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                        _unit.AddComponent<Unit>();
                        DontDestroyOnLoad(_unit);
                        Unit u = _unit.GetComponent<Unit>();
                      //  u = new Unit();
                        u.Create(guid);
                        GetInstance().ObjMgr().Add(u);

                        break;

                    case OBJECT_TYPE_ID.TYPEID_PLAYER:
                        if (guid.GetOldGuid() == _myGUID.GetOldGuid()) // objmgr.Add() would cause quite some trouble if we added ourself again
                        {
                            GameObject _goup = Instantiate(Resources.Load("Player") as GameObject);
                            _goup.AddComponent<MyCharacter>();

                            MyCharacter ch = _goup.GetComponent<MyCharacter>();
                            ch.Create(guid);

                            GetInstance().ObjMgr().Add(ch);
                            DontDestroyOnLoad(ch);

                            LevelManager.Load("DEMO_WORLD"); // Оптимальная загрузка уровня после прогрузки всех GO

                            break;
                        }
                        else
                        {
                            GameObject _goup = GameObject.CreatePrimitive(PrimitiveType.Cube);

                            _goup.AddComponent<Player>();
                            DontDestroyOnLoad(_goup);

                            Player p = _goup.GetComponent<Player>();
                            p.Create(guid);
                            GetInstance().ObjMgr().Add(p);
                            QueryName(guid);
                            break;
                        }

                    case OBJECT_TYPE_ID.TYPEID_GAMEOBJECT:
                        GameObject _goug = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                        _goug.AddComponent<GO>();
                        DontDestroyOnLoad(_goug);
                        GO go = _goug.GetComponent<GO>();
                        go.Create(guid);
                        GetInstance().ObjMgr().Add(go);
                        break;

                    case OBJECT_TYPE_ID.TYPEID_DYNAMICOBJECT:
                        DynamicObject d = new DynamicObject();
                        d.Create(guid);
                        GetInstance().ObjMgr().Add(d);
                        DontDestroyOnLoad(d);
                        break;
                    case OBJECT_TYPE_ID.TYPEID_CORPSE:
                        Corpse c = new Corpse();
                        c.Create(guid);
                        GetInstance().ObjMgr().Add(c);
                        DontDestroyOnLoad(c);
                        break;

                    default:
                        Log.WriteLine(netLogic.Shared.LogType.Normal, "Unknown updatetype {0}", objectTypeId);
                        break;
                }

                Object _o = GetInstance().ObjMgr().GetObj(guid);

                _o.ReadMov(gr);
                if (_o)
                {
                    _o.ReadUpd(gr);
                    if (_o.IsUnit())
                    {
                        CreatureQuery(_o.GetGUID(), _o.GetEntry());
                    }
                    else if (_o.IsGameObject())
                    {
                        ObjectQuery(_o.GetGUID(), _o.GetEntry());
                    }

                }
                else
                {
                    Log.WriteLine(netLogic.Shared.LogType.Debug, "Unknown updatetype {0}", objectTypeId);
                }
        }
示例#10
0
 public void QueryName(GameGuid guid)
 {
     PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_NAME_QUERY);
     packet.Write(guid.GetOldGuid());
     Send(packet);
 }
示例#11
0
 public void ObjectQuery(GameGuid guid, UInt32 entry)
 {
     PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_GAMEOBJECT_QUERY);
     packet.Write(entry);
     packet.Write(guid.GetOldGuid());
     Send(packet);
 }
示例#12
0
        public void Handle_NameQuery(PacketIn packet)
        {
            byte mask = packet.ReadByte();
            GameGuid guid = new GameGuid(mask, packet.ReadBytes(GameGuid.BitCount8(mask)));

            packet.ReadByte();
            string name = packet.ReadString();
            packet.ReadByte();

            //Races Race = (Races)packet.ReadByte();
            //Gender Gender = (Gender)packet.ReadByte();
            //Classes Class = (Classes)packet.ReadByte();

              /*  if (netLogicCore.ObjectMgr.GetObject(guid) != null)    // Update existing Object
            {
                obj = netLogicCore.ObjectMgr.GetObject(guid);
                obj.Name = name;

               // netLogicCore.ObjectMgr.updateObject(obj);
            }*/
             /*    else                // Create new Object        -- FIXME: Add to new 'names only' list?
             {
                 obj = new MMOObject(guid);
                 obj.Name = name;
                 netLogicCore.ObjectMgr.newObject(obj);

                //  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 == guid)
                     {
                         Log.WriteLine(netLogic.Shared.LogType.Chat, "[{1}] {0}", message.Message, name);
                         ChatQueued.Remove(message);
                     }
                 }

             }*/
        }
示例#13
0
 public void SetMyPlayerEnum(PlayerEnum _ch)
 {
     _myPlayerEnum = _ch; _chSelected = true; _myGUID = _ch.GUID;
 }