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); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); PlanetGen pgen = (PlanetGen)target; if (GUILayout.Button("Make Planet")) { pgen.CreatePlanet(); } }
public void GenerateThePlanet(ref GalaxyData galaxy, ref StarData star, ref GameDesc gameDesc) { PlanetGen.CreatePlanet(galaxy, star, gameDesc, planetIndex, orbitAround, orbitIndex, number, isGasGiant, infoSeed, genSeed); }
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; } }