Beispiel #1
0
        /// <summary>
        /// Generates the geo datafile.
        /// </summary>
        private static void GenerateGeography()
        {
            Console.WriteLine();
            Console.Write(@"Generated geography datafile... ");

            s_counter = 0;
            s_percentOld = 0;
            s_text = String.Empty;
            s_startTime = DateTime.Now;

            var allSystems = new List<SerializableSolarSystem>();
            var regions = new List<SerializableRegion>();

            // Regions
            foreach (MapRegion srcRegion in s_regions)
            {
                var region = new SerializableRegion
                                 {
                                     ID = srcRegion.ID,
                                     Name = srcRegion.Name
                                 };
                regions.Add(region);

                // Constellations
                var constellations = new List<SerializableConstellation>();
                foreach (MapConstellation srcConstellation in s_constellations.Where(x => x.RegionID == srcRegion.ID))
                {
                    var constellation = new SerializableConstellation
                                            {
                                                ID = srcConstellation.ID,
                                                Name = srcConstellation.Name
                                            };
                    constellations.Add(constellation);

                    // Systems
                    const double baseDistance = 1.0E14;
                    var systems = new List<SerializableSolarSystem>();
                    foreach (
                        MapSolarSystem srcSystem in s_solarSystems.Where(x => x.ConstellationID == srcConstellation.ID))
                    {
                        var system = new SerializableSolarSystem
                                         {
                                             ID = srcSystem.ID,
                                             Name = srcSystem.Name,
                                             X = (int) (srcSystem.X/baseDistance),
                                             Y = (int) (srcSystem.Y/baseDistance),
                                             Z = (int) (srcSystem.Z/baseDistance),
                                             SecurityLevel = srcSystem.SecurityLevel
                                         };
                        systems.Add(system);

                        // Stations
                        var stations = new List<SerializableStation>();
                        foreach (StaStation srcStation in s_stations.Where(x => x.SolarSystemID == srcSystem.ID))
                        {
                            UpdatePercentDone(s_geoGen);

                            // Agents
                            var stationAgents = new List<SerializableAgent>();
                            foreach (AgtAgents srcAgent in s_agents.Where(x => x.LocationID == srcStation.ID))
                            {
                                var agent = new SerializableAgent
                                                {
                                                    ID = srcAgent.ID,
                                                    Level = srcAgent.Level,
                                                    Quality = srcAgent.Quality,
                                                    Name = s_names.FirstOrDefault(x => x.ID == srcAgent.ID).Name
                                                };
                                stationAgents.Add(agent);
                            }

                            var station = new SerializableStation
                                              {
                                                  ID = srcStation.ID,
                                                  Name = srcStation.Name,
                                                  CorporationID = srcStation.CorporationID,
                                                  CorporationName = s_names.FirstOrDefault(x => x.ID == srcStation.CorporationID).Name,
                                                  ReprocessingEfficiency = srcStation.ReprocessingEfficiency,
                                                  ReprocessingStationsTake = srcStation.ReprocessingStationsTake,
                                                  Agents = stationAgents.ToArray()
                                              };
                            stations.Add(station);
                        }
                        system.Stations = stations.OrderBy(x => x.Name).ToArray();
                    }
                    constellation.Systems = systems.OrderBy(x => x.Name).ToArray();
                }
                region.Constellations = constellations.OrderBy(x => x.Name).ToArray();
            }

            // Jumps
            var jumps = new List<SerializableJump>();
            foreach (MapSolarSystemJump srcJump in s_jumps)
            {
                UpdatePercentDone(s_geoGenTotal);

                // In CCP tables, every jump is included twice, we only need one.
                if (srcJump.A < srcJump.B)
                    jumps.Add(new SerializableJump {FirstSystemID = srcJump.A, SecondSystemID = srcJump.B});
            }

            s_endTime = DateTime.Now;
            Console.WriteLine(String.Format(" in {0}", s_endTime.Subtract(s_startTime)).TrimEnd('0'));

            // Serialize
            var datafile = new GeoDatafile();
            datafile.Regions = regions.OrderBy(x => x.Name).ToArray();
            datafile.Jumps = jumps.ToArray();
            Util.SerializeXML(datafile, DatafileConstants.GeographyDatafile);
        }
Beispiel #2
0
        /// <summary>
        /// Exports the systems.
        /// </summary>
        /// <param name="srcConstellation">The source constellation.</param>
        /// <returns></returns>
        private static IEnumerable<SerializableSolarSystem> ExportSystems(IHasID srcConstellation)
            => Database.MapSolarSystemsTable
                .Where(x => x.ConstellationID == srcConstellation.ID)
                .Select(
                    srcSystem =>
                    {
                        SerializableSolarSystem system = new SerializableSolarSystem
                        {
                            ID = srcSystem.ID,
                            Name = srcSystem.Name,
                            X = (int)(srcSystem.X / BaseDistance),
                            Y = (int)(srcSystem.Y / BaseDistance),
                            Z = (int)(srcSystem.Z / BaseDistance),
                            SecurityLevel = srcSystem.SecurityLevel
                        };

                        // Stations
                        system.Stations.AddRange(ExportStations(srcSystem).OrderBy(x => x.Name));
                        return system;
                    });