/// <summary> /// This generates a random name for a star system /// </summary> /// <param name="prefix">The prefix for the generator</param> /// <param name="ourDice">Ddice used in rolling</param> /// <returns>A random name for a star system</returns> public static string GenRandomSysName( string prefix, Dice ourDice ) { return prefix + Math.Round(ourDice.RollRange(0, 1) * 1000000000, 0); }
/// <summary> /// This places our stars around the primary, as well as creating the secondary stars if called for /// </summary> /// <param name="ourSystem">The star system to be added to.</param> /// <param name="velvetBag">Our Ddice object.</param> private static void PlaceOurStars( StarSystem ourSystem, Dice velvetBag ) { //initiate the variables we need to ensure distances are kept var maxOrbitalDistance = 600.0; var starLimit = ourSystem.SysStars.Count; for (var i = 1; i < starLimit; i++) { var modifiers = 0; var minOrbitalDistance = ourSystem.SysStars[i - 1].OrbitalRadius; //set the min and max conditions for the first star here. int roll; double tempVal; if (ourSystem.SysStars[i].ParentId == 0 || ourSystem.SysStars[i].ParentId == Star.IsPrimary) { //apply modifiers if (ourSystem.SysStars[i].SelfId == Star.IsTrinary) { modifiers = modifiers + 6; } if (OptionCont.ForceGardenFavorable != null) { if ((bool) OptionCont.ForceGardenFavorable && ourSystem.SysStars[i].ParentId == Star.IsPrimary) { modifiers = modifiers + 4; } } if (minOrbitalDistance == 600.0) { //in this situation, orbital 3 or so can't be safely placed because the range is 0. // so we autogenerate it. tempVal = velvetBag.RollRange(25, 25); ourSystem.SysStars[i].OrbitalSep = 5; ourSystem.SysStars[ourSystem.Star2Index].OrbitalRadius = ourSystem.SysStars[ourSystem.Star2Index].OrbitalRadius - tempVal; ourSystem.SysStars[i].OrbitalRadius = 600 + tempVal; ourSystem.SysStars[i].DistFromPrimary = ourSystem.SysStars[i].OrbitalRadius; } else { do { //roll the Ddice and generate the orbital radius do { roll = velvetBag.GurpsRoll(modifiers); if (roll <= 6) { ourSystem.SysStars[i].OrbitalSep = Star.OrbsepVeryclose; } if (roll >= 7 && roll <= 9) { ourSystem.SysStars[i].OrbitalSep = Star.OrbsepClose; } if (roll >= 10 && roll <= 11) { ourSystem.SysStars[i].OrbitalSep = Star.OrbsepModerate; } if (roll >= 12 && roll <= 14) { ourSystem.SysStars[i].OrbitalSep = Star.OrbsepWide; } if (roll >= 15) { ourSystem.SysStars[i].OrbitalSep = Star.OrbsepDistant; } tempVal = velvetBag.Rng(2, 6) * GetSepModifier(ourSystem.SysStars[i].OrbitalSep); } while (tempVal <= minOrbitalDistance); //if (ourSystem.sysStars[i].selfID == 2) tempVal = this.velvetBag.six(1, 7) * ourSystem.sysStars[i].getSepModifier(); var lowerBound = tempVal - .5 * GetSepModifier(ourSystem.SysStars[i].OrbitalSep); var higherBound = .5 * GetSepModifier(ourSystem.SysStars[i].OrbitalSep) + tempVal; //set for constraints if (lowerBound < minOrbitalDistance) { lowerBound = minOrbitalDistance; } if (higherBound > maxOrbitalDistance) { higherBound = maxOrbitalDistance; } ourSystem.SysStars[i].OrbitalRadius = tempVal; ourSystem.SysStars[i].DistFromPrimary = ourSystem.SysStars[i].OrbitalRadius; } while (ourSystem.SysStars[i].OrbitalRadius <= minOrbitalDistance); //let's see if it has a subcompanion if (ourSystem.SysStars[i].OrbitalSep == Star.OrbsepDistant) { roll = velvetBag.GurpsRoll(); if (roll >= 11) { //generate the subcompanion var order = 0; if (ourSystem.SysStars[i].SelfId == Star.IsSecondary) { order = Star.IsSeccomp; } if (ourSystem.SysStars[i].SelfId == Star.IsTrinary) { order = Star.IsTricomp; } //add the star ourSystem.AddStar(order, ourSystem.SysStars[i].SelfId, i + 1); ourSystem.SysStars[starLimit].Name = Star.GenGenericName(ourSystem.SysName, i + 1); //set the name, then generate the star ourSystem.SysStars[starLimit].ParentName = ourSystem.SysStars[i].Name; GenerateAStar(ourSystem.SysStars[starLimit], velvetBag, ourSystem.SysStars[i].CurrMass, ourSystem.SysName); starLimit++; //increment the total number of stars we have generated } } } } else { maxOrbitalDistance = ourSystem.SysStars[ourSystem.GetStellarParentId(ourSystem.SysStars[i].ParentId)].OrbitalRadius; //roll for seperation do { //roll the Ddice roll = velvetBag.GurpsRoll(-6); if (roll <= 6) { ourSystem.SysStars[i].OrbitalSep = Star.OrbsepVeryclose; } if (roll >= 7 && roll <= 9) { ourSystem.SysStars[i].OrbitalSep = Star.OrbsepClose; } if (roll >= 10 && roll <= 11) { ourSystem.SysStars[i].OrbitalSep = Star.OrbsepModerate; } if (roll >= 12 && roll <= 14) { ourSystem.SysStars[i].OrbitalSep = Star.OrbsepWide; } if (roll >= 15) { ourSystem.SysStars[i].OrbitalSep = Star.OrbsepDistant; } //set the subcompanion orbital tempVal = velvetBag.Rng(2, 6) * GetSepModifier(ourSystem.SysStars[i].OrbitalSep); tempVal -= 0.5 * GetSepModifier(ourSystem.SysStars[i].OrbitalSep); var higherBound = .5 * GetSepModifier(ourSystem.SysStars[i].OrbitalSep) + tempVal; if (higherBound > maxOrbitalDistance) { higherBound = maxOrbitalDistance; } ourSystem.SysStars[i].OrbitalRadius = tempVal; ourSystem.SysStars[i].DistFromPrimary = ourSystem.SysStars[i].OrbitalRadius + maxOrbitalDistance; } while (ourSystem.SysStars[i].OrbitalRadius > maxOrbitalDistance); } CalcEccentricity(velvetBag, ourSystem.SysStars[i]); var parent = ourSystem.GetStellarParentId(ourSystem.SysStars[i].ParentId); ourSystem.SysStars[i].OrbitalPeriod = Star.CalcOrbitalPeriod(ourSystem.SysStars[parent].CurrMass, ourSystem.SysStars[i].CurrMass, ourSystem.SysStars[i].OrbitalRadius); } }
/// <summary> /// Updates a satellite for tidal lock /// </summary> /// <param name="s">The satelite </param> /// <param name="ourBag">Our Ddice object</param> private static void UpdateTidalLock( Satellite s, Dice ourBag ) { var atmDesc = s.GetAtmCategory(); if (atmDesc == Satellite.AtmPresNone || atmDesc == Satellite.AtmPresTrace) { s.UpdateAtmPres(0.00); s.HydCoverage = 0.0; s.DayFaceMod = 1.2; s.NightFaceMod = .1; } if (atmDesc == Satellite.AtmPresVerythin) { s.UpdateAtmPres(0.01); s.HydCoverage = 0.0; s.DayFaceMod = 1.2; s.NightFaceMod = .1; } if (atmDesc == Satellite.AtmPresThin) { s.UpdateAtmPres(ourBag.RollRange(.01, .49)); s.HydCoverage = s.HydCoverage - .5; if (s.HydCoverage < 0) { s.HydCoverage = 0.0; } s.DayFaceMod = 1.16; s.NightFaceMod = .67; } if (atmDesc == Satellite.AtmPresStandard) { s.HydCoverage = s.HydCoverage - .25; if (s.HydCoverage < 0) { s.HydCoverage = 0.0; } s.DayFaceMod = 1.12; s.NightFaceMod = .80; } if (atmDesc == Satellite.AtmPresDense) { s.HydCoverage = s.HydCoverage - .1; if (s.HydCoverage < 0) { s.HydCoverage = 0.0; } s.DayFaceMod = 1.09; s.NightFaceMod = .88; } if (atmDesc == Satellite.AtmPresVerydense) { s.DayFaceMod = 1.05; s.NightFaceMod = .95; } if (atmDesc != Satellite.AtmPresSuperdense) { return; } s.DayFaceMod = 1.0; s.NightFaceMod = 1.0; }
/// <summary> /// This function will set the diameter, mass and gravity, given the density. /// </summary> /// <param name="ourBag">Our Ddice object</param> /// <exception cref="Exception">Throws an exception if it's called on anything but a moon and gas giant</exception> /// <exception cref="Exception">Throws an exception if the density is unset.</exception> public virtual void GenPhysicalParameters( Dice ourBag ) { if (BaseType == BasetypeAsteroidbelt || BaseType == BasetypeEmpty || BaseType == BasetypeUnset) { throw new Exception("Please only call this on a moon, terrestial planet or gas giant."); } if (Math.Abs(Density) < 0) { throw new Exception("Density unset."); } if (BaseType == BasetypeTerrestial || BaseType == BasetypeMoon) { var baseVal = Math.Sqrt(BlackbodyTemp / Density); //range for small is .004 to .024 if (SatelliteSize == SizeTiny) { Diameter = ourBag.RollRange(.004, .020) * baseVal; } //range for small is .024 to .030 if (SatelliteSize == SizeSmall) { Diameter = ourBag.RollRange(.024, .006) * baseVal; } //range for medium is .030 to .065 if (SatelliteSize == SizeMedium) { Diameter = ourBag.RollRange(.030, .035) * baseVal; } //range for large is .065 to .091 if (SatelliteSize == SizeLarge) { Diameter = ourBag.RollRange(.065, .026) * baseVal; } Mass = Density * Math.Pow(Diameter, 3); Gravity = Density * Diameter; } if (BaseType == BasetypeGasgiant) { Diameter = Math.Pow(Mass / Density, .33); Gravity = Density * Diameter; } }