예제 #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));
            }
        }
예제 #2
0
        /// <summary>
        /// Compares this system with another one.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">other</exception>
        public int CompareTo(Constellation other)
        {
            other.ThrowIfNull(nameof(other));

            return(Region != other.Region
                ? Region.CompareTo(other.Region)
                : String.Compare(Name, other.Name, StringComparison.CurrentCulture));
        }
예제 #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);
            }
        }