public void GenerateBody() { ulong param1 = starSystem.SystemId << 16 | starSystem.SystemId >> 12 + (_systemBodyId & 0xFF); ulong param2 = ((ulong)_systemBodyId << 16 | starSystem.SystemId >> 12) + (starSystem.SystemId & 0xFF); Utils.Rotate_SystemParams(ref param1, ref param2); Random rand = new Random( (int)(param1 + param2) ); float hz = this.StarSystem.HZone; float minDist = hz * 0.2F; float maxDist = hz * 60.0F; //No planets more then 5000Au away if (maxDist > 5000) { maxDist = 5000; } if (minDist > 600) { minDist = 600; } int totalBodies = this.StarSystem.NumberOfBodies; double pNum = (_systemBodyId + 1) * 0.9; double pMin = ((Math.Pow(2, pNum - 1)) * (maxDist - minDist) / ((Math.Pow(2, totalBodies - 1)))) + minDist; double pMax = ((Math.Pow(2, pNum)) * (maxDist - minDist) / ((Math.Pow(2, totalBodies - 1)))) + minDist; double spreadHint = pMax - pMin; double baseDistance = rand.NextDouble() * (spreadHint / 2) + pMin; List <SystemBodyType> eTypes = new List <SystemBodyType>(); for (int i = 0; i < PlanetBaseDistance.Length; i++) { double mind = PlanetBaseDistance[i][0] * hz; double maxd = PlanetBaseDistance[i][1] * hz; if (baseDistance >= mind && baseDistance <= maxd) { eTypes.Add((SystemBodyType)i); } } if (eTypes.Count == 0) { eTypes.Add(SystemBodyType.RockyPlanetoid); eTypes.Add(SystemBodyType.Asteroid); } _systemBodyType = eTypes[rand.Next(0, eTypes.Count - 1)]; if ((int)_systemBodyType > 11) { _systemBodyType = SystemBodyType.Asteroid; } int baseTempA = PlanetBaseTemperature[(int)_systemBodyType][0]; int baseTempB = PlanetBaseTemperature[(int)_systemBodyType][1]; int baseTempR = baseTempA - baseTempB; double baseDistA = (double)(PlanetBaseDistance[(int)_systemBodyType][0] * hz); double baseDistB = (double)(PlanetBaseDistance[(int)_systemBodyType][1] * hz); double baseDistR = baseDistB - baseDistA; _temperature = (int)( baseTempA - ( (Math.Pow(baseDistance, 0.2) - Math.Pow(baseDistA, 0.2)) / Math.Pow(baseDistR, 0.2) * baseTempR ) ); _distance = (float)baseDistance; _orbitalPeriod = (float)Math.Round(Math.Pow(_distance, 1.5) * 1000, 5) / 1000; _radius = rand.Next(20, 1000) / 100; _angle = rand.Next(0, 360); //double rad = 0.0174532925; //double ssX = (long)(_distance * Math.Cos(_angle * rad) * 149598000); //double ssY = (long)(_distance * Math.Sin(_angle * rad) * 149598000); //double ssZ = 0; //this.SystemLocation.SetInSystemCoords(ssX, ssY, ssZ); SystemLocation.UpdateLocation(this); this._nrConcentration = new Dictionary <NaturalResource, int>(); for (int i = 0; i < NaturalResource.Count; i++) { NaturalResource r = NaturalResource.GetNaturalResource(i); int c = rand.Next( r.Concentration[_systemBodyType].Minimum, r.Concentration[_systemBodyType].Maximum); this._nrConcentration.Add(r, c); } }
public void GenerateSolBodies(int systemBodyId) { switch (systemBodyId) { case 0: this.Name = "Mercury"; this._systemBodyType = SystemBodyType.Inferno; this._numOfZones = 0; this._distance = 0.41F; this._orbitalPeriod = 0.24F; this._temperature = 396; break; case 1: this.Name = "Venus"; this._systemBodyType = SystemBodyType.Venuzian; this._numOfZones = 2; this._distance = 0.72F; this._orbitalPeriod = 0.65F; this._temperature = 480; break; case 2: this.Name = "Earth"; this._systemBodyType = SystemBodyType.Terrestrial; this._numOfZones = 4; this._distance = 1F; this._orbitalPeriod = 1F; this._temperature = 22; break; case 3: this.Name = "Mars"; this._systemBodyType = SystemBodyType.RockyWorld; this._numOfZones = 3; this._distance = 1.45F; this._orbitalPeriod = 1.88F; this._temperature = -25; break; case 4: this.Name = "Jupiter"; this._systemBodyType = SystemBodyType.GasGiant; this._distance = 5.42F; this._orbitalPeriod = 11.8F; this._temperature = -161; break; case 5: this.Name = "Saturn"; this._systemBodyType = SystemBodyType.RingedGasGiant; this._distance = 10.11F; this._orbitalPeriod = 29.45F; this._temperature = -190; break; case 6: this.Name = "Uranus"; this._systemBodyType = SystemBodyType.SubGasGiant; this._distance = 20.08F; this._orbitalPeriod = 84.32F; this._temperature = -224; break; case 7: this.Name = "Neptune"; this._systemBodyType = SystemBodyType.SubGasGiant; this._distance = 30.44F; this._orbitalPeriod = 164.79F; this._temperature = -218; break; case 8: this.Name = "Pluto"; this._systemBodyType = SystemBodyType.RockyPlanetoid; this._distance = 33.45F; this._orbitalPeriod = 248.09F; this._temperature = -260; break; } SystemLocation.UpdateLocation(this); }