public static SolarSystem GenerateSystemFromData(SolarSystemData data, Empire Owner)
        {
            SolarSystem newSys = new SolarSystem()
            {
                SunPath = data.SunPath,
                Name = data.Name
            };
            int numberOfRings = data.RingList.Count;
            int StarRadius = (int)RandomMath.RandomBetween(50f, 500f);
            for (int i = 1; i < numberOfRings + 1; i++)
            {
                int ringtype = 0;

                {
                    int x = (int)(RandomMath.RandomBetween(1, 29));

                        ringtype = x;

                }
                float ringRadius = (float)((i * ((float)StarRadius + RandomMath.RandomBetween(10500f, 12000f))) + 10000f);
                if (data.RingList[i - 1].Asteroids == null )
                {
                    int WhichPlanet = data.RingList[i - 1].WhichPlanet > 0 ? data.RingList[i - 1].WhichPlanet : ringtype;
                    float scale = 1f;
                    if (data.RingList[i - 1].planetScale > 0)
                    {
                        scale = data.RingList[i - 1].planetScale;
                    }
                    else
                    {
                        scale = RandomMath.RandomBetween(0.9f, 1.8f);
                        if (WhichPlanet == 2 || WhichPlanet == 6 || WhichPlanet == 10 || WhichPlanet == 12 || WhichPlanet == 15 || WhichPlanet == 20 || WhichPlanet == 26)
                        {
                            scale += 2.5f;
                        }
                    }

                    float planetRadius = 100f * scale;
                    float RandomAngle = RandomMath.RandomBetween(0f, 360f);
                    Vector2 planetCenter = newSys.findPointFromAngleAndDistance(Vector2.Zero, RandomAngle, ringRadius);

                    Planet newOrbital = new Planet()
                    {
                        Name = data.RingList[i - 1].Planet,
                        OrbitalAngle = RandomAngle,
                        ParentSystem = newSys,
                        SpecialDescription = data.RingList[i - 1].SpecialDescription,
                        planetType = WhichPlanet,
                        Position = planetCenter,
                        scale = scale,
                        ObjectRadius = planetRadius,
                        OrbitalRadius = ringRadius,
                        planetTilt = RandomMath.RandomBetween(45f, 135f)
                    };
                    newOrbital.InitializeUpdate();
                    if (!data.RingList[i - 1].HomePlanet || Owner == null)
                    {
                        if (data.RingList[i - 1].UniqueHabitat)
                        {
                            newOrbital.UniqueHab = true;
                            newOrbital.uniqueHabPercent = data.RingList[i - 1].UniqueHabPC;
                        }
                        newOrbital.SetPlanetAttributes();
                        if (data.RingList[i - 1].MaxPopDefined > 0)
                            newOrbital.MaxPopulation = data.RingList[i - 1].MaxPopDefined * 1000f;
                        if (!string.IsNullOrEmpty(data.RingList[i - 1].Owner) && !string.IsNullOrEmpty(data.RingList[i - 1].Owner))
                        {
                            newOrbital.Owner = EmpireManager.GetEmpireByName(data.RingList[i - 1].Owner);
                            EmpireManager.GetEmpireByName(data.RingList[i - 1].Owner).AddPlanet(newOrbital);
                            newOrbital.Population = newOrbital.MaxPopulation;
                            newOrbital.MineralRichness = 1f;
                            newOrbital.Fertility = 2f;
                            newOrbital.InitializeSliders(newOrbital.Owner);
                            newOrbital.colonyType = Planet.ColonyType.Core;
                            newOrbital.GovernorOn = true;
                        }
                    }
                    else
                    {
                        newOrbital.Owner = Owner;
                        Owner.Capital = newOrbital;
                        newOrbital.InitializeSliders(Owner);
                        Owner.AddPlanet(newOrbital);
                        newOrbital.SetPlanetAttributes(26f);
                        newOrbital.MineralRichness = 1f + Owner.data.Traits.HomeworldRichMod;
                        newOrbital.Special = "None";
                        newOrbital.Fertility = 2f + Owner.data.Traits.HomeworldFertMod;

                        if (data.RingList[i - 1].MaxPopDefined > 0)
                        {
                            newOrbital.MaxPopulation = (data.RingList[i - 1].MaxPopDefined * 1000f) + ((data.RingList[i - 1].MaxPopDefined * 1000f) *  Owner.data.Traits.HomeworldSizeMod);
                        }
                        else
                        {
                            newOrbital.MaxPopulation = 14000f + 14000f * Owner.data.Traits.HomeworldSizeMod;
                        }
                        newOrbital.Population = 14000f;
                        newOrbital.FoodHere = 100f;
                        newOrbital.ProductionHere = 100f;
                        if (!newSys.OwnerList.Contains(newOrbital.Owner))
                        {
                            newSys.OwnerList.Add(newOrbital.Owner);
                        }
                        newOrbital.HasShipyard = true;
                        newOrbital.AddGood("ReactorFuel", 1000);
                        ResourceManager.GetBuilding("Capital City").SetPlanet(newOrbital);
                        ResourceManager.GetBuilding("Space Port").SetPlanet(newOrbital);
                        if (GlobalStats.HardcoreRuleset)
                        {
                            ResourceManager.GetBuilding("Fissionables").SetPlanet(newOrbital);
                            ResourceManager.GetBuilding("Fissionables").SetPlanet(newOrbital);
                            ResourceManager.GetBuilding("Mine Fissionables").SetPlanet(newOrbital);
                            ResourceManager.GetBuilding("Fuel Refinery").SetPlanet(newOrbital);
                        }
                    }
                    if (data.RingList[i - 1].HasRings != null)
                    {
                        newOrbital.hasRings = true;
                        newOrbital.ringTilt = RandomMath.RandomBetween(-80f, -45f);
                    }
                    //Add buildings to planet
                    if (data.RingList[i - 1].BuildingList.Count > 0)
                        foreach (string building in data.RingList[i - 1].BuildingList)
                            ResourceManager.GetBuilding(building).SetPlanet(newOrbital);
                    //Add ships to orbit
                    if (data.RingList[i - 1].Guardians.Count > 0)
                        foreach (string ship in data.RingList[i - 1].Guardians)
                            newOrbital.Guardians.Add(ship);
                    //Add moons to planets
                    if (data.RingList[i - 1].Moons.Count > 0)
                    {
                        for (int j = 0; j < data.RingList[i - 1].Moons.Count; j++)
                        {
                            float radius = newOrbital.ObjectRadius * 5 + (RandomMath.RandomBetween(1000f, 1500f) * (j + 1));
                            Moon moon = new Moon()
                            {
                                orbitTarget = newOrbital.guid,
                                moonType = data.RingList[i - 1].Moons[j].WhichMoon,
                                scale = data.RingList[i - 1].Moons[j].MoonScale,
                                OrbitRadius = radius,
                                OrbitalAngle = RandomMath.RandomBetween(0f, 360f),
                                Position = newSys.GenerateRandomPointOnCircle(radius, newOrbital.Position)
                            };
                            newSys.MoonList.Add(moon);
                        }
                    }
                    newSys.PlanetList.Add(newOrbital);
                    SolarSystem.Ring ring = new SolarSystem.Ring()
                    {
                        Distance = ringRadius,
                        Asteroids = false,
                        planet = newOrbital
                    };
                    newSys.RingList.Add(ring);
                }
                else
                {
                    float numberOfAsteroids = RandomMath.RandomBetween(150f, 250f);
                    for (int k = 0; (float)k < numberOfAsteroids; k++)
                    {
                        Vector3 asteroidCenter = new Vector3(newSys.GenerateRandomPointOnCircle(ringRadius + RandomMath.RandomBetween(-3000f, 3000f), Vector2.Zero), 0f);
                        while (!newSys.RoidPosOK(asteroidCenter))
                        {
                            asteroidCenter = new Vector3(newSys.GenerateRandomPointOnCircle(ringRadius + RandomMath.RandomBetween(-3000f, 3000f), Vector2.Zero), 0f);
                        }
                        Asteroid newRoid = new Asteroid()
                        {
                            scale = RandomMath.RandomBetween(1.2f, 4.6f),
                            Position3D = asteroidCenter
                        };
                        int whichRoid = 0;
                        while (whichRoid == 0 || whichRoid == 3)
                        {
                            whichRoid = (int)RandomMath.RandomBetween(1f, 9f);
                        }
                        newRoid.whichRoid = whichRoid;
                        newRoid.Radius = RandomMath.RandomBetween(30f, 90f);
                        newSys.AsteroidsList.Add(newRoid);
                    }
                    SolarSystem.Ring ring = new SolarSystem.Ring()
                    {
                        Distance = ringRadius,
                        Asteroids = true
                    };
                    newSys.RingList.Add(ring);
                }
            }
            return newSys;
        }
        public void GenerateRandomSystem(string name, UniverseData data, float systemScale)
        {
            int WhichSun = (int)RandomMath.RandomBetween(1f, 6f);
            // CHANGED BY SHAHMATT
            if (WhichSun > 5)
            {
                if ((int)RandomMath.RandomBetween(0f, 100f) < 10)   // 10% for binary star (so 1/6 * 10% = 1/60 for binary star in system)
                {
                    WhichSun = 6;
                }
                else
                {
                    WhichSun = 5;
                }

            }
            // END OF CHANGED BY SHAHMATT

            //int WhichSun = (int)RandomMath.RandomBetween(1f, 6f);
            //if (WhichSun > 5)
            //{
            //    WhichSun = 5;
            //}
            if (WhichSun == 1)
            {
                this.SunPath = "star_red";
            }
            else if (WhichSun == 2)
            {
                this.SunPath = "star_yellow";
            }
            else if (WhichSun == 3)
            {
                this.SunPath = "star_green";
            }
            else if (WhichSun == 4)
            {
                this.SunPath = "star_blue";
            }
            else if (WhichSun == 5)
            {
                this.SunPath = "star_yellow2";
            }
            else if (WhichSun == 6)
            {
                this.SunPath = "star_binary";
            }
            this.Name = name;
            this.numberOfRings = (int)RandomMath.RandomBetween(1f, 6f);
            // ADDED BY SHAHMATT (more planets in system)
            if (GlobalStats.ExtraPlanets >0)
            {
                this.numberOfRings = this.numberOfRings + (int)RandomMath.RandomBetween(0f, (float)GlobalStats.ExtraPlanets);
            }
            // END OF ADDED BY SHAHMATT
            this.RingsCount = this.numberOfRings;
            this.StarRadius = (int)RandomMath.RandomBetween(250f, 500f);
            float ringbase = 10500f;
            float ringmax = 0;
            if (this.RingsCount > 0)
            {
                ringmax = (95000 - this.StarRadius) / this.numberOfRings;
                //ringbase = (10000 - this.StarRadius) / this.numberOfRings;
            }

            for (int i = 1; i < this.numberOfRings + 1; i++)
            {
                if (this.RingList.Count > 1)
                {
                    ringbase = this.RingList[this.RingList.Count - 1].Distance + 5000;// / this.numberOfRings;
                    Planet p = this.RingList[this.RingList.Count - 1].planet;
                    if (p != null)
                        ringbase += p.ObjectRadius;

                }

                //float ringRadius = (float)i * ((float)this.StarRadius + RandomMath.RandomBetween(10500f, 12000f) + 10000f);
                float ringRadius = ringbase + RandomMath.RandomBetween(0, ringmax);// + 20000f / this.numberOfRings);
                ringRadius = ringRadius * systemScale;
                if ((int)RandomMath.RandomBetween(1f, 100f) > 80)
                {
                    float numberOfAsteroids = RandomMath.RandomBetween(150f, 250f);
                    for (int k = 0; (float)k < numberOfAsteroids; k++)
                    {
                        Vector3 asteroidCenter = new Vector3(this.GenerateRandomPointOnCircle(ringRadius + RandomMath.RandomBetween(-3500f * systemScale, 3500f * systemScale), Vector2.Zero), 0f);
                        while (!this.RoidPosOK(asteroidCenter))
                        {
                            asteroidCenter = new Vector3(this.GenerateRandomPointOnCircle(ringRadius + RandomMath.RandomBetween(-3500f * systemScale, 3500f * systemScale), Vector2.Zero), 0f);
                        }
                        Asteroid newRoid = new Asteroid()
                        {
                            scale = RandomMath.RandomBetween(0.75f, 1.6f),
                            Position3D = asteroidCenter
                        };
                        int whichRoid = 0;
                        while (whichRoid == 0 || whichRoid == 3)
                        {
                            whichRoid = (int)RandomMath.RandomBetween(1f, 9f);
                        }
                        newRoid.whichRoid = whichRoid;
                        newRoid.Radius = RandomMath.RandomBetween(30f, 90f);
                        this.AsteroidsList.Add(newRoid);
                    }
                    SolarSystem.Ring ring = new SolarSystem.Ring()
                    {
                        Distance = ringRadius,
                        Asteroids = true
                    };
                    this.RingList.Add(ring);
                }
                else
                {

                    float RandomAngle = RandomMath.RandomBetween(0f, 360f);
                    Vector2 planetCenter = this.findPointFromAngleAndDistance(Vector2.Zero, RandomAngle, ringRadius);
                    Planet newOrbital = new Planet()
                    {
                        Name = string.Concat(this.Name, " ", NumberToRomanConvertor.NumberToRoman(i)),
                        OrbitalAngle = RandomAngle,
                        ParentSystem = this,
                        planetType = (int)RandomMath.RandomBetween(1f, 24f)
                    };
                    if ((newOrbital.planetType == 22 || newOrbital.planetType == 13) && RandomMath.RandomBetween(0f, 100f) > 50f)
                    {
                        newOrbital.planetType = (int)RandomMath.RandomBetween(1f, 24f);
                    }

                    float scale = RandomMath.RandomBetween(0.9f, 1.8f);
                    if (newOrbital.planetType == 2 || newOrbital.planetType == 6 || newOrbital.planetType == 10 || newOrbital.planetType == 12 || newOrbital.planetType == 15 || newOrbital.planetType == 20 || newOrbital.planetType == 26)
                    {
                        scale += 2.5f;
                    }
                    float planetRadius = 100f * scale;
                    newOrbital.SetPlanetAttributes();
                    newOrbital.Position = planetCenter;
                    newOrbital.scale = scale;
                    newOrbital.ObjectRadius = planetRadius;
                    newOrbital.OrbitalRadius = ringRadius;
                    newOrbital.planetTilt = RandomMath.RandomBetween(45f, 135f);
                    if (RandomMath.RandomBetween(1f, 100f) < 15f)
                    {
                        newOrbital.hasRings = true;
                        newOrbital.ringTilt = RandomMath.RandomBetween(-80f, -45f);
                    }
                    float quality = newOrbital.Fertility + newOrbital.MineralRichness + newOrbital.MaxPopulation / 1000f;
                    if (GlobalStats.ActiveModInfo != null && GlobalStats.ActiveModInfo.customRemnantElements)
                    {
                        if (quality > 6f && quality < 10f)
                        {
                            int iRandom = (int)RandomMath.RandomBetween(0f, 100f);
                            if (iRandom > 20 && iRandom < 50)
                            {
                                this.AddRemnantPatrol(newOrbital, data);
                            }
                            else if (iRandom >= 50)
                            {
                                this.AddRemnantGarrison(newOrbital, data);
                            }
                        }
                        else if (quality > 10f)
                        {
                            int iRandom = (int)RandomMath.RandomBetween(0f, 100f);
                            if (iRandom > 50 && iRandom < 85)
                            {
                                this.AddMinorRemnantPresence(newOrbital);
                            }
                            else if (iRandom >= 85)
                            {
                                this.AddMajorRemnantPresence(newOrbital);
                            }
                        }
                    }
                    else
                    {
                        if (quality > 6f && quality < 10f)
                        {
                            if ((int)RandomMath.RandomBetween(0f, 100f) > 50)
                            {
                                this.AddMinorRemnantPresence(newOrbital);
                            }
                        }
                        else if (quality > 10f && (int)RandomMath.RandomBetween(0f, 100f) < 50)
                        {
                            this.AddMajorRemnantPresence(newOrbital);
                        }
                    }
                    this.PlanetList.Add(newOrbital);
                    RandomMath.RandomBetween(0f, 3f);
                    SolarSystem.Ring ring = new SolarSystem.Ring()
                    {
                        Distance = ringRadius,
                        Asteroids = false,
                        planet = newOrbital
                    };
                    this.RingList.Add(ring);
                }
            }
        }
        public void GenerateStartingSystem(string name, Empire Owner, float systemScale)
        {
            this.isStartingSystem = true;
            int WhichSun = (int)RandomMath.RandomBetween(1f, 6f);
            if (WhichSun > 5)
            {
                WhichSun = 5;
            }
            if (WhichSun == 1)
            {
                this.SunPath = "star_red";
            }
            else if (WhichSun == 2)
            {
                this.SunPath = "star_yellow";
            }
            else if (WhichSun == 3)
            {
                this.SunPath = "star_green";
            }
            else if (WhichSun == 4)
            {
                this.SunPath = "star_blue";
            }
            else if (WhichSun == 5)
            {
                this.SunPath = "star_yellow2";
            }
            else if (WhichSun == 6)
            {
                this.SunPath = "star_binary";
            }
            this.Name = name;
            this.numberOfRings = GlobalStats.ExtraPlanets > 3?GlobalStats.ExtraPlanets:  3;

            this.numberOfRings += (int)(RandomMath.RandomBetween(0, 1) + RandomMath.RandomBetween(0, 1) + RandomMath.RandomBetween(0, 1));
            if (this.numberOfRings > 6)
                this.numberOfRings = 6;
            this.RingsCount = this.numberOfRings;
            this.StarRadius = (int)RandomMath.RandomBetween(250f, 500f);
            for (int i = 1; i < this.numberOfRings + 1; i++)
            {
                float ringRadius = (float)i * ((float)this.StarRadius +  RandomMath.RandomBetween(500f, 3500f) + 10000f);
                ringRadius = ringRadius * systemScale;
                if (i ==1 || i>3)
                {
                    float RandomAngle = RandomMath.RandomBetween(0f, 360f);
                    Vector2 planetCenter = this.findPointFromAngleAndDistance(Vector2.Zero, RandomAngle, ringRadius);
                    Planet newOrbital = new Planet()
                    {
                        Name = string.Concat(this.Name, " ", NumberToRomanConvertor.NumberToRoman(i)),
                        OrbitalAngle = RandomAngle,
                        ParentSystem = this,
                        planetType = (int)RandomMath.RandomBetween(1f, 24f)
                    };
                    float scale = RandomMath.RandomBetween(0.9f, 1.8f);
                    if (newOrbital.planetType == 2 || newOrbital.planetType == 6 || newOrbital.planetType == 10 || newOrbital.planetType == 12 || newOrbital.planetType == 15 || newOrbital.planetType == 20 || newOrbital.planetType == 26)
                    {
                        scale += 2.5f;
                    }
                    float planetRadius = 100f * scale;
                    newOrbital.SetPlanetAttributes();
                    newOrbital.Position = planetCenter;
                    newOrbital.scale = scale;
                    newOrbital.ObjectRadius = planetRadius;
                    newOrbital.OrbitalRadius = ringRadius;
                    newOrbital.planetTilt = RandomMath.RandomBetween(45f, 135f);
                    if (RandomMath.RandomBetween(1f, 100f) < 15f)
                    {
                        newOrbital.hasRings = true;
                        newOrbital.ringTilt = RandomMath.RandomBetween(-80f, -45f);
                    }
                    this.PlanetList.Add(newOrbital);
                    RandomMath.RandomBetween(0f, 3f);
                    SolarSystem.Ring ring = new SolarSystem.Ring()
                    {
                        Distance = ringRadius,
                        Asteroids = false,
                        planet = newOrbital
                    };
                    this.RingList.Add(ring);
                }
                else if (i == 2)
                {
                    float numberOfAsteroids = RandomMath.RandomBetween(150f, 250f);
                    for (int k = 0; (float)k < numberOfAsteroids; k++)
                    {
                        Vector3 asteroidCenter = new Vector3(this.GenerateRandomPointOnCircle(ringRadius + RandomMath.RandomBetween(-3500f * systemScale, 3500f * systemScale), Vector2.Zero), 0f);
                        while (!this.RoidPosOK(asteroidCenter))
                        {
                            asteroidCenter = new Vector3(this.GenerateRandomPointOnCircle(ringRadius + RandomMath.RandomBetween(-3500f * systemScale, 3500f * systemScale), Vector2.Zero), 0f);
                        }
                        Asteroid newRoid = new Asteroid()
                        {
                            scale = RandomMath.RandomBetween(0.75f, 1.6f),
                            Position3D = asteroidCenter
                        };
                        int whichRoid = 0;
                        while (whichRoid == 0 || whichRoid == 3)
                        {
                            whichRoid = (int)RandomMath.RandomBetween(1f, 9f);
                        }
                        newRoid.whichRoid = whichRoid;
                        newRoid.Radius = RandomMath.RandomBetween(30f, 90f);
                    }
                    SolarSystem.Ring ring = new SolarSystem.Ring()
                    {
                        Distance = ringRadius,
                        Asteroids = true
                    };
                    this.RingList.Add(ring);
                }
                else if (i == 3)
                {
                    float scale = RandomMath.RandomBetween(1f, 2f);
                    float planetRadius = 100f * scale;
                    float RandomAngle = RandomMath.RandomBetween(0f, 360f);
                    Vector2 planetCenter = this.findPointFromAngleAndDistance(Vector2.Zero, RandomAngle, ringRadius);
                    Planet newOrbital = new Planet()
                    {
                        Name = string.Concat(this.Name, " ", NumberToRomanConvertor.NumberToRoman(i)),
                        OrbitalAngle = RandomAngle,
                        ParentSystem = this
                    };
                    int random = (int)RandomMath.RandomBetween(1f, 3f);
                    if (random == 1)
                    {
                        newOrbital.planetType = 27;
                    }
                    else if (random == 2)
                    {
                        newOrbital.planetType = 29;
                    }
                    newOrbital.Owner = Owner;
                    Owner.Capital = newOrbital;
                    newOrbital.InitializeSliders(Owner);
                    Owner.AddPlanet(newOrbital);
                    newOrbital.SetPlanetAttributes(26f);
                    newOrbital.MineralRichness = 1f + Owner.data.Traits.HomeworldRichMod;
                    newOrbital.Special = "None";
                    newOrbital.Fertility = 2f + Owner.data.Traits.HomeworldFertMod;
                    newOrbital.MaxPopulation = 14000f + 14000f * Owner.data.Traits.HomeworldSizeMod;
                    newOrbital.Population = 14000f;
                    newOrbital.FoodHere = 100f;
                    newOrbital.ProductionHere = 100f;
                    newOrbital.HasShipyard = true;
                    newOrbital.AddGood("ReactorFuel", 1000);
                    ResourceManager.GetBuilding("Capital City").SetPlanet(newOrbital);
                    ResourceManager.GetBuilding("Space Port").SetPlanet(newOrbital);
                    if (GlobalStats.HardcoreRuleset)
                    {
                        ResourceManager.GetBuilding("Fissionables").SetPlanet(newOrbital);
                        ResourceManager.GetBuilding("Fissionables").SetPlanet(newOrbital);
                        ResourceManager.GetBuilding("Mine Fissionables").SetPlanet(newOrbital);
                        ResourceManager.GetBuilding("Fuel Refinery").SetPlanet(newOrbital);
                    }
                    newOrbital.Position = planetCenter;
                    newOrbital.scale = scale;
                    newOrbital.ObjectRadius = planetRadius;
                    newOrbital.OrbitalRadius = ringRadius;
                    newOrbital.planetTilt = RandomMath.RandomBetween(45f, 135f);
                    if (RandomMath.RandomBetween(1f, 100f) < 15f)
                    {
                        newOrbital.hasRings = true;
                        newOrbital.ringTilt = RandomMath.RandomBetween(-80f, -45f);
                    }
                    this.PlanetList.Add(newOrbital);
                    RandomMath.RandomBetween(0f, 3f);
                    SolarSystem.Ring ring = new SolarSystem.Ring()
                    {
                        Distance = ringRadius,
                        Asteroids = false,
                        planet = newOrbital
                    };
                    this.RingList.Add(ring);
                }
            }
        }
 public void GenerateCorsairSystem(string name)
 {
     int WhichSun = (int)RandomMath.RandomBetween(1f, 3f);
     if (WhichSun == 1)
     {
         this.SunPath = "star_red";
     }
     else if (WhichSun == 2)
     {
         this.SunPath = "star_yellow";
     }
     else if (WhichSun == 3)
     {
         this.SunPath = "star_green";
     }
     else if (WhichSun == 4)
     {
         this.SunPath = "star_blue";
     }
     else if (WhichSun == 5)
     {
         this.SunPath = "star_neutron";
     }
     else if (WhichSun == 6)
     {
         this.SunPath = "star_binary";
     }
     this.Name = name;
     this.numberOfRings = 2;
     this.RingsCount = this.numberOfRings;
     this.StarRadius = (int)RandomMath.RandomBetween(250f, 500f);
     for (int i = 1; i < this.numberOfRings + 1; i++)
     {
         float ringRadius = (float)i * ((float)this.StarRadius + RandomMath.RandomBetween(10500f, 12000f));
         if (i != 1)
         {
             float numberOfAsteroids = RandomMath.RandomBetween(150f, 250f);
             for (int k = 0; (float)k < numberOfAsteroids; k++)
             {
                 Vector3 asteroidCenter = new Vector3(this.GenerateRandomPointOnCircle(ringRadius + RandomMath.RandomBetween(-3500f, 3500f), Vector2.Zero), 0f);
                 while (!this.RoidPosOK(asteroidCenter))
                 {
                     asteroidCenter = new Vector3(this.GenerateRandomPointOnCircle(ringRadius + RandomMath.RandomBetween(-3500f, 3500f), Vector2.Zero), 0f);
                 }
                 Asteroid newRoid = new Asteroid()
                 {
                     scale = RandomMath.RandomBetween(0.75f, 1.6f),
                     Position3D = asteroidCenter
                 };
                 int whichRoid = 0;
                 while (whichRoid == 0 || whichRoid == 3)
                 {
                     whichRoid = (int)RandomMath.RandomBetween(1f, 9f);
                 }
                 newRoid.whichRoid = whichRoid;
                 newRoid.Radius = RandomMath.RandomBetween(30f, 90f);
                 this.AsteroidsList.Add(newRoid);
             }
             SolarSystem.Ring ring = new SolarSystem.Ring()
             {
                 Distance = ringRadius,
                 Asteroids = true
             };
             this.RingList.Add(ring);
         }
         else
         {
             float scale = RandomMath.RandomBetween(1f, 2f);
             float planetRadius = 100f * scale;
             float RandomAngle = RandomMath.RandomBetween(0f, 360f);
             Vector2 planetCenter = this.findPointFromAngleAndDistance(Vector2.Zero, RandomAngle, ringRadius);
             Planet newOrbital = new Planet()
             {
                 Name = string.Concat(this.Name, " ", NumberToRomanConvertor.NumberToRoman(i)),
                 OrbitalAngle = RandomAngle,
                 ParentSystem = this,
                 planetType = 22
             };
             newOrbital.SetPlanetAttributes();
             newOrbital.Position = planetCenter;
             newOrbital.scale = scale;
             newOrbital.ObjectRadius = planetRadius;
             newOrbital.OrbitalRadius = ringRadius;
             newOrbital.planetTilt = RandomMath.RandomBetween(45f, 135f);
             if (RandomMath.RandomBetween(1f, 100f) < 15f)
             {
                 newOrbital.hasRings = true;
                 newOrbital.ringTilt = RandomMath.RandomBetween(-80f, -45f);
             }
             float fertility = newOrbital.Fertility;
             float mineralRichness = newOrbital.MineralRichness;
             float maxPopulation = newOrbital.MaxPopulation / 1000f;
             newOrbital.CorsairPresence = true;
             this.PlanetList.Add(newOrbital);
             RandomMath.RandomBetween(0f, 3f);
             SolarSystem.Ring ring = new SolarSystem.Ring()
             {
                 Distance = ringRadius,
                 Asteroids = false,
                 planet = newOrbital
             };
             this.RingList.Add(ring);
         }
     }
 }