コード例 #1
0
ファイル: Planet.cs プロジェクト: ebrand/MvcPatterns
 public Planet(int id, string name, PlanetClass planetClass, Point3D location)
 {
     this.Id          = id;
     this.Name        = name;
     this.PlanetClass = PlanetClass;
     this.Location    = location;
 }
コード例 #2
0
        private void ProcessScannedBody(string journalEntry)
        {
            JsonElement eventJson = JsonDocument.Parse(journalEntry).RootElement;

            int         bodyId    = eventJson.GetProperty("BodyID").GetInt32();
            float       distance  = eventJson.GetProperty("DistanceFromArrivalLS").GetSingle();
            PlanetClass bodyClass = PlanetClass.Icy;

            string bodyName = eventJson.GetProperty("BodyName").GetString()?.Replace(SystemName ?? "NOSYSTEM", string.Empty);

            if (eventJson.TryGetProperty("PlanetClass", out JsonElement jsonPlanetClass))
            {
                bodyClass = MapPlanetClass(jsonPlanetClass.GetString());
            }

            bool isTerraformable = false;

            if (eventJson.TryGetProperty("TerraformState", out JsonElement terraformOptional))
            {
                isTerraformable = terraformOptional.GetString() == "Terraformable";
            }

            if (isTerraformable || bodyClass == PlanetClass.EarthLike || bodyClass == PlanetClass.AmmoniaWorld || bodyClass == PlanetClass.WaterWorld)
            {
                AddSystemPoi(bodyId, bodyName, isTerraformable, bodyClass, (int)distance);
            }
        }
コード例 #3
0
        }                                            // One of Basic, Detailed, NavBeacon, NavBeaconDetail

        public BodyScannedEvent(DateTime timestamp, string scantype, string name, PlanetClass planetClass, decimal?earthmass, decimal?radiusKm, decimal gravity, decimal?temperatureKelvin, decimal?pressureAtm, bool?tidallylocked, bool?landable, AtmosphereClass atmosphereClass, List <AtmosphereComposition> atmosphereComposition, List <SolidComposition> solidCompositions, Volcanism volcanism, decimal distancefromarrival_Ls, decimal orbitalperiodDays, decimal rotationperiodDays, decimal?semimajoraxisAU, decimal?eccentricity, decimal?orbitalinclinationDegrees, decimal?periapsisDegrees, List <Ring> rings, string reserves, List <MaterialPresence> materials, TerraformState terraformstate, decimal?axialtiltDegrees) : base(timestamp, NAME)
        {
            this.scantype              = scantype;
            this.name                  = name;
            this.distancefromarrival   = distancefromarrival_Ls;
            this.planetClass           = planetClass;
            this.earthmass             = earthmass;
            this.radius                = radiusKm;
            this.gravity               = gravity;
            this.temperature           = temperatureKelvin;
            this.pressure              = pressureAtm;
            this.tidallylocked         = tidallylocked;
            this.landable              = landable;
            this.atmosphereclass       = atmosphereClass;
            this.atmospherecomposition = atmosphereComposition;
            this.solidcomposition      = solidCompositions;
            this.volcanism             = volcanism;
            this.orbitalperiod         = orbitalperiodDays;
            this.rotationperiod        = rotationperiodDays;
            this.semimajoraxis         = semimajoraxisAU;
            this.eccentricity          = eccentricity;
            this.orbitalinclination    = orbitalinclinationDegrees;
            this.periapsis             = periapsisDegrees;
            this.rings                 = rings;
            this.reserves              = reserves;
            this.materials             = materials;
            this.terraformState        = terraformstate;
            this.axialtilt             = axialtiltDegrees;
            this.estimatedvalue        = estimateValue(scantype == "Detailed" || scantype == "NavBeaconDetail");
        }
コード例 #4
0
        public Planet(PlanetClass pClass)
        {
            planetClass = pClass;

            CompileLua();
            SetPlanetClass(planetClass);
            GenerateLevel(0);
        }
コード例 #5
0
ファイル: Planet.cs プロジェクト: HTCGS/Game-of-Gods
    private void PlanetValues()
    {
        float index = Random.Range(0.0f, 1f);

        Data.Radius.RandomValue(index, Mathf.Lerp);
        index = Random.Range(0.0f, 1f);
        Data.Density.RandomValue(index, Mathf.Lerp);
        this.Class = Data.PlanetClass;
    }
コード例 #6
0
        private void InitializePlanetsClass()
        {
            var i = 0;

            for (; i < planetsClass.Length; i++)
            {
                planetsClass[i] = new PlanetClass();
            }
        }
コード例 #7
0
        private void AddSystemPoi(int bodyId, string bodyName, bool isTerraformble, PlanetClass planetClass, int distance)
        {
            if (!SystemPoiList.Any(item => item.BodyID == bodyId))
            {
                PlaySystemPoiFound(planetClass);

                SystemPoiList.Add(new SystemPoi()
                {
                    BodyID            = bodyId,
                    PlanetClass       = planetClass,
                    BodyName          = bodyName,
                    IsTerraformable   = isTerraformble,
                    SurfaceScanned    = false,
                    DistanceFromEntry = distance
                });
            }
        }
コード例 #8
0
ファイル: Satellite.cs プロジェクト: HTCGS/Game-of-Gods
    public void Create(float parentRadius)
    {
        PlanetClass satClass  = PlanetClass.Random;
        int         randClass = Random.Range(0, 3);

        if (randClass == 0)
        {
            satClass = PlanetClass.A;
        }
        if (randClass == 1)
        {
            satClass = PlanetClass.C;
        }
        if (randClass == 2)
        {
            satClass = PlanetClass.D;
        }
        Data             = PlanetData.GetData(satClass);
        Data.Radius.From = 10000f;
        if (parentRadius >= 15000000)
        {
            Data.Radius.To = 5000000f;
        }
        else if (parentRadius >= 5000000)
        {
            Data.Radius.To = 2000000f;
        }
        else
        {
            Data.Radius.To = 700000f;
        }
        float index = Random.Range(0.0f, 1f);

        Data.Radius.RandomValue(index, Mathf.Lerp);
        index = Random.Range(0.0f, 1f);
        Data.Density.RandomValue(index, Mathf.Lerp);
        Visualize();
    }
コード例 #9
0
        private void PlaySystemPoiFound(PlanetClass planetClass)
        {
            switch (planetClass)
            {
            case PlanetClass.AmmoniaWorld:
                Player.Open(new Uri($"{Environment.CurrentDirectory}/sounds/terraform.wav"));
                break;

            case PlanetClass.WaterWorld:
                Player.Open(new Uri($"{Environment.CurrentDirectory}/sounds/terraform.wav"));
                break;

            case PlanetClass.EarthLike:
                Player.Open(new Uri($"{Environment.CurrentDirectory}/sounds/terraform.wav"));
                break;

            default:
                Player.Open(new Uri($"{Environment.CurrentDirectory}/sounds/terraform.wav"));
                break;
            }

            Player.Play();
        }
コード例 #10
0
        private Body ParseStarMapBody(JObject body, string systemName)
        {
            // General items
            long?    bodyId            = (long?)body["bodyId"];
            long?    EDSMID            = (long?)body["id"];
            string   bodyname          = (string)body["name"];
            BodyType bodyType          = BodyType.FromName((string)body["type"]) ?? BodyType.None;
            decimal? distanceLs        = (decimal?)body["distanceToArrival"]; // Light Seconds
            decimal? temperatureKelvin = (long?)body["surfaceTemperature"];   // Kelvin

            // Orbital characteristics
            decimal?orbitalPeriodDays         = (decimal?)body["orbitalPeriod"];                           // Days
            decimal?semimajoraxisLs           = ConstantConverters.au2ls((decimal?)body["semiMajorAxis"]); // Light seconds
            decimal?eccentricity              = (decimal?)body["orbitalEccentricity"];
            decimal?orbitalInclinationDegrees = (decimal?)body["orbitalInclination"];                      // Degrees
            decimal?periapsisDegrees          = (decimal?)body["argOfPeriapsis"];                          // Degrees
            decimal?rotationPeriodDays        = (decimal?)body["rotationalPeriod"];                        // Days
            decimal?axialTiltDegrees          = (decimal?)body["axialTilt"];                               // Degrees

            List <IDictionary <string, object> > parents = new List <IDictionary <string, object> >();

            if (body["parents"] != null)
            {
                // Parent body types and IDs
                parents = body["parents"].ToObject <List <IDictionary <string, object> > >() ?? new List <IDictionary <string, object> >();
            }

            List <Ring> rings = new List <Ring>();

            if ((JArray)body["rings"] != null || (JArray)body["belts"] != null)
            {
                var ringsData = body["rings"] ?? body["belts"];
                if (ringsData != null)
                {
                    foreach (JObject ring in ringsData)
                    {
                        rings.Add(new Ring(
                                      (string)ring["name"],
                                      RingComposition.FromName((string)ring["type"]),
                                      (decimal)ring["mass"],
                                      (decimal)ring["innerRadius"],
                                      (decimal)ring["outerRadius"]
                                      ));
                    }
                }
            }

            if ((string)body["type"] == "Star")
            {
                // Star-specific items
                string stellarclass      = ((string)body["subType"]).Split(' ')[0]; // Splits "B (Blue-White) Star" to "B"
                int?   stellarsubclass   = null;
                string endOfStellarClass = stellarclass.ToCharArray().ElementAt(stellarclass.Length - 1).ToString();
                if (int.TryParse(endOfStellarClass, out int subclass))
                {
                    // If our stellarclass ends in a number, we need to separate the class from the subclass
                    stellarsubclass = subclass;
                    stellarclass    = stellarclass.Replace(endOfStellarClass, "");
                }

                long?   ageMegaYears      = (long?)body["age"]; // Age in megayears
                string  luminosityclass   = (string)body["luminosity"];
                decimal?absolutemagnitude = (decimal?)body["absoluteMagnitude"];
                decimal?stellarMass       = (decimal?)body["solarMasses"];
                decimal?solarradius       = (decimal?)body["solarRadius"];
                decimal radiusKm          = (decimal)(solarradius != null ? solarradius * Constants.solarRadiusMeters / 1000 : null);

                Body Body = new Body(bodyname, bodyId, parents, distanceLs, stellarclass, stellarsubclass, stellarMass,
                                     radiusKm, absolutemagnitude, ageMegaYears, temperatureKelvin, luminosityclass, semimajoraxisLs,
                                     eccentricity, orbitalInclinationDegrees, periapsisDegrees, orbitalPeriodDays, rotationPeriodDays,
                                     axialTiltDegrees, rings, true, false, systemName, null)
                {
                    EDSMID = EDSMID
                };
                DateTime updatedAt = JsonParsing.getDateTime("updateTime", body);
                Body.updatedat = updatedAt == null ? null : (long?)Dates.fromDateTimeToSeconds(updatedAt);

                return(Body);
            }

            if ((string)body["type"] == "Planet")
            {
                // Planet and moon specific items
                PlanetClass    planetClass    = PlanetClass.FromName((string)body["subType"]) ?? PlanetClass.None;
                bool?          tidallylocked  = (bool?)body["rotationalPeriodTidallyLocked"] ?? false;
                bool?          landable       = (bool?)body["isLandable"];
                decimal?       gravity        = (decimal?)body["gravity"]; // G's
                decimal?       earthmass      = (decimal?)body["earthMasses"];
                decimal?       radiusKm       = (decimal?)body["radius"];  // Kilometers
                TerraformState terraformState = TerraformState.FromName((string)body["terraformingState"]) ?? TerraformState.NotTerraformable;

                Volcanism volcanism = null;
                if ((string)body["volcanismType"] != null)
                {
                    volcanism = Volcanism.FromName((string)body["volcanismType"]);
                }

                List <AtmosphereComposition> atmosphereCompositions = new List <AtmosphereComposition>();
                if (body["atmosphereComposition"] is JObject)
                {
                    var compositions = body["atmosphereComposition"].ToObject <Dictionary <string, decimal?> >();

                    foreach (KeyValuePair <string, decimal?> compositionKV in compositions)
                    {
                        string  compositionName = compositionKV.Key;
                        decimal?share           = compositionKV.Value;
                        if (compositionName != null && share != null)
                        {
                            atmosphereCompositions.Add(new AtmosphereComposition(compositionName, (decimal)share));
                        }
                    }
                    if (atmosphereCompositions.Count > 0)
                    {
                        atmosphereCompositions = atmosphereCompositions.OrderByDescending(x => x.percent).ToList();
                    }
                }
                decimal?        pressureAtm     = (decimal?)body["surfacePressure"];
                AtmosphereClass atmosphereClass = null;
                if (((string)body["subType"]).Contains("gas giant") &&
                    (string)body["atmosphereType"] == "No atmosphere")
                {
                    // EDSM classifies any body with an empty string atmosphere property as "No atmosphere".
                    // However, gas giants also receive an empty string. Fix it, since gas giants have atmospheres.
                    atmosphereClass = AtmosphereClass.FromEDName("GasGiant");
                }
                else
                {
                    atmosphereClass = AtmosphereClass.FromName((string)body["atmosphereType"]);
                }

                List <SolidComposition> solidCompositions = new List <SolidComposition>();
                if (body["solidComposition"] is JObject)
                {
                    var compositions = body["solidComposition"].ToObject <Dictionary <string, decimal?> >();

                    foreach (KeyValuePair <string, decimal?> compositionKV in compositions)
                    {
                        string  composition = compositionKV.Key;
                        decimal?share       = compositionKV.Value;
                        if (composition != null && share != null)
                        {
                            solidCompositions.Add(new SolidComposition(composition, (decimal)share));
                        }
                    }
                    if (solidCompositions.Count > 0)
                    {
                        solidCompositions = solidCompositions.OrderByDescending(x => x.percent).ToList();
                    }
                }

                List <MaterialPresence> materials = new List <MaterialPresence>();
                if (body["materials"] is JObject)
                {
                    var materialsData = body["materials"].ToObject <Dictionary <string, decimal?> >();
                    foreach (KeyValuePair <string, decimal?> materialKV in materialsData)
                    {
                        Material material = Material.FromName(materialKV.Key);
                        decimal? amount   = materialKV.Value;
                        if (material != null && amount != null)
                        {
                            materials.Add(new MaterialPresence(material, (decimal)amount));
                        }
                    }
                    if (materials.Count > 0)
                    {
                        materials = materials.OrderByDescending(o => o.percentage).ToList();
                    }
                }
                ReserveLevel reserveLevel = ReserveLevel.FromName((string)body["reserveLevel"]) ?? ReserveLevel.None;

                DateTime updatedAt = JsonParsing.getDateTime("updateTime", body);
                Body     Body      = new Body(bodyname, bodyId, parents, distanceLs, tidallylocked, terraformState, planetClass, atmosphereClass, atmosphereCompositions, volcanism, earthmass, radiusKm, (decimal)gravity, temperatureKelvin, pressureAtm, landable, materials, solidCompositions, semimajoraxisLs, eccentricity, orbitalInclinationDegrees, periapsisDegrees, orbitalPeriodDays, rotationPeriodDays, axialTiltDegrees, rings, reserveLevel, true, true, systemName, null)
                {
                    EDSMID    = EDSMID,
                    updatedat = updatedAt == null ? null : (long?)Dates.fromDateTimeToSeconds(updatedAt)
                };

                return(Body);
            }


            return(null);
        }
コード例 #11
0
        public string DisplayString(int indent = 0, bool includefront = true, MaterialCommoditiesList historicmatlist = null, MaterialCommoditiesList currentmatlist = null)
        {
            string inds = new string(' ', indent);

            StringBuilder scanText = new StringBuilder();

            scanText.Append(inds);

            if (includefront)
            {
                scanText.AppendFormat("{0} {1}\n\n", BodyName, IsEDSMBody ? " (EDSM)" : "");

                if (IsStar)
                {
                    scanText.AppendFormat(GetStarTypeName());
                }
                else if (PlanetClass != null)
                {
                    scanText.AppendFormat("{0}", PlanetClass);

                    if (!PlanetClass.ToLower().Contains("gas"))
                    {
                        scanText.AppendFormat((Atmosphere == null || Atmosphere == String.Empty) ? ", No Atmosphere" : (", " + Atmosphere));
                    }
                }

                if (IsLandable)
                {
                    scanText.AppendFormat(", Landable");
                }

                scanText.AppendFormat("\n");

                if (HasAtmosphericComposition)
                {
                    scanText.Append("\n" + DisplayAtmosphere(2));
                }

                if (HasPlanetaryComposition)
                {
                    scanText.Append("\n" + DisplayComposition(2));
                }

                if (HasPlanetaryComposition || HasAtmosphericComposition)
                {
                    scanText.Append("\n\n");
                }

                if (nAge.HasValue)
                {
                    scanText.AppendFormat("Age: {0} million years\n", nAge.Value.ToString("N0"));
                }

                if (nStellarMass.HasValue)
                {
                    scanText.AppendFormat("Solar Masses: {0:0.00}\n", nStellarMass.Value);
                }

                if (nMassEM.HasValue)
                {
                    scanText.AppendFormat("Earth Masses: {0:0.0000}\n", nMassEM.Value);
                }

                if (nRadius.HasValue)
                {
                    if (IsStar)
                    {
                        scanText.AppendFormat("Solar Radius: {0:0.00} Sols\n", (nRadius.Value / solarRadius_m));
                    }
                    else
                    {
                        scanText.AppendFormat("Body Radius: {0:0.00}km\n", (nRadius.Value / 1000));
                    }
                }
            }

            if (nSurfaceTemperature.HasValue)
            {
                scanText.AppendFormat("Surface Temp: {0}K\n", nSurfaceTemperature.Value.ToString("N0"));
            }

            if (Luminosity != null)
            {
                scanText.AppendFormat("Luminosity: {0}\n", Luminosity);
            }

            if (nSurfaceGravity.HasValue)
            {
                scanText.AppendFormat("Gravity: {0:0.0}g\n", nSurfaceGravity.Value / oneGee_m_s2);
            }

            if (nSurfacePressure.HasValue && nSurfacePressure.Value > 0.00 && !PlanetClass.ToLower().Contains("gas"))
            {
                if (nSurfacePressure.Value > 1000)
                {
                    scanText.AppendFormat("Surface Pressure: {0} Atmospheres\n", (nSurfacePressure.Value / oneAtmosphere_Pa).ToString("N2"));
                }
                else
                {
                    { scanText.AppendFormat("Surface Pressure: {0} Pa\n", (nSurfacePressure.Value).ToString("N2")); }
                }
            }

            if (Volcanism != null)
            {
                scanText.AppendFormat("Volcanism: {0}\n", Volcanism == String.Empty ? "No Volcanism" : System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.
                                      ToTitleCase(Volcanism.ToLower()));
            }

            if (DistanceFromArrivalLS > 0)
            {
                scanText.AppendFormat("Distance from Arrival Point {0:N1}ls\n", DistanceFromArrivalLS);
            }

            if (nOrbitalPeriod.HasValue && nOrbitalPeriod > 0)
            {
                scanText.AppendFormat("Orbital Period: {0} days\n", (nOrbitalPeriod.Value / oneDay_s).ToString("N1"));
            }

            if (nSemiMajorAxis.HasValue)
            {
                if (IsStar || nSemiMajorAxis.Value > oneAU_m / 10)
                {
                    scanText.AppendFormat("Semi Major Axis: {0:0.00}AU\n", (nSemiMajorAxis.Value / oneAU_m));
                }
                else
                {
                    scanText.AppendFormat("Semi Major Axis: {0}km\n", (nSemiMajorAxis.Value / 1000).ToString("N1"));
                }
            }

            if (nEccentricity.HasValue)
            {
                scanText.AppendFormat("Orbital Eccentricity: {0:0.000}\n", nEccentricity.Value);
            }

            if (nOrbitalInclination.HasValue)
            {
                scanText.AppendFormat("Orbital Inclination: {0:0.000}°\n", nOrbitalInclination.Value);
            }

            if (nPeriapsis.HasValue)
            {
                scanText.AppendFormat("Arg Of Periapsis: {0:0.000}°\n", nPeriapsis.Value);
            }

            if (nAbsoluteMagnitude.HasValue)
            {
                scanText.AppendFormat("Absolute Magnitude: {0:0.00}\n", nAbsoluteMagnitude.Value);
            }

            if (nAxialTilt.HasValue)
            {
                scanText.AppendFormat("Axial tilt: {0:0.00}°\n", nAxialTilt.Value * 180.0 / Math.PI);
            }

            if (nRotationPeriod.HasValue)
            {
                scanText.AppendFormat("Rotation Period: {0} days\n", (nRotationPeriod.Value / oneDay_s).ToString("N1"));
            }

            if (nTidalLock.HasValue && nTidalLock.Value)
            {
                scanText.Append("Tidally locked\n");
            }

            if (Terraformable)
            {
                scanText.Append("Candidate for terraforming\n");
            }

            if (HasRings)
            {
                scanText.Append("\n");
                if (IsStar)
                {
                    scanText.AppendFormat("Belt{0}", Rings.Count() == 1 ? ":" : "s:");
                    for (int i = 0; i < Rings.Length; i++)
                    {
                        if (Rings[i].MassMT > (oneMoon_MT / 10000))
                        {
                            scanText.Append("\n" + RingInformation(i, 1.0 / oneMoon_MT, " Moons"));
                        }
                        else
                        {
                            scanText.Append("\n" + RingInformation(i));
                        }
                    }
                }
                else
                {
                    scanText.AppendFormat("Ring{0}", Rings.Count() == 1 ? ":" : "s:");

                    for (int i = 0; i < Rings.Length; i++)
                    {
                        scanText.Append("\n" + RingInformation(i));
                    }
                }
            }

            if (HasMaterials)
            {
                scanText.Append("\n" + DisplayMaterials(2, historicmatlist, currentmatlist) + "\n");
            }

            string habzonestring = HabZoneString();

            if (habzonestring != null)
            {
                scanText.Append("\n" + habzonestring);
            }

            if (scanText.Length > 0 && scanText[scanText.Length - 1] == '\n')
            {
                scanText.Remove(scanText.Length - 1, 1);
            }

            if (EstimatedValue > 0)
            {
                scanText.AppendFormat("\nEstimated value: {0:N0}", EstimatedValue);
            }

            if (EDSMDiscoveryCommander != null)
            {
                scanText.AppendFormat("\n\nDiscovered by " + EDSMDiscoveryCommander + " on " + EDSMDiscoveryUTC.ToStringZulu());
            }

            return(scanText.ToNullSafeString().Replace("\n", "\n" + inds));
        }
コード例 #12
0
        public JournalScan(JObject evt) : base(evt, JournalTypeEnum.Scan)
        {
            ScanType = evt["ScanType"].Str();
            BodyName = evt["BodyName"].Str();
            BodyID   = evt["BodyID"].IntNull();
            StarType = evt["StarType"].StrNull();

            DistanceFromArrivalLS = evt["DistanceFromArrivalLS"].Double();

            nAge               = evt["Age_MY"].DoubleNull();
            nStellarMass       = evt["StellarMass"].DoubleNull();
            nRadius            = evt["Radius"].DoubleNull();
            nAbsoluteMagnitude = evt["AbsoluteMagnitude"].DoubleNull();
            Luminosity         = evt["Luminosity"].StrNull();

            nRotationPeriod = evt["RotationPeriod"].DoubleNull();

            nOrbitalPeriod      = evt["OrbitalPeriod"].DoubleNull();
            nSemiMajorAxis      = evt["SemiMajorAxis"].DoubleNull();
            nEccentricity       = evt["Eccentricity"].DoubleNull();
            nOrbitalInclination = evt["OrbitalInclination"].DoubleNull();
            nPeriapsis          = evt["Periapsis"].DoubleNull();
            nAxialTilt          = evt["AxialTilt"].DoubleNull();

            Rings = evt["Rings"]?.ToObjectProtected <StarPlanetRing[]>(); // may be Null

            nTidalLock     = evt["TidalLock"].Bool();
            TerraformState = evt["TerraformState"].StrNull();
            if (TerraformState != null && TerraformState.Equals("Not Terraformable", StringComparison.InvariantCultureIgnoreCase)) // EDSM returns this, normalise to journal
            {
                TerraformState = String.Empty;
            }
            PlanetClass = evt["PlanetClass"].StrNull();

            Atmosphere = evt["Atmosphere"].StrNull();
            if (Atmosphere == null || Atmosphere.Length == 0)             // Earthlikes appear to have empty atmospheres but AtmosphereType
            {
                Atmosphere = evt["AtmosphereType"].StrNull();
            }
            if (Atmosphere != null)
            {
                Atmosphere = Atmosphere.SplitCapsWordFull();
            }

            AtmosphereID        = Bodies.AtmosphereStr2Enum(Atmosphere, out AtmosphereProperty);
            Volcanism           = evt["Volcanism"].StrNull();
            VolcanismID         = Bodies.VolcanismStr2Enum(Volcanism, out VolcanismProperty);
            nMassEM             = evt["MassEM"].DoubleNull();
            nSurfaceGravity     = evt["SurfaceGravity"].DoubleNull();
            nSurfaceTemperature = evt["SurfaceTemperature"].DoubleNull();
            nSurfacePressure    = evt["SurfacePressure"].DoubleNull();
            nLandable           = evt["Landable"].BoolNull();

            ReserveLevelStr = evt["ReserveLevel"].Str();

            if (IsStar)
            {
                StarTypeID = Bodies.StarStr2Enum(StarType);

                if (nRadius.HasValue && nSurfaceTemperature.HasValue)
                {
                    HabitableZoneInner = DistanceForBlackBodyTemperature(315);
                    HabitableZoneOuter = DistanceForBlackBodyTemperature(223);
                }
            }
            else if (PlanetClass != null)
            {
                PlanetTypeID = Bodies.PlanetStr2Enum(PlanetClass);
                // Fix naming to standard and fix case..
                PlanetClass = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.
                              ToTitleCase(PlanetClass.ToLower()).Replace("Ii ", "II ").Replace("Iv ", "IV ").Replace("Iii ", "III ");
            }
            else
            {
                PlanetTypeID = EDPlanet.Unknown;
            }

            JToken mats = (JToken)evt["Materials"];

            if (mats != null)
            {
                if (mats.Type == JTokenType.Object)
                {
                    Materials = mats?.ToObjectProtected <Dictionary <string, double> >();
                }
                else
                {
                    Materials = new Dictionary <string, double>();
                    foreach (JObject jo in mats)
                    {
                        Materials[(string)jo["Name"]] = jo["Percent"].Double();
                    }
                }
            }

            JToken atmos = (JToken)evt["AtmosphereComposition"];

            if (atmos != null)
            {
                if (atmos.Type == JTokenType.Object)
                {
                    AtmosphereComposition = atmos?.ToObjectProtected <Dictionary <string, double> >();
                }
                else
                {
                    AtmosphereComposition = new Dictionary <string, double>();
                    foreach (JObject jo in atmos)
                    {
                        AtmosphereComposition[(string)jo["Name"]] = jo["Percent"].Double();
                    }
                }
            }

            JToken composition = evt["Composition"];

            if (composition != null)
            {
                PlanetComposition = new Dictionary <string, double>();
                foreach (JProperty jp in composition)
                {
                    PlanetComposition[jp.Name] = (double)jp.Value;
                }
            }

            EstimatedValue = CalculateEstimatedValue();

            if (evt["Parents"] != null)
            {
                Parents = new List <BodyParent>();
                foreach (JObject parent in evt["Parents"])
                {
                    JProperty prop = parent.Properties().First();
                    Parents.Add(new BodyParent {
                        Type = prop.Name, BodyID = prop.Value.Int()
                    });
                }
            }

            // EDSM bodies fields

            IsEDSMBody = evt["EDDFromEDSMBodie"].Bool(false);           // Bodie? Who is bodie?  Did you mean Body Finwen ;-)

            JToken discovery = evt["discovery"];

            if (discovery != null)
            {
                EDSMDiscoveryCommander = discovery["commander"].StrNull();
                EDSMDiscoveryUTC       = discovery["date"].DateTimeUTC();
            }
        }
コード例 #13
0
ファイル: EddbBodyData.cs プロジェクト: rekrapt/EDDI
        private static Body ParseEddbBody(object response)
        {
            JObject bodyJson = ((JObject)response);

            Body Body = new Body
            {
                // General items
                EDDBID       = (long)bodyJson["id"],
                updatedat    = (long)(Dates.fromDateTimeStringToSeconds((string)bodyJson["updated_at"])),
                name         = (string)bodyJson["name"],
                Type         = BodyType.FromEDName((string)bodyJson["group_name"]),
                systemEDDBID = (long)bodyJson["system_id"],

                // Orbital data
                distance         = (decimal?)bodyJson["distance_to_arrival"],                                // Light seconds
                temperature      = (decimal?)bodyJson["surface_temperature"],                                //Kelvin
                tidallylocked    = (bool?)bodyJson["is_rotational_period_tidally_locked"] ?? false,          // Days
                rotationalperiod = (decimal?)(double?)bodyJson["rotational_period"],                         // Days
                tilt             = (decimal?)(double?)bodyJson["axis_tilt"],                                 // Degrees
                semimajoraxis    = ConstantConverters.au2ls((decimal?)(double?)bodyJson["semi_major_axis"]), // Light Seconds
                orbitalperiod    = (decimal?)(double?)bodyJson["orbital_period"],                            // Days
                periapsis        = (decimal?)(double?)bodyJson["arg_of_periapsis"],                          // Degrees
                eccentricity     = (decimal?)(double?)bodyJson["orbital_eccentricity"],
                inclination      = (decimal?)(double?)bodyJson["orbital_inclination"]                        // Degrees
            };

            if ((string)bodyJson["group_name"] == "belt")
            {
                // Not interested in asteroid belts,
                // no need to add additional information at this time.
            }

            else if ((string)bodyJson["group_name"] == "star")
            {
                // Star-specific items
                Body.stellarclass    = ((string)bodyJson["spectral_class"])?.ToUpperInvariant();
                Body.luminosityclass = ((string)bodyJson["luminosity_class"])?.ToUpperInvariant();
                Body.solarmass       = (decimal?)(double?)bodyJson["solar_masses"];
                Body.solarradius     = (decimal?)(double?)bodyJson["solar_radius"];
                Body.age             = (long?)bodyJson["age"]; // MegaYears
                Body.mainstar        = (bool?)bodyJson["is_main_star"];
                Body.landable        = false;
                Body.setStellarExtras();
            }

            else if ((string)bodyJson["group_name"] == "planet")
            {
                // Planet-specific items
                Body.planetClass    = PlanetClass.FromEDName((string)bodyJson["type_name"]);
                Body.landable       = (bool?)bodyJson["is_landable"] ?? false;
                Body.earthmass      = (decimal?)(double?)bodyJson["earth_masses"];
                Body.gravity        = (decimal?)(double?)bodyJson["gravity"]; // G's
                Body.radius         = (decimal?)bodyJson["radius"];           // Kilometers
                Body.pressure       = (decimal?)(double?)bodyJson["surface_pressure"] ?? 0;
                Body.terraformState = TerraformState.FromName((string)bodyJson["terraforming_state_name"]);
                // Per Themroc @ EDDB, "Major" and "Minor" volcanism descriptors are stripped from EDDB data.
                Body.volcanism       = Volcanism.FromName((string)bodyJson["volcanism_type_name"]);
                Body.atmosphereclass = AtmosphereClass.FromName((string)bodyJson["atmosphere_type_name"]);
                if (bodyJson["atmosphere_composition"] != null)
                {
                    List <AtmosphereComposition> atmosphereCompositions = new List <AtmosphereComposition>();
                    foreach (JObject atmoJson in bodyJson["atmosphere_composition"])
                    {
                        string  composition = (string)atmoJson["atmosphere_component_name"];
                        decimal?share       = (decimal?)atmoJson["share"];
                        if (composition != null && share != null)
                        {
                            atmosphereCompositions.Add(new AtmosphereComposition(composition, (decimal)share));
                        }
                    }
                    if (atmosphereCompositions.Count > 0)
                    {
                        atmosphereCompositions      = atmosphereCompositions.OrderByDescending(x => x.percent).ToList();
                        Body.atmospherecompositions = atmosphereCompositions;
                    }
                }
                if (bodyJson["solid_composition"] != null)
                {
                    List <SolidComposition> bodyCompositions = new List <SolidComposition>();
                    foreach (JObject bodyCompJson in bodyJson["solid_composition"])
                    {
                        string  composition = (string)bodyCompJson["solid_component_name"];
                        decimal?share       = (decimal?)bodyCompJson["share"];
                        if (composition != null && share != null)
                        {
                            bodyCompositions.Add(new SolidComposition(composition, (decimal)share));
                        }
                    }
                    if (bodyCompositions.Count > 0)
                    {
                        bodyCompositions       = bodyCompositions.OrderByDescending(x => x.percent).ToList();
                        Body.solidcompositions = bodyCompositions;
                    }
                }
                if (bodyJson["materials"] != null)
                {
                    List <MaterialPresence> Materials = new List <MaterialPresence>();
                    foreach (JObject materialJson in bodyJson["materials"])
                    {
                        Material material = Material.FromEDName((string)materialJson["material_name"]);
                        decimal? amount   = (decimal?)(double?)materialJson["share"];
                        if (material != null && amount != null)
                        {
                            Materials.Add(new MaterialPresence(material, (decimal)amount));
                        }
                    }
                    if (Materials.Count > 0)
                    {
                        Body.materials = Materials.OrderByDescending(o => o.percentage).ToList();
                    }
                }
            }

            // Rings may be an object or may be a singular
            List <Ring> rings = new List <Ring>();

            if (bodyJson["rings"] != null)
            {
                foreach (JObject ringJson in bodyJson["rings"])
                {
                    string          name             = (string)ringJson["name"];
                    RingComposition composition      = RingComposition.FromName((string)ringJson["ring_type_name"]);
                    decimal         ringMassMegaTons = (decimal)ringJson["ring_mass"];
                    decimal         innerRadiusKm    = (decimal)ringJson["ring_inner_radius"];
                    decimal         outerRadiusKm    = (decimal)ringJson["ring_outer_radius"];
                    Ring            ring             = new Ring(name, composition, ringMassMegaTons, innerRadiusKm, outerRadiusKm);
                    rings.Add(ring);
                }
            }
            if (bodyJson["ring_type_name"].HasValues)
            {
                string          name             = (string)bodyJson["name"];
                RingComposition composition      = RingComposition.FromName((string)bodyJson["ring_type_name"]);
                decimal         ringMassMegaTons = (decimal)bodyJson["ring_mass"];
                decimal         innerRadiusKm    = (decimal)bodyJson["ring_inner_radius"];
                decimal         outerRadiusKm    = (decimal)bodyJson["ring_outer_radius"];
                Ring            ring             = new Ring(name, composition, ringMassMegaTons, innerRadiusKm, outerRadiusKm);
                rings.Add(ring);
            }
            if (rings.Count > 0)
            {
                Body.rings = rings.OrderBy(o => o.innerradius).ToList();
            }

            return(Body);
        }
コード例 #14
0
ファイル: EdsmBodyData.cs プロジェクト: williamrice/EDDI
        private static Body ParseStarMapBody(JObject body, string system)
        {
            Body Body = new Body
            {
                // General items
                EDSMID      = (long?)body["id"],
                name        = (string)body["name"],
                systemname  = system,
                Type        = BodyType.FromName((string)body["type"]) ?? BodyType.None,
                distance    = (decimal?)body["distanceToArrival"], // Light Seconds
                temperature = (long?)body["surfaceTemperature"],   // Kelvin

                // Orbital characteristics
                orbitalperiod    = (decimal?)body["orbitalPeriod"],                           // Days
                semimajoraxis    = ConstantConverters.au2ls((decimal?)body["semiMajorAxis"]), // Light seconds
                eccentricity     = (decimal?)body["orbitalEccentricity"],
                inclination      = (decimal?)body["orbitalInclination"],                      // Degrees
                periapsis        = (decimal?)body["argOfPeriapsis"],                          // Degrees
                rotationalperiod = (decimal?)body["rotationalPeriod"],                        // Days
                tidallylocked    = (bool?)body["rotationalPeriodTidallyLocked"] ?? false,
                tilt             = (decimal?)body["axialTilt"]                                // Degrees
            };

            if ((string)body["type"] == "Belt")
            {
                // Not interested in asteroid belts,
                // no need to add additional information at this time.
            }

            if ((string)body["type"] == "Star")
            {
                // Star-specific items
                Body.stellarclass      = ((string)body["subType"]).Split(' ')[0]; // Splits "B (Blue-White) Star" to "B"
                Body.mainstar          = (bool?)body["isMainStar"];
                Body.age               = (long?)body["age"];                      // Age in megayears
                Body.luminosityclass   = (string)body["luminosity"];
                Body.absoluteMagnitude = (decimal?)body["absoluteMagnitude"];
                Body.solarmass         = (decimal?)body["solarMasses"];
                Body.solarradius       = (decimal?)body["solarRadius"];
                Body.landable          = false;
                Body.setStellarExtras();
            }

            if ((string)body["type"] == "Planet")
            {
                // Planet-specific items
                Body.planetClass    = PlanetClass.FromName((string)body["subType"]) ?? PlanetClass.None;
                Body.landable       = (bool?)body["isLandable"];
                Body.gravity        = (decimal?)body["gravity"]; // G's
                Body.earthmass      = (decimal?)body["earthMasses"];
                Body.radius         = (decimal?)body["radius"];  // Kilometers
                Body.terraformState = TerraformState.FromName((string)body["terraformingState"]) ?? TerraformState.NotTerraformable;
                if ((string)body["volcanismType"] != null)
                {
                    Body.volcanism = Volcanism.FromName((string)body["volcanismType"]);
                }

                if (body["atmosphereComposition"] is JObject)
                {
                    List <AtmosphereComposition> atmosphereCompositions = new List <AtmosphereComposition>();
                    var compositions = body["atmosphereComposition"].ToObject <Dictionary <string, decimal?> >();

                    foreach (KeyValuePair <string, decimal?> compositionKV in compositions)
                    {
                        string  compositionName = compositionKV.Key;
                        decimal?share           = compositionKV.Value;
                        if (compositionName != null && share != null)
                        {
                            atmosphereCompositions.Add(new AtmosphereComposition(compositionName, (decimal)share));
                        }
                    }
                    if (atmosphereCompositions.Count > 0)
                    {
                        atmosphereCompositions      = atmosphereCompositions.OrderByDescending(x => x.percent).ToList();
                        Body.atmospherecompositions = atmosphereCompositions;
                    }
                }
                Body.pressure = (decimal?)body["surfacePressure"];
                if (((string)body["subType"]).Contains("gas giant") &&
                    (string)body["atmosphereType"] == "No atmosphere")
                {
                    // EDSM classifies any body with an empty string atmosphere property as "No atmosphere".
                    // However, gas giants also receive an empty string. Fix it, since gas giants have atmospheres.
                    Body.atmosphereclass = AtmosphereClass.FromEDName("GasGiant");
                }
                else
                {
                    Body.atmosphereclass = AtmosphereClass.FromName((string)body["atmosphereType"]);
                }

                if (body["solidComposition"] is JObject)
                {
                    List <SolidComposition> bodyCompositions = new List <SolidComposition>();
                    var compositions = body["solidComposition"].ToObject <Dictionary <string, decimal?> >();

                    foreach (KeyValuePair <string, decimal?> compositionKV in compositions)
                    {
                        string  composition = compositionKV.Key;
                        decimal?share       = compositionKV.Value;
                        if (composition != null && share != null)
                        {
                            bodyCompositions.Add(new SolidComposition(composition, (decimal)share));
                        }
                    }
                    if (bodyCompositions.Count > 0)
                    {
                        bodyCompositions       = bodyCompositions.OrderByDescending(x => x.percent).ToList();
                        Body.solidcompositions = bodyCompositions;
                    }
                }

                if (body["materials"] is JObject)
                {
                    List <MaterialPresence> Materials = new List <MaterialPresence>();
                    var materials = body["materials"].ToObject <Dictionary <string, decimal?> >();
                    foreach (KeyValuePair <string, decimal?> materialKV in materials)
                    {
                        Material material = Material.FromName(materialKV.Key);
                        decimal? amount   = materialKV.Value;
                        if (material != null && amount != null)
                        {
                            Materials.Add(new MaterialPresence(material, (decimal)amount));
                        }
                    }
                    if (Materials.Count > 0)
                    {
                        Body.materials = Materials.OrderByDescending(o => o.percentage).ToList();
                    }
                }
            }

            if ((JArray)body["rings"] != null || (JArray)body["belts"] != null)
            {
                var rings = body["rings"] ?? body["belts"];
                if (rings != null)
                {
                    List <Ring> Rings = new List <Ring>();
                    foreach (JObject ring in rings)
                    {
                        Rings.Add(new Ring(
                                      (string)ring["name"],
                                      RingComposition.FromName((string)ring["type"]),
                                      (decimal)ring["mass"],
                                      (decimal)ring["innerRadius"],
                                      (decimal)ring["outerRadius"]
                                      ));
                    }
                    Body.rings = Rings;
                }
            }
            Body.reserveLevel = ReserveLevel.FromName((string)body["reserveLevel"]) ?? ReserveLevel.None;

            DateTime updatedAt = DateTime.SpecifyKind(DateTime.Parse((string)body["updateTime"]), DateTimeKind.Utc);

            Body.updatedat = updatedAt == null ? null : (long?)(updatedAt.Subtract(new DateTime(1970, 1, 1, 0, 0, 0))).TotalSeconds;

            return(Body);
        }
コード例 #15
0
 public void EDSMPlanetClassAliases(string edsmName, string expectedInvariantName)
 {
     Assert.AreEqual(expectedInvariantName, PlanetClass.FromName(edsmName)?.invariantName);
 }
コード例 #16
0
        private void SetPlanetClass(PlanetClass p_class)
        {
            planetClass    = p_class;
            planetMap      = new PlanetMap();
            entities       = new List <Entity.BaseGameEntity>();
            entityParticle = new Systems.ParticleSystem(500);
            bulletManager  = new Systems.BulletManager(500);

            switch (p_class)
            {
            case PlanetClass.ClassA:
            {
                cellSpacePartition = new Systems.CellSpacePartition((int)(double)lua["ClassA.Width"], (int)(double)lua["ClassA.Height"], 4);
                tilePartition      = new Systems.CellSpacePartition((int)(double)lua["ClassA.Width"], (int)(double)lua["ClassA.Height"], 4);
                mapGenerator       = new MapGenerator(
                    (int)(double)lua["ClassA.Width"],
                    (int)(double)lua["ClassA.Height"],
                    (int)(double)lua["ClassA.MaxRooms"],
                    (int)(double)lua["ClassA.RoomMaxSize"],
                    (int)(double)lua["ClassA.RoomMinSize"]);
                planetMap = mapGenerator.CreateMap();
                break;
            }

            case PlanetClass.ClassB:
            {
                cellSpacePartition = new Systems.CellSpacePartition((int)(double)lua["ClassB.Width"], (int)(double)lua["ClassB.Height"], 4);
                tilePartition      = new Systems.CellSpacePartition((int)(double)lua["ClassB.Width"], (int)(double)lua["ClassB.Height"], 4);
                mapGenerator       = new MapGenerator(
                    (int)(double)lua["ClassB.Width"],
                    (int)(double)lua["ClassB.Height"],
                    (int)(double)lua["ClassB.MaxRooms"],
                    (int)(double)lua["ClassB.RoomMaxSize"],
                    (int)(double)lua["ClassB.RoomMinSize"]);
                planetMap = mapGenerator.CreateMap();
                break;
            }

            case PlanetClass.ClassC:
            {
                cellSpacePartition = new Systems.CellSpacePartition((int)(double)lua["ClassC.Width"], (int)(double)lua["ClassC.Height"], 4);
                tilePartition      = new Systems.CellSpacePartition((int)(double)lua["ClassC.Width"], (int)(double)lua["ClassC.Height"], 4);
                mapGenerator       = new MapGenerator(
                    (int)(double)lua["ClassC.Width"],
                    (int)(double)lua["ClassC.Height"],
                    (int)(double)lua["ClassC.MaxRooms"],
                    (int)(double)lua["ClassC.RoomMaxSize"],
                    (int)(double)lua["ClassC.RoomMinSize"]);
                planetMap = mapGenerator.CreateMap();
                break;
            }

            case PlanetClass.ClassD:
            {
                cellSpacePartition = new Systems.CellSpacePartition((int)(double)lua["ClassD.Width"], (int)(double)lua["ClassD.Height"], 4);
                tilePartition      = new Systems.CellSpacePartition((int)(double)lua["ClassD.Width"], (int)(double)lua["ClassD.Height"], 4);
                mapGenerator       = new MapGenerator(
                    (int)(double)lua["ClassD.Width"],
                    (int)(double)lua["ClassD.Height"],
                    (int)(double)lua["ClassD.MaxRooms"],
                    (int)(double)lua["ClassD.RoomMaxSize"],
                    (int)(double)lua["ClassD.RoomMinSize"]);
                planetMap = mapGenerator.CreateMap();
                break;
            }
            }

            for (int y = 0; y < planetMap.tilemap.GetLength(1); y++)
            {
                for (int x = 0; x < planetMap.tilemap.GetLength(0); x++)
                {
                    tilePartition.AddEntity(new Entity.Tile(new Vector2(x * 128, y * 128), planetMap.tilemap[x, y]));
                }
            }

            lua.DoFile("Scripts/Planets/Generation.lua");
        }
コード例 #17
0
        public System.Drawing.Image GetPlanetClassImage()
        {
            if (PlanetClass == null)
            {
                return(EliteDangerous.Properties.Resources.Globe);
            }

            string name = PlanetClass.ToLower();

            if (name.Contains("gas"))
            {
                if (name.Contains("helium"))
                {
                    return(EliteDangerous.Properties.Resources.Helium_Rich_Gas_Giant1);
                }
                else if (name.Contains("water"))
                {
                    return(EliteDangerous.Properties.Resources.Gas_giant_water_based_life_Brown3);
                }
                else if (name.Contains("ammonia"))
                {
                    return(EliteDangerous.Properties.Resources.Gas_giant_ammonia_based_life1);
                }
                else if (name.Contains("iv"))
                {
                    return(EliteDangerous.Properties.Resources.Class_I_Gas_Giant_Brown2);               // MISSING.
                }
                else if (name.Contains("iii"))
                {
                    return(EliteDangerous.Properties.Resources.Class_III_Gas_Giant_Blue3);
                }
                else if (name.Contains("ii"))
                {
                    return(EliteDangerous.Properties.Resources.Class_II_Gas_Giant_Sand1);
                }
                else if (name.Contains("v"))
                {
                    return(EliteDangerous.Properties.Resources.Class_I_Gas_Giant_Brown2);               // MISSING.
                }
                else
                {
                    return(EliteDangerous.Properties.Resources.Class_I_Gas_Giant_Brown2);
                }
            }
            else if (name.Contains("ammonia"))
            {
                return(EliteDangerous.Properties.Resources.Ammonia_Brown);      // also have orange.
            }
            else if (name.Contains("earth"))
            {
                return(EliteDangerous.Properties.Resources.Earth_Like_Standard);
            }
            else if (name.Contains("ice"))
            {
                return(EliteDangerous.Properties.Resources.Rocky_Ice_World_Sol_Titan);
            }
            else if (name.Contains("icy"))
            {
                return(EliteDangerous.Properties.Resources.Icy_Body_Greenish1);
            }
            else if (name.Contains("water"))
            {
                if (name.Contains("giant"))
                {
                    return(EliteDangerous.Properties.Resources.Water_Giant1);
                }
                else
                {
                    return(EliteDangerous.Properties.Resources.Water_World_Poles_Cloudless4);
                }
            }
            else if (name.Contains("metal"))
            {
                if (AtmosphereProperty == (EDAtmosphereProperty.Hot | EDAtmosphereProperty.Thick))
                {
                    return(EliteDangerous.Properties.Resources.High_metal_content_world_White3);
                }

                if (name.Contains("rich"))
                {
                    return(EliteDangerous.Properties.Resources.metal_rich);
                }
                else if (nSurfaceTemperature > 700)
                {
                    return(EliteDangerous.Properties.Resources.High_metal_content_world_Lava1);
                }
                else if (nSurfaceTemperature > 250)
                {
                    return(EliteDangerous.Properties.Resources.High_metal_content_world_Mix3);
                }
                else
                {
                    return(EliteDangerous.Properties.Resources.High_metal_content_world_Orange8);
                }
            }
            else if (name.Contains("rocky"))
            {
                return(EliteDangerous.Properties.Resources.Rocky_Body_Sand2);
            }
            else
            {
                return(EliteDangerous.Properties.Resources.Globe);
            }
        }
コード例 #18
0
ファイル: PlanetData.cs プロジェクト: HTCGS/Game-of-Gods
        public static PlanetData GetData(PlanetClass planetClass)
        {
            switch (planetClass)
            {
            case PlanetClass.Random:
                return(GetData());

            case PlanetClass.A:
                return(PlanetData.A);

            case PlanetClass.B:
                return(PlanetData.B);

            case PlanetClass.C:
                return(PlanetData.C);

            case PlanetClass.D:
                return(PlanetData.D);

            case PlanetClass.E:
                return(PlanetData.E);

            case PlanetClass.F:
                return(PlanetData.F);

            case PlanetClass.G:
                return(PlanetData.G);

            case PlanetClass.H:
                return(PlanetData.H);

            case PlanetClass.I:
                return(PlanetData.I);

            case PlanetClass.J:
                return(PlanetData.J);

            case PlanetClass.K:
                return(PlanetData.K);

            case PlanetClass.L:
                return(PlanetData.L);

            case PlanetClass.M:
                return(PlanetData.M);

            case PlanetClass.N:
                return(PlanetData.N);

            case PlanetClass.O:
                return(PlanetData.O);

            case PlanetClass.P:
                return(PlanetData.P);

            case PlanetClass.Q:
                return(PlanetData.Q);

            case PlanetClass.S:
                return(PlanetData.S);

            case PlanetClass.X:
                return(PlanetData.X);

            case PlanetClass.Y:
                return(PlanetData.Y);

            default:
                break;
            }
            return(null);
        }
コード例 #19
0
ファイル: PlanetData.cs プロジェクト: HTCGS/Game-of-Gods
        public static PlanetData GetData()
        {
            PlanetClass planetClass = (PlanetClass)Random.Range(1, 21);

            return(GetData(planetClass));
        }
コード例 #20
0
        public string DisplayString(int indent = 0, bool includefront = true)
        {
            string inds = new string(' ', indent);

            StringBuilder scanText = new StringBuilder();

            scanText.Append(inds);

            if (includefront)
            {
                scanText.AppendFormat("{0}\n\n", BodyName);

                if (IsStar)
                {
                    scanText.AppendFormat(GetStarTypeImage().Item2);
                }
                else if (PlanetClass != null)
                {
                    scanText.AppendFormat("{0}", PlanetClass);

                    if (!PlanetClass.ToLower().Contains("gas"))
                    {
                        scanText.AppendFormat((Atmosphere == null || Atmosphere == String.Empty) ? ", No Atmosphere" : (", " + Atmosphere));
                    }
                }

                if (IsLandable)
                {
                    scanText.AppendFormat(", Landable");
                }

                scanText.AppendFormat("\n");

                if (nAge.HasValue)
                {
                    scanText.AppendFormat("Age: {0} million years\n", nAge.Value.ToString("N0"));
                }

                if (nStellarMass.HasValue)
                {
                    scanText.AppendFormat("Solar Masses: {0:0.00}\n", nStellarMass.Value);
                }

                if (nMassEM.HasValue)
                {
                    scanText.AppendFormat("Earth Masses: {0:0.0000}\n", nMassEM.Value);
                }

                if (nRadius.HasValue)
                {
                    if (IsStar)
                    {
                        scanText.AppendFormat("Solar Radius: {0:0.00} Sols\n", (nRadius.Value / solarRadius_m));
                    }
                    else
                    {
                        scanText.AppendFormat("Body Radius: {0:0.00}km\n", (nRadius.Value / 1000));
                    }
                }
            }

            if (nSurfaceTemperature.HasValue)
            {
                scanText.AppendFormat("Surface Temp: {0}K\n", nSurfaceTemperature.Value.ToString("N0"));
            }

            if (nSurfaceGravity.HasValue)
            {
                scanText.AppendFormat("Gravity: {0:0.0}g\n", nSurfaceGravity.Value / 9.8);
            }

            if (nSurfacePressure.HasValue && nSurfacePressure.Value > 0.00 && !PlanetClass.ToLower().Contains("gas"))
            {
                if (nSurfacePressure.Value > 1000)
                {
                    scanText.AppendFormat("Surface Pressure: {0} Atmospheres\n", (nSurfacePressure.Value / 100000).ToString("N2"));
                }
                else
                {
                    { scanText.AppendFormat("Surface Pressure: {0} Pa\n", (nSurfacePressure.Value).ToString("N2")); }
                }
            }

            if (Volcanism != null)
            {
                scanText.AppendFormat("Volcanism: {0}\n", Volcanism == String.Empty ? "No Volcanism" : System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.
                                      ToTitleCase(Volcanism.ToLower()));
            }

            if (DistanceFromArrivalLS > 0)
            {
                scanText.AppendFormat("Distance from Arrival Point {0:N1}ls\n", DistanceFromArrivalLS);
            }

            if (nOrbitalPeriod.HasValue && nOrbitalPeriod > 0)
            {
                scanText.AppendFormat("Orbital Period: {0} days\n", (nOrbitalPeriod.Value / oneDay_s).ToString("N1"));
            }

            if (nSemiMajorAxis.HasValue)
            {
                if (IsStar || nSemiMajorAxis.Value > oneAU_m / 10)
                {
                    scanText.AppendFormat("Semi Major Axis: {0:0.00}AU\n", (nSemiMajorAxis.Value / oneAU_m));
                }
                else
                {
                    scanText.AppendFormat("Semi Major Axis: {0}km\n", (nSemiMajorAxis.Value / 1000).ToString("N1"));
                }
            }

            if (nEccentricity.HasValue)
            {
                scanText.AppendFormat("Orbital Eccentricity: {0:0.000}°\n", nEccentricity.Value);
            }

            if (nOrbitalInclination.HasValue)
            {
                scanText.AppendFormat("Orbital Inclination: {0:0.000}°\n", nOrbitalInclination.Value);
            }

            if (nPeriapsis.HasValue)
            {
                scanText.AppendFormat("Arg Of Periapsis: {0:0.000}°\n", nPeriapsis.Value);
            }

            if (nAbsoluteMagnitude.HasValue)
            {
                scanText.AppendFormat("Absolute Magnitude: {0:0.00}\n", nAbsoluteMagnitude.Value);
            }

            if (nRotationPeriod.HasValue)
            {
                scanText.AppendFormat("Rotation Period: {0} days\n", (nRotationPeriod.Value / oneDay_s).ToString("N1"));
            }

            if (nTidalLock.HasValue && nTidalLock.Value)
            {
                scanText.Append("Tidally locked\n");
            }

            if (TerraformState != null && TerraformState == "Terraformable")
            {
                scanText.Append("Candidate for terraforming\n");
            }

            if (HasRings)
            {
                scanText.Append("\n");
                if (IsStar)
                {
                    scanText.AppendFormat("Belt{0}", Rings.Count() == 1 ? ":" : "s:");
                    for (int i = 0; i < Rings.Length; i++)
                    {
                        if (Rings[i].MassMT > 7342000000)
                        {
                            scanText.Append("\n" + RingInformation(i, 1.0 / oneMoon_MT, " Moons"));
                        }
                        else
                        {
                            scanText.Append("\n" + RingInformation(i));
                        }
                    }
                }
                else
                {
                    scanText.AppendFormat("Ring{0}", Rings.Count() == 1 ? ":" : "s:");
                    for (int i = 0; i < Rings.Length; i++)
                    {
                        scanText.Append("\n" + RingInformation(i));
                    }
                }
            }

            if (HasMaterials)
            {
                scanText.Append("\n" + DisplayMaterials(2) + "\n");
            }

            if (IsStar && HabitableZoneInner.HasValue && HabitableZoneOuter.HasValue)
            {
                StringBuilder habZone = new StringBuilder();
                habZone.AppendFormat("Habitable Zone Approx. {0}ls to {1}ls\n", HabitableZoneInner.Value.ToString("N0"), HabitableZoneOuter.Value.ToString("N0"));
                if (nSemiMajorAxis.HasValue && nSemiMajorAxis.Value > 0)
                {
                    habZone.AppendFormat(" (This star only, others not considered)\n");
                }
                scanText.Append("\n" + habZone);
            }

            if (scanText.Length > 0 && scanText[scanText.Length - 1] == '\n')
            {
                scanText.Remove(scanText.Length - 1, 1);
            }


            int estvalue = EstimatedValue();

            if (estvalue > 0)
            {
                scanText.AppendFormat("\nEstimated value: {0}", estvalue);
            }

            return(scanText.ToNullSafeString().Replace("\n", "\n" + inds));
        }
コード例 #21
0
        public JournalScan(JObject evt) : base(evt, JournalTypeEnum.Scan)
        {
            BodyName = evt["BodyName"].Str();
            StarType = evt["StarType"].StrNull();

            DistanceFromArrivalLS = evt["DistanceFromArrivalLS"].Double();

            nAge               = evt["Age_MY"].DoubleNull();
            nStellarMass       = evt["StellarMass"].DoubleNull();
            nRadius            = evt["Radius"].DoubleNull();
            nAbsoluteMagnitude = evt["AbsoluteMagnitude"].DoubleNull();
            nRotationPeriod    = evt["RotationPeriod"].DoubleNull();

            nOrbitalPeriod      = evt["OrbitalPeriod"].DoubleNull();
            nSemiMajorAxis      = evt["SemiMajorAxis"].DoubleNull();
            nEccentricity       = evt["Eccentricity"].DoubleNull();
            nOrbitalInclination = evt["OrbitalInclination"].DoubleNull();
            nPeriapsis          = evt["Periapsis"].DoubleNull();

            Rings = evt["Rings"]?.ToObject <StarPlanetRing[]>();

            nTidalLock     = evt["TidalLock"].Bool();
            TerraformState = evt["TerraformState"].StrNull();
            if (TerraformState != null && TerraformState.Equals("Not Terraformable", StringComparison.InvariantCultureIgnoreCase)) // EDSM returns this, normalise to journal
            {
                TerraformState = String.Empty;
            }
            PlanetClass = evt["PlanetClass"].StrNull();

            Atmosphere = evt["Atmosphere"].StrNull();
            if (Atmosphere == null || Atmosphere.Length == 0)             // Earthlikes appear to have empty atmospheres but AtmosphereType
            {
                Atmosphere = evt["AtmosphereType"].StrNull();
            }
            if (Atmosphere != null)
            {
                Atmosphere = Atmosphere.SplitCapsWordFull();
            }

            AtmosphereID        = Bodies.AtmosphereStr2Enum(Atmosphere, out AtmosphereProperty);
            Volcanism           = evt["Volcanism"].StrNull();
            VolcanismID         = Bodies.VolcanismStr2Enum(Volcanism, out VolcanismProperty);
            nMassEM             = evt["MassEM"].DoubleNull();
            nSurfaceGravity     = evt["SurfaceGravity"].DoubleNull();
            nSurfaceTemperature = evt["SurfaceTemperature"].DoubleNull();
            nSurfacePressure    = evt["SurfacePressure"].DoubleNull();
            nLandable           = evt["Landable"].BoolNull();

            ReserveLevelStr = evt["ReserveLevel"].Str();

            if (IsStar)
            {
                StarTypeID = Bodies.StarStr2Enum(StarType);

                if (nRadius.HasValue && nSurfaceTemperature.HasValue)
                {
                    HabitableZoneInner = DistanceForBlackBodyTemperature(315);
                    HabitableZoneOuter = DistanceForBlackBodyTemperature(223);
                }
            }
            else if (PlanetClass != null)
            {
                PlanetTypeID = Bodies.PlanetStr2Enum(PlanetClass);
                // Fix naming to standard and fix case..
                PlanetClass = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.
                              ToTitleCase(PlanetClass.ToLower()).Replace("Ii ", "II ").Replace("Iv ", "IV ").Replace("Iii ", "III ");
            }
            else
            {
                PlanetTypeID = EDPlanet.Unknown;
            }


            JToken mats = (JToken)evt["Materials"];

            if (mats != null)
            {
                if (mats.Type == JTokenType.Object)
                {
                    Materials = mats?.ToObject <Dictionary <string, double> >();
                }
                else
                {
                    Materials = new Dictionary <string, double>();
                    foreach (JObject jo in mats)
                    {
                        Materials[(string)jo["Name"]] = jo["Percent"].Double();
                    }
                }
            }

            IsEDSMBody = evt["EDDFromEDSMBodie"].Bool(false);
        }