コード例 #1
0
ファイル: StarSystem.cs プロジェクト: sveco/AccreteSharp
        /// <summary> Creates the planets of this system using Dole's accretion algorithm.</summary>
        private void Initialize()
        {
            PlanetClassifier pc = new PlanetClassifier();
            Planet last_planet = null, cur_planet = null;
            //Protoplanet p;
            ArrayList protoplanetsList = new ArrayList();
            //int I;

            Protosystem ps = new Protosystem(Primary);
            ps.dist_planetary_masses();
            //p = ps.planet_head;
            foreach (Protoplanet p in ps.protoplanetsList)
            {
                if (p.mass > 0.0)
                {
                    cur_planet = new Planet(p);
                    cur_planet.age = Primary.age; // not sure why, but planets are missing age when generated, so i'll put this here
                    cur_planet.orbit_zone = Primary.orb_zone(cur_planet.a);
                    cur_planet.set_vital_stats(Primary.SM, Primary.r_greenhouse, Primary.r_ecosphere, Primary.age);
                    cur_planet.description = pc.planetType(cur_planet);

                    // could generate moons here
                    // 1. generate a new protosystem based on the planet and star
                    // 2. pull out all of the protoplanets and create moons from them
                    // 3. delete the protosystem
                    #region Added: moons [Yan]

                    //not sure if it's ok to calculate this way, satellites can be created individually as planets and then get snatched by bigger planet but it works this way too
                    //planet migration due to orbital drag not calculated too
                    Protosystem ps_moons = new Protosystem(Primary, cur_planet);
                    ps_moons.dist_moon_masses();
                    Planet last_moon = null, cur_moon = null;

                    foreach (Protoplanet p_moon in ps_moons.protoplanetsList)
                    {
                        if (p_moon.mass > 0.0)
                        {
                            cur_moon = new Planet(p_moon);
                            if (last_moon != null)
                            {
                                if (cur_moon.mass > 0.0000001) // fine-tweaked to give some moons, but not too many
                                {
                                    cur_planet.moons.Add(cur_moon);
                                }
                            }
                            last_moon = cur_moon;
                        }
                    }
                    #endregion

                    if (last_planet != null)
                    {
                        this.planetsList.Add(cur_planet);
                    }
                    last_planet = cur_planet;
                }
            }
            ps = null;
            planetsList.Sort(new PlanetSort(SortDirection.Ascending));
        }
コード例 #2
0
        /// <summary> Creates the planets of this system using Dole's accretion algorithm.</summary>
        private void Initialize()
        {
            PlanetClassifier pc = new PlanetClassifier();
            Planet           last_planet = null, cur_planet = null;
            //Protoplanet p;
            ArrayList protoplanetsList = new ArrayList();
            //int I;

            Protosystem ps = new Protosystem(Primary);

            ps.dist_planetary_masses();
            //p = ps.planet_head;
            foreach (Protoplanet p in ps.protoplanetsList)
            {
                if (p.mass > 0.0)
                {
                    cur_planet            = new Planet(p);
                    cur_planet.age        = Primary.age; // not sure why, but planets are missing age when generated, so i'll put this here
                    cur_planet.orbit_zone = Primary.orb_zone(cur_planet.a);
                    cur_planet.set_vital_stats(Primary.SM, Primary.r_greenhouse, Primary.r_ecosphere, Primary.age);
                    cur_planet.description = pc.planetType(cur_planet);

                    // could generate moons here
                    // 1. generate a new protosystem based on the planet and star
                    // 2. pull out all of the protoplanets and create moons from them
                    // 3. delete the protosystem
                    #region Added: moons [Yan]

                    //not sure if it's ok to calculate this way, satellites can be created individually as planets and then get snatched by bigger planet but it works this way too
                    //planet migration due to orbital drag not calculated too
                    Protosystem ps_moons = new Protosystem(Primary, cur_planet);
                    ps_moons.dist_moon_masses();
                    Planet last_moon = null, cur_moon = null;

                    foreach (Protoplanet p_moon in ps_moons.protoplanetsList)
                    {
                        if (p_moon.mass > 0.0)
                        {
                            cur_moon = new Planet(p_moon);
                            if (last_moon != null)
                            {
                                if (cur_moon.mass > 0.0000001) // fine-tweaked to give some moons, but not too many
                                {
                                    cur_planet.moons.Add(cur_moon);
                                }
                            }
                            last_moon = cur_moon;
                        }
                    }
                    #endregion

                    if (last_planet != null)
                    {
                        this.planetsList.Add(cur_planet);
                    }
                    last_planet = cur_planet;
                }
            }
            ps = null;
            planetsList.Sort(new PlanetSort(SortDirection.Ascending));
        }