Beispiel #1
0
        /// <summary>
        ///     This function generates and populates our stars.
        /// </summary>
        /// <param name="ourBag">The Ddice object used for our PRNG</param>
        /// <param name="ourSystem">The solar system we are creating stars for</param>
        public static void CreateStars( Dice ourBag, StarSystem ourSystem )
        {
            var numStars = 0;

            //determine the number of stars
            if (OptionCont.GetNumberOfStars() != -1)
            {
                numStars = OptionCont.GetNumberOfStars();
            }
            else
            {
                // We take the roll, add 2 if it's in an open cluster,subtract 1 if not, then divide it by 5.
                // This matches the roll probablity to the table.
                numStars = (int) Math.Floor(( ourBag.GurpsRoll() + ( OptionCont.InOpenCluster ? 2 : -1 ) ) / 5.0);

                if (numStars < 1)
                {
                    numStars = 1;
                }
                if (numStars > 3)
                {
                    numStars = 3;
                }
            }

            //creating the stars.
            for (var i = 0; i < numStars; i++)
            {
                if (i == 0)
                {
                    ourSystem.AddStar(Star.IsPrimary, Star.IsPrimary, i);

                    //manually set the first star's mass and push it to the max mass setting
                    ourSystem.SysStars[0].UpdateMass(RollStellarMass(ourBag, Star.IsPrimary));
                    ourSystem.MaxMass = ourSystem.SysStars[0].CurrMass;

                    //generate the star
                    GenerateAStar(ourSystem.SysStars[i], ourBag, ourSystem.MaxMass, ourSystem.SysName);
                }
                if (i == 1)
                {
                    ourSystem.AddStar(Star.IsSecondary, Star.IsPrimary, i);
                    //generate the star
                    GenerateAStar(ourSystem.SysStars[i], ourBag, ourSystem.MaxMass, ourSystem.SysName);
                }
                if (i == 2)
                {
                    ourSystem.AddStar(Star.IsTrinary, Star.IsPrimary, i);
                    //generate the star
                    GenerateAStar(ourSystem.SysStars[i], ourBag, ourSystem.MaxMass, ourSystem.SysName);
                }

                GasGiantFlag(ourSystem.SysStars[i], ourBag.GurpsRoll());
            }

            //now generate orbitals
            if (ourSystem.CountStars() > 1)
            {
                PlaceOurStars(ourSystem, ourBag);
            }
        }
Beispiel #2
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);
            }
        }