コード例 #1
0
            public RockyPlanet(byte planetId, string planetName, string description, StarSystem parentStarSystem, Star parentStar, float auFromParent)
            {
                Universe.PlanetCount++;
                Id           = planetId;
                Name         = planetName;
                Description  = description;
                ParentObject = parentStarSystem;
                AuFromParent = auFromParent;
                Moons        = new List <Moon>();
                ChildRings   = new List <Ring>();


                //Calculating Physical Properties
                Radius                = GenerateRadius();
                ResourcesPresent      = CalculateBodyResources();
                Volume                = CalculateVolume(Radius);                   //Calculating the volume based on the radius of the planet (assuming a spherical planet)
                AverageDensity        = CalculateAverageDensity(ResourcesPresent); //Based on resources present
                Mass                  = CalculateMass(Volume, AverageDensity);     //Calculates and stores the mass of the planet in Kilograms. Based on the individual elemental densities and their percentage of the total volume of the planet
                Gravity               = CalculateGravity(Mass, Radius);            //Based on the mass and radius in meters of the planet
                GeologicActivityLevel = CalculateGeologicalActivityLevel();
                LandmassRatio         = CalculateLandmassRatio();

                //Calculating Temperature and Radiation based properties
                SolarInsolation           = CalculateSolarInsolation(auFromParent, parentStar);
                BaseTemperature           = CalculateBaseTemperature(SolarInsolation);
                GreenhouseModifier        = CalculateGreenhouseMultiplier();
                AverageSurfaceTemperature = CalculateInitialSurfaceTemperature(BaseTemperature, GreenhouseModifier);

                //Calculating Resource dispersal and state  //Todo: Clean this up!!! Please!!! Seems redundant to pass the ResourcesByState object to the method only to place the passed object right back into itself. (objects are pass by reference...)
                ResourcesByState = CalculateResourceStates(ResourcesPresent, AverageSurfaceTemperature);
                ResourcesByState.Atmospherics = CalculateResourceAbundance(ResourcesByState.Atmospherics);
                ResourcesByState.Liquids      = CalculateResourceAbundance(ResourcesByState.Liquids);
                ResourcesByState.Solids       = CalculateResourceAbundance(ResourcesByState.Solids);

                //Calculating Biological properties
                FloraBioDiversity = CalulateBioDiversity();
                FaunaBioDiversity = CalulateBioDiversity();

                //Calculating the atmospheric density based off of the resources present.
                if (ResourcesByState.Atmospherics != null && ResourcesByState.Atmospherics.Count > 0)
                {
                    AtmosphericDensity = CalculateAtmosphericDensity(ResourcesByState.Atmospherics);
                }
                else
                {
                    AtmosphericDensity = 0;
                }

                GenerateMoons();
            }