Пример #1
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();
            }
        }
Пример #2
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);
        }