Exemple #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="src"></param>
        internal Region(SerializableRegion src)
            : base(src.Constellations.Length)
        {
            m_id   = src.ID;
            m_name = src.Name;

            foreach (var srcConstellation in src.Constellations)
            {
                m_items.Add(new Constellation(this, srcConstellation));
            }
        }
Exemple #2
0
        /// <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);
        }
Exemple #3
0
        /// <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);
        }