Exemple #1
0
    void OnTriggerEnter(Collider c)
    {
        if (inatmo)
        {
            return;
        }

        switch (c.gameObject.tag)
        {
        case "Atmosphere":

            inatmo = true;

            PlanetGen pg = c.GetComponentInParent <PlanetGen>();

            particles.GetComponent <CosmosParticles>().InAtm(pg.atmColor,
                                                             (int)pg.atmStr);

            game.landing  = true;
            game.fuel     = fuel;
            game.people   = peoples;
            game.atmColor = pg.atmColor;
            game.str      = (int)pg.atmStr / 1000;
            game.angle    = transform.eulerAngles.z;
            game.velo     = rb.velocity.magnitude;
            GoLanding();

            break;

            /*case "Ring":
             *      c.GetComponent<Ring>().InRing();
             *      break;*/
        }
    }
Exemple #2
0
    override public void WhenActivate()
    {
        SpaceShip ss = FindObjectOfType <SpaceShip>();

        PlanetGen[] pg = FindObjectsOfType <PlanetGen>();
        if (pg.Length == 0)
        {
            return;
        }

        PlanetGen nearp    = pg[0];
        float     neardist = 99999f;

        foreach (PlanetGen p in pg)
        {
            if (p.founded)
            {
                continue;
            }
            float d = Vector3.Distance(ss.transform.position, p.transform.position);
            if (d < neardist)
            {
                neardist = d;
                nearp    = p;
            }
        }

        if (nearp == null)
        {
            return;
        }

        nearp.Founded();
    }
Exemple #3
0
        public static void GenerateAllPlanets(GalaxyData galaxy, StarData star, GameDesc gameDesc, List <PlanetForGenerator> planetsToGenerate)
        {
            Patch.Debug("Recap of what have to be generated : \n", LogLevel.Debug, Patch.DebugStarGen);
            var finalIndex = 0;

            foreach (var planet in planetsToGenerate)
            {
                var debugLine = "A ";

                planet.planetIndex = finalIndex;
                foreach (var planetForGenerator in planet.moons)
                {
                    planetForGenerator.orbitAround = finalIndex + 1;
                }

                if (planet.isGasGiant)
                {
                    debugLine += " Gas Giant :" + planet.planetIndex + "with values : \n";
                }
                else
                {
                    debugLine += " Telluric Planet :" + planet.planetIndex + "with values : \n";
                }

                //planet.ToString();

                //planet.GenerateThePlanet(ref galaxy,ref star,ref gameDesc);
                //  Debug.Log();
                PlanetGen.CreatePlanet(galaxy, star, gameDesc, planet.planetIndex, planet.orbitAround, planet.orbitIndex, planet.number, planet.isGasGiant, planet.infoSeed, planet.genSeed);
                star.planets[finalIndex].name = star.name + " - " + RomanNumbers.roman[planet.number];
                planet.name = star.planets[finalIndex].name;

                if (planet.moons.Count >= 2)
                {
                    star.planets[finalIndex].HasMultipleSatellites();
                }

                Patch.Debug(star.planets[finalIndex].name, LogLevel.Debug, Patch.DebugStarNamingGen);
                finalIndex++;
                //debugLine += planet.ToString() + "\n\n";
                if (planet.moons.Count != 0)
                {
                    debugLine += "with " + planet.moons.Count + " Moons  : \n\n";
                    foreach (var moon in planet.moons)
                    {
                        moon.planetIndex = finalIndex;
                        debugLine       += " Moon : " + moon.planetIndex + "\n";
                        PlanetGen.CreatePlanet(galaxy, star, gameDesc, moon.planetIndex, moon.orbitAround, moon.orbitIndex, moon.number, moon.isGasGiant, moon.infoSeed, moon.genSeed);
                        star.planets[moon.planetIndex].name = planet.name + " - " + RomanNumbers.roman[moon.number];
                        Patch.Debug(star.planets[moon.planetIndex].name, LogLevel.Debug, Patch.DebugStarNamingGen);

                        finalIndex++;
                    }
                }



                Patch.Debug(debugLine, LogLevel.Debug, Patch.DebugStarGen);
            }
        }
Exemple #4
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        PlanetGen pgen = (PlanetGen)target;

        if (GUILayout.Button("Make Planet"))
        {
            pgen.CreatePlanet();
        }
    }
    override public void RightButton()
    {
        base.RightButton();

        amount = 1100;

        SpaceShip ss = FindObjectOfType <SpaceShip>();

        ss.ChangeEnergy(Random.Range(-475, -525));

        PlanetGen[] pg = FindObjectsOfType <PlanetGen>();
        if (pg.Length == 0)
        {
            return;
        }

        PlanetGen nearp    = pg[0];
        float     neardist = 99999f;

        foreach (PlanetGen p in pg)
        {
            if (p.founded)
            {
                continue;
            }
            float d = Vector3.Distance(ss.transform.position, p.transform.position);
            if (d < neardist)
            {
                neardist = d;
                nearp    = p;
            }
        }

        if (nearp == null)
        {
            FindObjectOfType <StatusText>().SetText("Поиск не дал результатов");
            return;
        }

        if (Random.Range(0, 10) > 2)
        {
            FindObjectOfType <StatusText>().SetText("Отлично, найдена планета!");
            FindObjectOfType <SpaceShip>().ChangeHappy(5);
            nearp.Founded();
        }
        else
        {
            FindObjectOfType <StatusText>().SetText("Поиск не дал результатов");
            FindObjectOfType <SpaceShip>().ChangeHappy(-2);
        }
    }
Exemple #6
0
    // Generate new planet
    public void generatePlanet(PlanetConfig _p_config)
    {
        // Add the planet gen componant
        PlanetGen gen = gameObject.AddComponent <PlanetGen>() as PlanetGen;

        gen.GeneratePlanet(_p_config);

        // Set material colors in shader
        GetComponent <Renderer>().material.SetColor("LandCol", _p_config.l1_col);
        GetComponent <Renderer>().material.SetColor("OceanCol", _p_config.l2_col);
        GetComponent <Renderer>().material.SetColor("SandCol", _p_config.l3_col);
        GetComponent <Renderer>().material.SetColor("MountainsCol", _p_config.l4_col);
        GetComponent <Renderer>().material.SetColor("NightLightsCol", _p_config.nightlights_col);
    }
 public void GenerateThePlanet(ref GalaxyData galaxy, ref StarData star, ref GameDesc gameDesc)
 {
     PlanetGen.CreatePlanet(galaxy, star, gameDesc, planetIndex, orbitAround, orbitIndex, number, isGasGiant, infoSeed, genSeed);
 }
Exemple #8
0
        public static void CreateStarPlanetsRework(GalaxyData galaxy, StarData star, GameDesc gameDesc, PlanetGeneratorSettings genSettings)
        {
            star.name = SystemsNames.systems[star.index];

            Patch.Debug("System " + star.name + " - " + star.type + " - " + star.spectr, LogLevel.Debug,
                        Patch.DebugStarGen);

            // Random Generators Inits
            UnityRandom.InitState(star.seed);
            var mainSeed  = new Random(star.seed);
            var annexSeed = new Random(mainSeed.Next());

            // InnerCount for the System
            var planetsToGenerate = new List <PlanetForGenerator>();

            // settings from the config
            PatchForStarSystemGeneration.StarSystemSetting currentSettings;

            if (star.type == EStarType.BlackHole || star.type == EStarType.GiantStar ||
                star.type == EStarType.NeutronStar || star.type == EStarType.WhiteDwarf)
            {
                currentSettings = Patch.GeneratorSpecialsSystemConfig[star.type];
            }
            else
            {
                currentSettings = Patch.GeneratorMainSystemConfig[star.spectr];
            }

            //Debugging configs
            Patch.Debug("*************************** : \n" +
                        "ChanceMoonGasGiant : " + currentSettings.ChanceGasGiantMoon + "\n" +
                        "ChanceMoonTelluric : " + currentSettings.ChanceMoonTelluric + "\n" +
                        "ChancePlanetTelluric : " + currentSettings.ChanceTelluricPlanet + "\n" +
                        "ChancePlanetGasGiant : " + currentSettings.ChanceGasGiant + "\n" +
                        "MaxMoonNb : " + currentSettings.MaxMoonNb + "\n" +
                        "MaxPlanetNb : " + currentSettings.MaxPlanetNb + "\n" +
                        "ChanceJumpOrbitMoons : " + currentSettings.ChanceJumpOrbitMoons + "\n" +
                        "ChanceJumpOrbitPlanets : " + currentSettings.ChanceJumpOrbitPlanets + "\n" +
                        "*************************** ", LogLevel.Debug, Patch.DebugStarGenDeep);

            Patch.Debug("Definition of Nb of planets In the system :", LogLevel.Debug, Patch.DebugStarGenDeep);

            DefineNumberOfBodies(currentSettings, annexSeed, genSettings);

            if (star.IsStartingStar())
            {
                // check if minimum number of planet is met
                genSettings.nbOfTelluricPlanets = genSettings.nbOfTelluricPlanets < Patch.StartingSystemMinPlanetTelluricNb.Value ? Patch.StartingSystemMinPlanetTelluricNb.Value : genSettings.nbOfTelluricPlanets;
                genSettings.nbOfMoonsTelluric   = genSettings.nbOfMoonsTelluric < Patch.StartingSystemMinTelluricMoonNb.Value ? Patch.StartingSystemMinTelluricMoonNb.Value : genSettings.nbOfMoonsTelluric;
                genSettings.nbOfGasGiantPlanets = genSettings.nbOfGasGiantPlanets < Patch.StartingSystemMinGasGiantNb.Value ? Patch.StartingSystemMinGasGiantNb.Value : genSettings.nbOfGasGiantPlanets;
                genSettings.nbOfMoonsGasGiant   = genSettings.nbOfMoonsGasGiant < Patch.StartingSystemMinGasGiantMoonNb.Value ? Patch.StartingSystemMinGasGiantMoonNb.Value : genSettings.nbOfMoonsGasGiant;

                genSettings.nbOfMoons         = genSettings.nbOfMoonsTelluric + genSettings.nbOfMoonsGasGiant;
                genSettings.nbOfPlanets       = genSettings.nbOfTelluricPlanets + genSettings.nbOfGasGiantPlanets;
                genSettings.nbOfStellarBodies = genSettings.nbOfPlanets + genSettings.nbOfMoons;
            }

            star.planets = new PlanetData[genSettings.nbOfStellarBodies];

            Patch.Debug("*************************** :", LogLevel.Debug, Patch.DebugStarGen);
            Patch.Debug("\nSystem Presets : ", LogLevel.Debug, Patch.DebugStarGen);

            var preset =
                "nbOfPlanets : " + genSettings.nbOfPlanets + "\n" +
                "nbOfTelluricPlanets : " + genSettings.nbOfTelluricPlanets + "\n" +
                "nbOfGasGiantPlanets : " + genSettings.nbOfGasGiantPlanets + "\n" +
                "nbOfMoons : " + genSettings.nbOfMoons + "\n" +
                "nbOfMoonsTelluric : " + genSettings.nbOfMoonsTelluric + "\n" +
                "nbOfMoonsGasGiant : " + genSettings.nbOfMoonsGasGiant + "\n\n";

            Patch.Debug(preset, LogLevel.Debug, Patch.DebugStarGen);

            PreGenerateAllBodies(star, planetsToGenerate, annexSeed, genSettings, currentSettings);

            GenerateAllPlanets(galaxy, star, gameDesc, planetsToGenerate);


            if (star.IsStartingStar())
            {
                Patch.Debug(star.name + " --recap-- : ", LogLevel.Debug, Patch.DebugStarGen);
                var nbOfHabitablePlanets = 0;
                foreach (var planet in star.planets)
                {
                    if (planet.orbitAround != 0)
                    {
                        Patch.Debug("moon type : " + planet.type, LogLevel.Debug, Patch.DebugStarGen);
                    }
                    else
                    {
                        Patch.Debug("planet type : " + planet.type, LogLevel.Debug, Patch.DebugStarGen);
                    }

                    if (planet.type == EPlanetType.Ocean)
                    {
                        nbOfHabitablePlanets++;
                    }
                }

                if (nbOfHabitablePlanets == 0)
                {
                    Patch.Debug("Nb of habitable == 0 --> Override one planet ", LogLevel.Debug, Patch.DebugStarGen);
                    bool @override = true;
                    while (@override)
                    {
                        var indexStartingPlanet = UnityRandom.Range(0, star.planets.Length - 1);

                        if (star.planets[indexStartingPlanet].type != EPlanetType.Gas)
                        {
                            star.planets[indexStartingPlanet].ShouldBeHabitable();
                            galaxy.birthPlanetId = star.planets[indexStartingPlanet].id;
                            @override            = false;
                        }
                    }


                    Patch.Debug(" galaxy.birthPlanetId --> " + galaxy.birthPlanetId, LogLevel.Debug, Patch.DebugStarGen);
                }
            }

            // Apply themes
            foreach (var planet in star.planets)
            {
                PlanetGen.SetPlanetTheme(planet, star, gameDesc, 0, 0, mainSeed.NextDouble(), mainSeed.NextDouble(), mainSeed.NextDouble(), mainSeed.NextDouble(), mainSeed.Next());
                Patch.Debug("planet.algoId --> " + planet.algoId, LogLevel.Debug, Patch.DebugStarGen);
            }

            star.planetCount = star.planets.Length;
        }
        public static void CreateStarPlanets(GalaxyData galaxy, StarData star, GameDesc gameDesc)
        {
            Traverse.Create(typeof(StarGen)).Field("pGas").SetValue(new double[100]);
            System.Random random = new System.Random(star.seed);
            random.Next();
            random.Next();
            random.Next();
            int seed = random.Next();

            System.Random random2 = new System.Random(seed);
            double        num     = random2.NextDouble();
            double        num2    = random2.NextDouble();
            double        num3    = random2.NextDouble();
            double        num4    = random2.NextDouble();
            double        num5    = random2.NextDouble();
            double        num6    = random2.NextDouble() * 0.2 + 0.9;
            double        num7    = random2.NextDouble() * 0.2 + 0.9;

            if (star.type == EStarType.BlackHole)
            {
                star.planetCount = 1;
                star.planets     = new PlanetData[star.planetCount];
                int info_seed = random2.Next();
                int gen_seed  = random2.Next();
                star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 0, 0, 3, 1, false, info_seed, gen_seed);
            }
            else if (star.type == EStarType.NeutronStar)
            {
                star.planetCount = 1;
                star.planets     = new PlanetData[star.planetCount];
                int info_seed2 = random2.Next();
                int gen_seed2  = random2.Next();
                star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 0, 0, 3, 1, false, info_seed2, gen_seed2);
            }
            else if (star.type == EStarType.WhiteDwarf)
            {
                if (num < 0.699999988079071)
                {
                    star.planetCount = 1;
                    star.planets     = new PlanetData[star.planetCount];
                    int info_seed3 = random2.Next();
                    int gen_seed3  = random2.Next();
                    star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 0, 0, 3, 1, false, info_seed3, gen_seed3);
                }
                else
                {
                    star.planetCount = 2;
                    star.planets     = new PlanetData[star.planetCount];
                    if (num2 < 0.30000001192092896)
                    {
                        int info_seed4 = random2.Next();
                        int gen_seed4  = random2.Next();
                        star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 0, 0, 3, 1, false, info_seed4, gen_seed4);
                        info_seed4      = random2.Next();
                        gen_seed4       = random2.Next();
                        star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 1, 0, 4, 2, false, info_seed4, gen_seed4);
                    }
                    else
                    {
                        int info_seed4 = random2.Next();
                        int gen_seed4  = random2.Next();
                        star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 0, 0, 4, 1, true, info_seed4, gen_seed4);
                        info_seed4      = random2.Next();
                        gen_seed4       = random2.Next();
                        star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 1, 1, 1, 1, false, info_seed4, gen_seed4);
                    }
                }
            }
            else if (star.type == EStarType.GiantStar)
            {
                if (num < 0.30000001192092896)
                {
                    star.planetCount = 1;
                    star.planets     = new PlanetData[star.planetCount];
                    int info_seed5 = random2.Next();
                    int gen_seed5  = random2.Next();
                    star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 0, 0, (num3 <= 0.5) ? 2 : 3, 1, false, info_seed5, gen_seed5);
                }
                else if (num < 0.800000011920929)
                {
                    star.planetCount = 2;
                    star.planets     = new PlanetData[star.planetCount];
                    if (num2 < 0.25)
                    {
                        int info_seed6 = random2.Next();
                        int gen_seed6  = random2.Next();
                        star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 0, 0, (num3 <= 0.5) ? 2 : 3, 1, false, info_seed6, gen_seed6);
                        info_seed6      = random2.Next();
                        gen_seed6       = random2.Next();
                        star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 1, 0, (num3 <= 0.5) ? 3 : 4, 2, false, info_seed6, gen_seed6);
                    }
                    else
                    {
                        int info_seed6 = random2.Next();
                        int gen_seed6  = random2.Next();
                        star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 0, 0, 3, 1, true, info_seed6, gen_seed6);
                        info_seed6      = random2.Next();
                        gen_seed6       = random2.Next();
                        star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 1, 1, 1, 1, false, info_seed6, gen_seed6);
                    }
                }
                else
                {
                    star.planetCount = 3;
                    star.planets     = new PlanetData[star.planetCount];
                    if (num2 < 0.15000000596046448)
                    {
                        int info_seed7 = random2.Next();
                        int gen_seed7  = random2.Next();
                        star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 0, 0, (num3 <= 0.5) ? 2 : 3, 1, false, info_seed7, gen_seed7);
                        info_seed7      = random2.Next();
                        gen_seed7       = random2.Next();
                        star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 1, 0, (num3 <= 0.5) ? 3 : 4, 2, false, info_seed7, gen_seed7);
                        info_seed7      = random2.Next();
                        gen_seed7       = random2.Next();
                        star.planets[2] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 2, 0, (num3 <= 0.5) ? 4 : 5, 3, false, info_seed7, gen_seed7);
                    }
                    else if (num2 < 0.75)
                    {
                        int info_seed7 = random2.Next();
                        int gen_seed7  = random2.Next();
                        star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 0, 0, (num3 <= 0.5) ? 2 : 3, 1, false, info_seed7, gen_seed7);
                        info_seed7      = random2.Next();
                        gen_seed7       = random2.Next();
                        star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 1, 0, 4, 2, true, info_seed7, gen_seed7);
                        info_seed7      = random2.Next();
                        gen_seed7       = random2.Next();
                        star.planets[2] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 2, 2, 1, 1, false, info_seed7, gen_seed7);
                    }
                    else
                    {
                        int info_seed7 = random2.Next();
                        int gen_seed7  = random2.Next();
                        star.planets[0] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 0, 0, (num3 <= 0.5) ? 3 : 4, 1, true, info_seed7, gen_seed7);
                        info_seed7      = random2.Next();
                        gen_seed7       = random2.Next();
                        star.planets[1] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 1, 1, 1, 1, false, info_seed7, gen_seed7);
                        info_seed7      = random2.Next();
                        gen_seed7       = random2.Next();
                        star.planets[2] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, 2, 1, 2, 2, false, info_seed7, gen_seed7);
                    }
                }
            }
            else
            {
                if (star.index == 0)
                {
                    star.planetCount = StarCount;
                    for (int i = 0; i < star.planetCount; i++)
                    {
                        SetPGas(i, random.NextDouble() % 0.9);
                    }
                }
                else if (star.spectr == ESpectrType.M)
                {
                    if (num < 0.1)
                    {
                        star.planetCount = 1;
                    }
                    else if (num < 0.3)
                    {
                        star.planetCount = 2;
                    }
                    else if (num < 0.8)
                    {
                        star.planetCount = 3;
                    }
                    else
                    {
                        star.planetCount = 4;
                    }
                    if (star.planetCount <= 3)
                    {
                        SetPGas(0, 0.2);
                        SetPGas(1, 0.2);
                    }
                    else
                    {
                        SetPGas(0, 0);
                        SetPGas(1, 0.2);
                        SetPGas(2, 0.3);
                    }
                }
                else if (star.spectr == ESpectrType.K)
                {
                    if (num < 0.1)
                    {
                        star.planetCount = 1;
                    }
                    else if (num < 0.2)
                    {
                        star.planetCount = 2;
                    }
                    else if (num < 0.7)
                    {
                        star.planetCount = 3;
                    }
                    else if (num < 0.95)
                    {
                        star.planetCount = 4;
                    }
                    else
                    {
                        star.planetCount = 5;
                    }
                    if (star.planetCount <= 3)
                    {
                        SetPGas(0, 0.18);
                        SetPGas(1, 0.18);
                    }
                    else
                    {
                        SetPGas(0, 0);
                        SetPGas(1, 0.18);
                        SetPGas(2, 0.28);
                        SetPGas(3, 0.28);
                    }
                }
                else if (star.spectr == ESpectrType.G)
                {
                    if (num < 0.4)
                    {
                        star.planetCount = 3;
                    }
                    else if (num < 0.9)
                    {
                        star.planetCount = 4;
                    }
                    else
                    {
                        star.planetCount = 5;
                    }
                    if (star.planetCount <= 3)
                    {
                        SetPGas(0, 0.18);
                        SetPGas(1, 0.18);
                    }
                    else
                    {
                        SetPGas(0, 0);
                        SetPGas(1, 0.2);
                        SetPGas(2, 0.3);
                        SetPGas(3, 0.3);
                    }
                }
                else if (star.spectr == ESpectrType.F)
                {
                    if (num < 0.35)
                    {
                        star.planetCount = 3;
                    }
                    else if (num < 0.8)
                    {
                        star.planetCount = 4;
                    }
                    else
                    {
                        star.planetCount = 5;
                    }
                    if (star.planetCount <= 3)
                    {
                        SetPGas(0, 0.2);
                        SetPGas(1, 0.2);
                    }
                    else
                    {
                        SetPGas(0, 0);
                        SetPGas(1, 0.22);
                        SetPGas(2, 0.31);
                        SetPGas(3, 0.31);
                    }
                }
                else if (star.spectr == ESpectrType.A)
                {
                    if (num < 0.3)
                    {
                        star.planetCount = 3;
                    }
                    else if (num < 0.75)
                    {
                        star.planetCount = 4;
                    }
                    else
                    {
                        star.planetCount = 5;
                    }
                    if (star.planetCount <= 3)
                    {
                        SetPGas(0, 0.2);
                        SetPGas(1, 0.2);
                    }
                    else
                    {
                        SetPGas(0, 0.1);
                        SetPGas(1, 0.28);
                        SetPGas(2, 0.3);
                        SetPGas(3, 0.35);
                    }
                }
                else if (star.spectr == ESpectrType.B)
                {
                    if (num < 0.3)
                    {
                        star.planetCount = 4;
                    }
                    else if (num < 0.75)
                    {
                        star.planetCount = 5;
                    }
                    else
                    {
                        star.planetCount = 6;
                    }
                    if (star.planetCount <= 3)
                    {
                        SetPGas(0, 0.2);
                        SetPGas(0, 0.2);
                    }
                    else
                    {
                        SetPGas(0, 0.1);
                        SetPGas(1, 0.22);
                        SetPGas(2, 0.28);
                        SetPGas(3, 0.35);
                        SetPGas(4, 0.35);
                    }
                }
                else if (star.spectr == ESpectrType.O)
                {
                    if (num < 0.5)
                    {
                        star.planetCount = 5;
                    }
                    else
                    {
                        star.planetCount = 6;
                    }
                    SetPGas(0, 0.1);
                    SetPGas(1, 0.2);
                    SetPGas(2, 0.25);
                    SetPGas(3, 0.3);
                    SetPGas(4, 0.32);
                    SetPGas(5, 0.35);
                }
                else
                {
                    star.planetCount = 1;
                }
                star.planets = new PlanetData[star.planetCount];
                int num8  = 0;
                int num9  = 0;
                int num10 = 0;
                int num11 = 1;
                for (int i = 0; i < star.planetCount; i++)
                {
                    int    info_seed8 = random2.Next();
                    int    gen_seed8  = random2.Next();
                    double num12      = random2.NextDouble();
                    double num13      = random2.NextDouble();
                    bool   flag       = false;
                    if (num10 == 0)
                    {
                        num8++;
                        if (i < star.planetCount - 1 && num12 < Traverse.Create(typeof(StarGen)).Field("pGas").GetValue <double[]>()[i])
                        {
                            flag = true;
                            if (num11 < 3)
                            {
                                num11 = 3;
                            }
                        }
                        while (star.index != 0 || num11 != 3)
                        {
                            int num14 = star.planetCount - i;
                            int num15 = 9 - num11;
                            if (num15 > num14)
                            {
                                float num16 = (float)num14 / (float)num15;
                                if (num11 > 3)
                                {
                                    num16 = Mathf.Lerp(num16, 1f, 0.45f) + 0.01f;
                                }
                                else
                                {
                                    num16 = Mathf.Lerp(num16, 1f, 0.15f) + 0.01f;
                                }
                                double num17 = random2.NextDouble();
                                if (num17 >= (double)num16)
                                {
                                    num11++;
                                    continue;
                                }
                            }
                            goto IL_D1A;
                        }
                        flag = true;
                    }
                    else
                    {
                        num9++;
                        flag = false;
                    }
IL_D1A:
                    star.planets[i] = PlanetGen.CreatePlanet(galaxy, star, gameDesc, i, num10, (num10 != 0) ? num9 : num11, (num10 != 0) ? num9 : num8, flag, info_seed8, gen_seed8);
                    num11++;
                    if (flag)
                    {
                        num10 = num8;
                        num9  = 0;
                    }
                    if (num9 >= 1 && num13 < 0.8)
                    {
                        num10 = 0;
                        num9  = 0;
                    }
                }
            }
            int num18 = 0;
            int num19 = 0;
            int num20 = 0;

            for (int j = 0; j < star.planetCount; j++)
            {
                if (star.planets[j].type == EPlanetType.Gas)
                {
                    num18 = star.planets[j].orbitIndex;
                    break;
                }
            }
            for (int k = 0; k < star.planetCount; k++)
            {
                if (star.planets[k].orbitAround == 0)
                {
                    num19 = star.planets[k].orbitIndex;
                }
            }
            if (num18 > 0)
            {
                int  num21 = num18 - 1;
                bool flag2 = true;
                for (int l = 0; l < star.planetCount; l++)
                {
                    if (star.planets[l].orbitAround == 0 && star.planets[l].orbitIndex == num18 - 1)
                    {
                        flag2 = false;
                        break;
                    }
                }
                if (flag2 && num4 < 0.2 + (double)num21 * 0.2)
                {
                    num20 = num21;
                }
            }
            int num22;

            if (num5 < 0.2)
            {
                num22 = num19 + 3;
            }
            else if (num5 < 0.4)
            {
                num22 = num19 + 2;
            }
            else if (num5 < 0.8)
            {
                num22 = num19 + 1;
            }
            else
            {
                num22 = 0;
            }
            if (num22 != 0 && num22 < 5)
            {
                num22 = 5;
            }
            star.asterBelt1OrbitIndex = (float)num20;
            star.asterBelt2OrbitIndex = (float)num22;
            if (num20 > 0)
            {
                star.asterBelt1Radius = StarGen.orbitRadius[num20] * (float)num6 * star.orbitScaler;
            }
            if (num22 > 0)
            {
                star.asterBelt2Radius = StarGen.orbitRadius[num22] * (float)num7 * star.orbitScaler;
            }
        }