Exemplo n.º 1
0
        internal static NPCSpawnPoolTemplate GetOrCreateSpawnPoolTemplate(uint poolId)
        {
            NPCSpawnPoolTemplate templ;

            if (poolId == 0)
            {
                // does not belong to any Pool
                templ = new NPCSpawnPoolTemplate();
                SpawnPoolTemplates.Add(templ.PoolId, templ);
            }
            else if (!SpawnPoolTemplates.TryGetValue(poolId, out templ))
            {
                // pool does not exist yet
                var entry = SpawnMgr.GetSpawnPoolTemplateEntry(poolId);

                if (entry != null)
                {
                    // default pool
                    templ = new NPCSpawnPoolTemplate(entry);
                }
                else
                {
                    // pool does not exist
                    //ContentMgr.OnInvalidDBData("");
                    templ = new NPCSpawnPoolTemplate();
                }
                SpawnPoolTemplates.Add(templ.PoolId, templ);
            }
            return(templ);
        }
Exemplo n.º 2
0
        internal static NPCSpawnPoolTemplate GetOrCreateSpawnPoolTemplate(uint poolId)
        {
            NPCSpawnPoolTemplate spawnPoolTemplate;

            if (poolId == 0U)
            {
                spawnPoolTemplate = new NPCSpawnPoolTemplate();
                NPCMgr.SpawnPoolTemplates.Add(spawnPoolTemplate.PoolId, spawnPoolTemplate);
            }
            else if (!NPCMgr.SpawnPoolTemplates.TryGetValue(poolId, out spawnPoolTemplate))
            {
                SpawnPoolTemplateEntry poolTemplateEntry = SpawnMgr.GetSpawnPoolTemplateEntry(poolId);
                spawnPoolTemplate = poolTemplateEntry == null
                    ? new NPCSpawnPoolTemplate()
                    : new NPCSpawnPoolTemplate(poolTemplateEntry);
                NPCMgr.SpawnPoolTemplates.Add(spawnPoolTemplate.PoolId, spawnPoolTemplate);
            }

            return(spawnPoolTemplate);
        }
Exemplo n.º 3
0
 public static void LoadSpawns(bool force)
 {
     NPCMgr.Loading = true;
     try
     {
         NPCMgr.OnlyLoadSpawns(force);
         NPCMgr.LoadWaypoints(force);
         if (!ServerApp <WCell.RealmServer.RealmServer> .Instance.IsRunning)
         {
             return;
         }
         for (MapId mapId = MapId.Silaris; mapId < MapId.End; ++mapId)
         {
             Map map = WCell.RealmServer.Global.World.GetNonInstancedMap(mapId);
             if (map != null && map.NPCsSpawned)
             {
                 List <NPCSpawnPoolTemplate> poolTemplatesByMap = NPCMgr.GetSpawnPoolTemplatesByMap(mapId);
                 if (poolTemplatesByMap != null)
                 {
                     foreach (NPCSpawnPoolTemplate spawnPoolTemplate in poolTemplatesByMap)
                     {
                         if (spawnPoolTemplate.AutoSpawns)
                         {
                             NPCSpawnPoolTemplate p = spawnPoolTemplate;
                             map.ExecuteInContext((Action)(() => map.AddNPCSpawnPoolNow(p)));
                         }
                     }
                 }
             }
         }
     }
     finally
     {
         NPCMgr.Loading = false;
     }
 }