Exemplo n.º 1
0
        void Spawn1Object(PoolObject obj)
        {
            switch (typeof(T).Name)
            {
            case "Creature":
                CreatureData data = Global.ObjectMgr.GetCreatureData(obj.guid);
                if (data != null)
                {
                    Global.ObjectMgr.AddCreatureToGrid(obj.guid, data);

                    // Spawn if necessary (loaded grids only)
                    Map map = Global.MapMgr.CreateBaseMap(data.mapid);
                    // We use spawn coords to spawn
                    if (!map.Instanceable() && map.IsGridLoaded(data.posX, data.posY))
                    {
                        Creature creature = new Creature();
                        if (!creature.LoadCreatureFromDB(obj.guid, map))
                        {
                            return;
                        }
                    }
                }
                break;

            case "GameObject":
                GameObjectData data_ = Global.ObjectMgr.GetGOData(obj.guid);
                if (data_ != null)
                {
                    Global.ObjectMgr.AddGameObjectToGrid(obj.guid, data_);
                    // Spawn if necessary (loaded grids only)
                    // this base map checked as non-instanced and then only existed
                    Map map = Global.MapMgr.CreateBaseMap(data_.mapid);
                    // We use current coords to unspawn, not spawn coords since creature can have changed grid
                    if (!map.Instanceable() && map.IsGridLoaded(data_.posX, data_.posY))
                    {
                        GameObject pGameobject = new GameObject();
                        if (!pGameobject.LoadGameObjectFromDB(obj.guid, map, false))
                        {
                            return;
                        }
                        else
                        {
                            if (pGameobject.isSpawnedByDefault())
                            {
                                map.AddToMap(pGameobject);
                            }
                        }
                    }
                }
                break;

            case "Pool":
                Global.PoolMgr.SpawnPool((uint)obj.guid);
                break;

            case "Quest":
                // Creatures
                var questMap = Global.ObjectMgr.GetCreatureQuestRelationMap();
                var qr       = Global.PoolMgr.mQuestCreatureRelation.LookupByKey(obj.guid);
                foreach (var creature in qr)
                {
                    Log.outDebug(LogFilter.Pool, "PoolGroup<Quest>: Adding quest {0} to creature {1}", obj.guid, creature);
                    questMap.Add(creature, (uint)obj.guid);
                }

                // Gameobjects
                questMap = Global.ObjectMgr.GetGOQuestRelationMap();
                qr       = Global.PoolMgr.mQuestGORelation.LookupByKey(obj.guid);
                foreach (var go in qr)
                {
                    Log.outDebug(LogFilter.Pool, "PoolGroup<Quest>: Adding quest {0} to GO {1}", obj.guid, go);
                    questMap.Add(go, (uint)obj.guid);
                }
                break;
            }
        }