Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SolarSystem"/> class.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="src">The source.</param>
        /// <exception cref="System.ArgumentNullException">owner or src</exception>
        public SolarSystem(Constellation owner, SerializableSolarSystem src)
            : base(src?.Stations?.Count ?? 0)
        {
            owner.ThrowIfNull(nameof(owner));

            src.ThrowIfNull(nameof(src));

            ID            = src.ID;
            Constellation = owner;
            Name          = src.Name;
            SecurityLevel = src.SecurityLevel;
            FullLocation  = $"{owner.FullLocation} > {src.Name}";
            m_jumps       = new FastList <SolarSystem>(0);

            m_x = src.X;
            m_y = src.Y;
            m_z = src.Z;

            if (src.Stations == null)
            {
                return;
            }

            foreach (SerializableStation srcStation in src.Stations)
            {
                Items.Add(new Station(this, srcStation));
            }
        }
Esempio n. 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);
        });
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SolarSystem"/> class.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="src">The source.</param>
        /// <exception cref="System.ArgumentNullException">owner or src</exception>
        public SolarSystem(Constellation owner, SerializableSolarSystem src)
            : base(src?.Stations?.Count ?? 0)
        {
            owner.ThrowIfNull(nameof(owner));
            src.ThrowIfNull(nameof(src));

            ID            = src.ID;
            Constellation = owner;
            Name          = src.Name;
            SecurityLevel = src.SecurityLevel;
            FullLocation  = $"{owner.FullLocation} > {src.Name}";
            m_jumps       = new FastList <SolarSystem>(0);

            m_x = src.X;
            m_y = src.Y;
            m_z = src.Z;

            if (src.Stations != null)
            {
                foreach (SerializableStation srcStation in src.Stations)
                {
                    Items.Add(new Station(this, srcStation));
                }
            }

            if (src.Planets != null)
            {
                // Add planets
                m_planets = new FastList <Planet>(src.Planets.Count);
                foreach (SerializablePlanet srcPlanet in src.Planets)
                {
                    m_planets.Add(new Planet(this, srcPlanet));
                }
            }
            else
            {
                m_planets = new FastList <Planet>(1);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public SolarSystem(Constellation owner, SerializableSolarSystem src)
            : base(src.Stations == null ? 0 : src.Stations.Length)
        {
            m_id            = src.ID;
            m_owner         = owner;
            m_name          = src.Name;
            m_securityLevel = src.SecurityLevel;
            m_jumps         = new FastList <SolarSystem>(0);

            m_x = src.X;
            m_y = src.Y;
            m_z = src.Z;

            if (src.Stations == null)
            {
                return;
            }
            foreach (var srcStation in src.Stations)
            {
                m_items.Add(new Station(this, srcStation));
            }
        }