/// <summary> /// Initialize static geography. /// </summary> internal static void Load() { GeoDatafile datafile = LoadGeoData(); LoadFactions(); CompleteInitialization(datafile); GlobalDatafileCollection.OnDatafileLoaded(); }
/// <summary> /// Generates the geography datafile. /// </summary> internal static void GenerateDatafile() { Stopwatch stopwatch = Stopwatch.StartNew(); Util.ResetCounters(); Console.WriteLine(); Console.Write(@"Generating geography datafile... "); // Get the planets out of InvItems so we don't have to iterate all of them each time Planets = Database.InvItemsTable.Where(x => Database.MapSolarSystemsTable.HasValue(x.LocationID) && // item location is a solar system Database.InvTypesTable.HasValue(x.TypeID) && // item has a valid type (CCP...) Database.InvTypesTable[x.TypeID].GroupID == 7) // type group is planet .GroupBy(x => x.LocationID) .ToDictionary(x => x.Key, x => x); // Regions IEnumerable <SerializableRegion> regions = Database.MapRegionsTable.Select( srcRegion => { Util.UpdatePercentDone(Database.GeographyTotalCount); SerializableRegion region = new SerializableRegion { ID = srcRegion.ID, Name = srcRegion.Name }; // Constellations region.Constellations.AddRange(ExportConstellations(srcRegion).OrderBy(x => x.Name)); return(region); }); // Jumps IEnumerable <SerializableJump> jumps = Database.MapSolarSystemJumpsTable.Where(srcJump => srcJump.A < srcJump.B) .Select(srcJump => new SerializableJump { FirstSystemID = srcJump.A, SecondSystemID = srcJump.B }); // Serialize GeoDatafile datafile = new GeoDatafile(); datafile.Regions.AddRange(regions.OrderBy(x => x.Name)); datafile.Jumps.AddRange(jumps); Util.DisplayEndTime(stopwatch); Util.SerializeXml(datafile, DatafileConstants.GeographyDatafile); }
/// <summary> /// Generates the geography datafile. /// </summary> internal static void GenerateDatafile() { Stopwatch stopwatch = Stopwatch.StartNew(); Util.ResetCounters(); Console.WriteLine(); Console.Write(@"Generating geography datafile... "); // Regions IEnumerable <SerializableRegion> regions = Database.MapRegionsTable.Select( srcRegion => { Util.UpdatePercentDone(Database.GeographyTotalCount); SerializableRegion region = new SerializableRegion { ID = srcRegion.ID, Name = srcRegion.Name }; // Constellations region.Constellations.AddRange(ExportConstellations(srcRegion).OrderBy(x => x.Name)); return(region); }); // Jumps IEnumerable <SerializableJump> jumps = Database.MapSolarSystemJumpsTable.Where(srcJump => srcJump.A < srcJump.B) .Select(srcJump => new SerializableJump { FirstSystemID = srcJump.A, SecondSystemID = srcJump.B }); // Serialize GeoDatafile datafile = new GeoDatafile(); datafile.Regions.AddRange(regions.OrderBy(x => x.Name)); datafile.Jumps.AddRange(jumps); Util.DisplayEndTime(stopwatch); Util.SerializeXml(datafile, DatafileConstants.GeographyDatafile); }
/// <summary> /// Completes the initialization. /// </summary> /// <param name="datafile">The datafile.</param> private static void CompleteInitialization(GeoDatafile datafile) { // Connects the systems foreach (SerializableJump srcJump in datafile.Jumps) { SolarSystem a = GetSolarSystemByID(srcJump.FirstSystemID); SolarSystem b = GetSolarSystemByID(srcJump.SecondSystemID); if (a == null || b == null) { continue; } a.AddNeighbor(b); b.AddNeighbor(a); } foreach (SolarSystem system in s_solarSystemsByID.Values) { system.TrimNeighbors(); } }
/// <summary> /// Initialize static geography. /// </summary> internal static void Load() { GeoDatafile datafile = Util.DeserializeDatafile <GeoDatafile>(DatafileConstants.GeographyDatafile, Util.LoadXslt(Properties.Resources.DatafilesXSLT)); // Generate the nodes foreach (SerializableRegion srcRegion in datafile.Regions) { Region region = new Region(srcRegion); s_regionsByID[srcRegion.ID] = region; // Store the children into their dictionaries foreach (Constellation constellation in region) { s_constellationsByID[constellation.ID] = constellation; foreach (SolarSystem solarSystem in constellation) { s_solarSystemsByID[solarSystem.ID] = solarSystem; foreach (Station station in solarSystem) { s_stationsByID[station.ID] = station; s_corporationsByID[station.CorporationID] = new NPCCorporation(station); foreach (Agent agent in station) { s_agentsByID[agent.ID] = agent; } } } } } CompleteInitialization(datafile); GlobalDatafileCollection.OnDatafileLoaded(); }