/// <summary> /// Saves set options to the Option Container and generates the stars. Then updates the datatable, and returns back to the /// main window. /// </summary> /// <param name="sender">The sender object</param> /// <param name="e">The event arguments</param> private void btnGenStars_Click(object sender, EventArgs e) { //save to OptionCont OptionCont.forceGardenFavorable = chkForceGarden.Checked; OptionCont.inOpenCluster = chkOpenCluster.Checked; OptionCont.setVerboseOutput(chkVerbose.Checked); OptionCont.ensureOneOrbit = chkForceOneOrbit.Checked; //set age, or clear age. if (chkAgeOverride.Checked) { OptionCont.setSystemAge((double)numAge.Value); } if (!chkAgeOverride.Checked) { OptionCont.setSystemAge(-1.0); } //set stars, or clear stars if (chkStarOverride.Checked) { OptionCont.setNumberOfStars((int)numStars.Value); } if (!chkStarOverride.Checked) { OptionCont.setNumberOfStars(-1); } OptionCont.lessStellarEccent = chkLesserEccentricity.Checked; OptionCont.forceVeryLowStellarEccent = chkExtLowStellar.Checked; //set stellar mass options OptionCont.stellarMassRangeSet = chkStellarMass.Checked; OptionCont.minStellarMass = (double)numMinMass.Value; OptionCont.maxStellarMass = (double)numMaxMass.Value; OptionCont.fantasyColors = chkFantasyColors.Checked; OptionCont.moreFlareStarChance = chkMoreFlare.Checked; OptionCont.anyStarFlareStar = chkAnyFlareStar.Checked; //now we start setting system parameters. if (txtSysName.Text == "") { this.ourSystem.sysName = libStarGen.genRandomSysName(OptionCont.sysNamePrefix, velvetBag); } else { this.ourSystem.sysName = txtSysName.Text; } this.ourSystem.sysAge = libStarGen.genSystemAge(velvetBag); //start creating and making stars. libStarGen.createStars(velvetBag, ourSystem); parent.createStarsFinished = true; this.Close(); //close the form }
public override string ToString() { String ret; String nL = Environment.NewLine + " "; ret = this.name + " is a " + this.getStatusDesc() + " star with spectral type " + this.specType; ret = ret + nL + "This star has " + this.currMass + " solar masses, and a current luminosity of " + Math.Round(this.currLumin, OptionCont.numberOfDecimal); ret = ret + nL + "solar luminosities. It has a surface temperature of " + Math.Round(this.effTemp, OptionCont.numberOfDecimal) + "K."; ret = ret + nL + "This star's radius is " + Math.Round(this.getRadiusAU(), OptionCont.numberOfDecimal) + " AU."; ret = ret + nL + "Apparent Color : " + this.starColor; if (OptionCont.getVerboseOutput()) { ret = ret + Environment.NewLine; ret = ret + nL + "Initial Luminosity: " + this.initLumin + " solar luminosities."; ret = ret + nL + "Initial Mass: " + this.initMass + " solar masses"; ret = ret + nL + "Formation Zones: " + Star.innerRadius(this.initLumin, this.initMass) + " AU to " + Math.Round(Star.outerRadius(this.initMass), OptionCont.numberOfDecimal) + " AU"; ret = ret + nL + "Snow Line: " + Math.Round(Star.snowLine(this.initLumin), OptionCont.numberOfDecimal) + " AU."; } ret = ret + Environment.NewLine; if (this.isFlareStar) { ret = ret + nL + "This star is a flare star."; } ret = ret + Environment.NewLine; if (OptionCont.getVerboseOutput()) { ret = ret + nL + "Self ID: " + Star.getDescSelfFlag(this.selfID) + " and Parent ID: " + Star.getDescSelfFlag(this.parentID); ret = ret + nL; } //printing out age details ret = ret + nL + "Evolution Data"; ret = ret + Environment.NewLine; if (this.evoLine.getGiantLimit() < 1000) { ret = ret + nL + "Main Sequence Ends: " + this.evoLine.getMainLimit() + " Gyr,"; ret = ret + " Subgiant Ends: " + this.evoLine.getSubLimit() + " Gyr"; ret = ret + nL + "Giant Stage Ends: " + this.evoLine.getGiantLimit() + " Gyr"; if (this.starAge < this.evoLine.getMainLimit()) { ret = ret + nL + "This star will exit the main sequence phase in: " + (this.evoLine.getMainLimit() - this.starAge) + " Gyr"; } if (this.starAge >= this.evoLine.getMainLimit() && this.starAge < this.evoLine.getSubLimit()) { ret = ret + nL + "This star will exit the subgiant phase in: " + (this.evoLine.getSubLimit() - this.starAge) + " Gyr"; } if (this.starAge >= this.evoLine.getSubLimit() && this.starAge < this.evoLine.getGiantLimit()) { ret = ret + nL + "This star will exit the giant phase in: " + (this.evoLine.getGiantLimit() - this.starAge) + " Gyr"; } if (this.starAge >= this.evoLine.getGiantLimit()) { ret = ret + nL + "This star has been a white dwarf for: " + (this.starAge - this.evoLine.getGiantLimit()) + " Gyr"; } } else { ret = ret + nL + "This star will burn out sometime well after the galaxy disappears."; } if (this.selfID != Star.IS_PRIMARY) { ret = ret + Environment.NewLine; ret = ret + nL + "Orbital Details"; ret = ret + nL + "This orbits " + this.parentName + " at " + this.orbitalRadius + " AU."; if (this.orbitalEccent > 0) { ret = ret + nL + "Eccentricity: " + this.orbitalEccent + "."; ret = ret + nL + "Periapsis: " + Orbital.getPeriapsis(this.orbitalEccent, this.orbitalRadius) + " AU and Apapasis: " + Orbital.getApapsis(this.orbitalEccent, this.orbitalRadius) + " AU."; } ret = ret + nL + "Orbital period is " + Math.Round(this.orbitalPeriod, 2) + " years (" + Math.Round(this.orbitalPeriod * 365.25, 2); ret = ret + " days)"; ret = ret + nL + "This has a seperation of " + libStarGen.getSeperationStr(this.orbitalSep); } ret = ret + nL; ret = ret + nL + "Orbital Details"; foreach (Satellite s in this.sysPlanets) { ret = ret + nL + s; ret = ret + nL; } ret = ret + nL; if (OptionCont.getVerboseOutput()) { ret = ret + nL; ret = ret + nL + "Formation Zone Details"; ret = ret + nL; foreach (forbiddenZone r in this.zonesOfInterest.forbiddenZones) { ret = ret + nL + r; } ret = ret + nL; foreach (cleanZone r in this.zonesOfInterest.formationZones) { ret = ret + nL + r; } ret = ret + nL; ret = ret + nL + "Gas Giant Flag: " + Star.descGasGiantFlag(this.gasGiantFlag); ret = ret + nL; } return(ret); }
/// <summary> /// Sends the completed status and begins generating the planets /// </summary> /// <param name="sender">Sender object</param> /// <param name="e">EventArgs object</param> private void btnGenPlanets_Click(object sender, EventArgs e) { //save options OptionCont.moreConGasGiantChances = chkConGasGiant.Checked; OptionCont.noOceanOnlyGarden = onlyGarden.Checked; OptionCont.moreAccurateO2Catastrophe = chkMoreAccurateO2Catastrophe.Checked; OptionCont.stableActivity = frcStableActivity.Checked; OptionCont.noMarginalAtm = noMarginAtm.Checked; OptionCont.highRVMVal = highRVM.Checked; OptionCont.overrideHabitability = chkHigherHabitability.Checked; OptionCont.ignoreLunarTidesOnGardenWorlds = ignoreTides.Checked; OptionCont.rerollAxialTiltOver45 = chkKeepAxialTiltUnder45.Checked; OptionCont.alwaysDisplayTidalData = chkDisplayTidalData.Checked; OptionCont.expandAsteroidBelt = chkExpandAsteroidBelt.Checked; if (overrideMoons.Checked) { OptionCont.setNumberOfMoonsOverGarden((int)numMoons.Value); } if (overridePressure.Checked) { OptionCont.setAtmPressure = (double)numAtmPressure.Value; } if (chkOverrideTilt.Checked) { OptionCont.setAxialTilt((int)numTilt.Value); } //set the moon option. if (bookHigh.Checked) { OptionCont.moonOrbitFlag = OptionCont.MOON_BOOKHIGH; } if (bookMoon.Checked) { OptionCont.moonOrbitFlag = OptionCont.MOON_BOOK; } if (extendHigh.Checked) { OptionCont.moonOrbitFlag = OptionCont.MOON_EXPANDHIGH; } if (extendNorm.Checked) { OptionCont.moonOrbitFlag = OptionCont.MOON_EXPAND; } //generate the planets! int totalOrbCount = 0; //total orbital count //first off, master loop. for (int currStar = 0; currStar < this.ourSystem.sysStars.Count; currStar++) { Range temp; //draw up forbidden zones. if (!this.ourSystem.sysStars[currStar].testInitlizationZones()) { this.ourSystem.sysStars[currStar].initalizeZonesOfInterest(); } for (int i = 1; i < this.ourSystem.sysStars.Count; i++) { if (this.ourSystem.sysStars[i].parentID == this.ourSystem.sysStars[currStar].selfID) { temp = new Range(this.ourSystem.sysStars[i].getInnerForbiddenZone(), this.ourSystem.sysStars[i].getOuterForbiddenZone()); this.ourSystem.sysStars[currStar].createForbiddenZone(temp, this.ourSystem.sysStars[currStar].selfID, this.ourSystem.sysStars[i].selfID); } if (this.ourSystem.sysStars[i].selfID == this.ourSystem.sysStars[currStar].selfID) { temp = new Range(this.ourSystem.sysStars[i].getInnerForbiddenZone(), this.ourSystem.sysStars[i].getOuterForbiddenZone()); this.ourSystem.sysStars[currStar].createForbiddenZone(temp, this.ourSystem.sysStars[currStar].parentID, this.ourSystem.sysStars[currStar].selfID); } } this.ourSystem.sysStars[currStar].sortForbidden(); this.ourSystem.sysStars[currStar].createCleanZones(); //gas giant flag // libStarGen.gasGiantFlag(this.ourSystem.sysStars[currStar], velvetBag.gurpsRoll()); Satellite placeHolder = new Satellite(0, 0, 0, 0); int ownership, roll; double orbit = 0; if (this.ourSystem.sysStars[currStar].gasGiantFlag != Star.GASGIANT_NONE) { double rangeAvail = 0, lowerBound = 0, diffRange = 0; Range spawnRange = new Range(0, 1); //get range availability and spawn range //CONVENTIONAL if (this.ourSystem.sysStars[currStar].gasGiantFlag == Star.GASGIANT_CONVENTIONAL) { rangeAvail = this.ourSystem.sysStars[currStar].checkConRange(); lowerBound = Star.snowLine(this.ourSystem.sysStars[currStar].initLumin) * 1; diffRange = (Star.snowLine(this.ourSystem.sysStars[currStar].initLumin) * 1.5) - lowerBound; spawnRange = this.ourSystem.sysStars[currStar].getConventionalRange(); } //ECCENTRIC if (this.ourSystem.sysStars[currStar].gasGiantFlag == Star.GASGIANT_ECCENTRIC) { rangeAvail = this.ourSystem.sysStars[currStar].checkEccRange(); lowerBound = Star.snowLine(this.ourSystem.sysStars[currStar].initLumin) * .125; diffRange = (Star.snowLine(this.ourSystem.sysStars[currStar].initLumin) * .75) - lowerBound; spawnRange = this.ourSystem.sysStars[currStar].getEccentricRange(); } //EPISTELLAR if (this.ourSystem.sysStars[currStar].gasGiantFlag == Star.GASGIANT_EPISTELLAR) { rangeAvail = this.ourSystem.sysStars[currStar].checkEpiRange(); lowerBound = Star.innerRadius(this.ourSystem.sysStars[currStar].initLumin, this.ourSystem.sysStars[currStar].initMass) * .1; diffRange = (Star.innerRadius(this.ourSystem.sysStars[currStar].initLumin, this.ourSystem.sysStars[currStar].initMass) * 1.8) - lowerBound; spawnRange = this.ourSystem.sysStars[currStar].getEpistellarRange(); } if (rangeAvail >= .25) { do { orbit = velvetBag.rollRange(lowerBound, diffRange); } while (!this.ourSystem.sysStars[currStar].verifyCleanOrbit(orbit)); ownership = this.ourSystem.sysStars[currStar].getOwnership(orbit); if (this.ourSystem.sysStars[currStar].gasGiantFlag == Star.GASGIANT_EPISTELLAR) { ownership = this.ourSystem.sysStars[currStar].selfID; } placeHolder = new Satellite(ownership, 0, orbit, 0, Satellite.BASETYPE_GASGIANT); roll = velvetBag.gurpsRoll() + 4; libStarGen.updateGasGiantSize(placeHolder, roll); } if (rangeAvail >= .005 && rangeAvail < .25) { orbit = this.ourSystem.sysStars[currStar].pickInRange(spawnRange); ownership = this.ourSystem.sysStars[currStar].getOwnership(orbit); if (this.ourSystem.sysStars[currStar].gasGiantFlag == Star.GASGIANT_EPISTELLAR) { ownership = this.ourSystem.sysStars[currStar].selfID; } placeHolder = new Satellite(ownership, 0, orbit, 0, Satellite.BASETYPE_GASGIANT); roll = velvetBag.gurpsRoll() + 4; libStarGen.updateGasGiantSize(placeHolder, roll); } } //now we've determined our placeholdr, let's start working on our orbitals. double currOrbit = Star.innerRadius(this.ourSystem.sysStars[currStar].initLumin, this.ourSystem.sysStars[currStar].initMass), nextOrbit = 0; double distance = .15; //now we have our placeholder. if (placeHolder.orbitalRadius != 0) { this.ourSystem.sysStars[currStar].addSatellite(placeHolder); currOrbit = placeHolder.orbitalRadius; } if (this.ourSystem.sysStars[currStar].gasGiantFlag != Star.GASGIANT_EPISTELLAR && placeHolder.orbitalRadius != 0) { //we're moving left. //LEFT RIGHT LEFT //.. sorry about that double innerRadius = Star.innerRadius(this.ourSystem.sysStars[currStar].initLumin, this.ourSystem.sysStars[currStar].initMass); do { //as we're moving left, divide. nextOrbit = currOrbit / libStarGen.getOrbitalRatio(velvetBag); if (nextOrbit > currOrbit - distance) { nextOrbit = currOrbit - distance; } if (this.ourSystem.sysStars[currStar].verifyCleanOrbit(nextOrbit) && this.ourSystem.sysStars[currStar].withinCreationRange(nextOrbit)) { ownership = this.ourSystem.sysStars[currStar].getOwnership(nextOrbit); this.ourSystem.sysStars[currStar].addSatellite(new Satellite(ownership, 0, nextOrbit, 0)); } currOrbit = nextOrbit; //now let's check on } while (currOrbit > innerRadius); } //MOVE RIGHT! //now we have our placeholder. if (this.ourSystem.sysStars[currStar].gasGiantFlag == Star.GASGIANT_EPISTELLAR || placeHolder.orbitalRadius == 0) { double outerRadius = Star.outerRadius(this.ourSystem.sysStars[currStar].initMass); do { //as we're moving right, multiply. nextOrbit = currOrbit * libStarGen.getOrbitalRatio(velvetBag); if (nextOrbit < currOrbit + distance) { nextOrbit = currOrbit + distance; } if (this.ourSystem.sysStars[currStar].verifyCleanOrbit(nextOrbit) && this.ourSystem.sysStars[currStar].withinCreationRange(nextOrbit)) { ownership = this.ourSystem.sysStars[currStar].getOwnership(nextOrbit); this.ourSystem.sysStars[currStar].addSatellite(new Satellite(ownership, 0, nextOrbit, 0)); } currOrbit = nextOrbit; if (currOrbit < 0) { currOrbit = outerRadius + 10; } //now let's check on } while (currOrbit < outerRadius); } //if a clean zone has 0 planets, add one. foreach (cleanZone c in this.ourSystem.sysStars[currStar].zonesOfInterest.formationZones) { if (!this.ourSystem.sysStars[currStar].cleanZoneHasOrbits(c)) { nextOrbit = this.ourSystem.sysStars[currStar].pickInRange(c.getRange()); ownership = this.ourSystem.sysStars[currStar].getOwnership(nextOrbit); this.ourSystem.sysStars[currStar].addSatellite(new Satellite(ownership, 0, nextOrbit, 0)); } } //sort orbitals this.ourSystem.sysStars[currStar].sortOrbitals(); this.ourSystem.sysStars[currStar].giveOrbitalsOrder(ref totalOrbCount); //now we get orbital contents, then fill in details libStarGen.populateOrbits(this.ourSystem.sysStars[currStar], velvetBag); //set any star with all empty orbits to have one planet if (this.ourSystem.sysStars[currStar].isAllEmptyOrbits() && OptionCont.ensureOneOrbit) { int newPlanet = velvetBag.rng(1, this.ourSystem.sysStars[currStar].sysPlanets.Count, -1); this.ourSystem.sysStars[currStar].sysPlanets[newPlanet].updateTypeSize(Satellite.BASETYPE_TERRESTIAL, Satellite.SIZE_MEDIUM); } } for (int currStar = 0; currStar < this.ourSystem.sysStars.Count; currStar++) { double[,] distChart = libStarGen.genDistChart(this.ourSystem.sysStars); for (int i = 0; i < this.ourSystem.sysStars[currStar].sysPlanets.Count; i++) { this.ourSystem.sysStars[currStar].sysPlanets[i].updateBlackBodyTemp(distChart, this.ourSystem.sysStars); } libStarGen.createPlanets(this.ourSystem, this.ourSystem.sysStars[currStar].sysPlanets, velvetBag); } parent.createPlanetsFinished = true; this.Close(); //close the form }