private static ImpactScienceData createAsteroidSpectralData(CelestialBody crashBody, Vessel asteroid, Vessel crashVessel, uint flightID)
        {
            double crashVelocity = crashVessel.srf_velocity.magnitude;

            Log("Velocity=" + crashVelocity);
            float  crashMasss  = crashVessel.GetTotalMass() * 1000;
            double crashEnergy = 0.5 * crashMasss * crashVelocity * crashVelocity; //KE of crash

            ScienceExperiment    experiment = ResearchAndDevelopment.GetExperiment("AsteroidSpectometry");
            ExperimentSituations situation  = ScienceUtil.GetExperimentSituation(asteroid);

            ScienceSubject subject = ResearchAndDevelopment.GetExperimentSubject(experiment, situation, asteroid.id.ToString(), asteroid.GetName(), crashBody, "", "");
            double         science = subject.scienceCap;

            Log("Impact took place in " + situation);
            String flavourText = "Impact at <<1>> on <<2>>";


            science /= subject.subjectValue;

            ImpactScienceData data = new ImpactScienceData(0, asteroid.GetName(),
                                                           (float)(science * subject.dataScale), 1f, 0, subject.id,
                                                           Localizer.Format(flavourText, asteroid.GetName(), crashBody.GetDisplayName()), false, flightID);

            ScreenMessages.PostScreenMessage(
                Localizer.Format("#autoLOC_Screen_Asteroid", asteroid.GetName(), crashBody.GetDisplayName()),
                5.0f, ScreenMessageStyle.UPPER_RIGHT);

            return(data);
        }
        private static ImpactScienceData createSpectralData(CelestialBody crashBody, Vessel crashVessel, uint flightID)
        {
            double crashVelocity = crashVessel.srf_velocity.magnitude;

            Log("Velocity=" + crashVelocity);
            float  crashMasss  = crashVessel.GetTotalMass() * 1000;
            double crashEnergy = 0.5 * crashMasss * crashVelocity * crashVelocity; //KE of crash

            ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment("ImpactSpectrometer");
            String            biome      = ScienceUtil.GetExperimentBiome(crashBody, crashVessel.latitude, crashVessel.longitude);
            CBAttributeMapSO  m          = crashBody.BiomeMap;

            CBAttributeMapSO.MapAttribute[] atts = m.Attributes;
            ScienceSubject subject = ResearchAndDevelopment.GetExperimentSubject(experiment, ExperimentSituations.InSpaceLow, crashBody, biome, biome);
            double         science = subject.scienceCap;

            Log("Impact took place in " + biome + " at " + crashVessel.latitude + "," + crashVessel.longitude);
            String flavourText = "Impact at <<1>> on <<2>>";

            science  = Math.Max(0, science - subject.science);
            science /= subject.subjectValue;

            ImpactScienceData data = new ImpactScienceData(ImpactScienceData.DataTypes.Spectral,
                                                           0, biome, crashVessel.latitude,
                                                           (float)(science * subject.dataScale), 1f, 0, subject.id,
                                                           Localizer.Format(flavourText, biome, crashBody.GetDisplayName()), false, flightID);

            ScreenMessages.PostScreenMessage(
                Localizer.Format("#autoLOC_Screen_Spectrum", biome, crashBody.GetDisplayName()),
                5.0f, ScreenMessageStyle.UPPER_RIGHT);

            return(data);
        }
 protected override string GetTitle()
 {
     CelestialBody targetBody = StnSciParameter.getTargetBody(this);
     if (targetBody == null)
         return Localizer.Format("#autoLOC_StatSciDoExp_TitleA");
     else
         return Localizer.Format("#autoLOC_StatSciDoExp_TitleB", targetBody.GetDisplayName());
 }
Example #4
0
 protected override string GetTitle()
 {
     if (targetBody == null)
     {
         return(Localizer.Format("#ne_Run_experiment_in_orbit"));
     }
     else
     {
         return(Localizer.Format("#ne_Run_experiment_in_orbit_around_1", targetBody.GetDisplayName()));
     }
 }
Example #5
0
        public static string CleanDisplayName(this CelestialBody body, bool lower = false)
        {
            strArr[0] = body.GetDisplayName();
            string displayName = KSP.Localization.Localizer.Format("<<1>>", strArr);

            if (lower && displayName != body.name)
            {
                displayName = Char.ToLowerInvariant(displayName[0]) + displayName.Substring(1);
            }

            return(displayName);
        }
 protected override string GetTitle()
 {
     return(Localizer.Format("#ne_Run_experiment_1_in_orbit_around_2_and_return_it_to_3",
                             experiment.getShortName(), targetBody.GetDisplayName(), Planetarium.fetch.Home.GetDisplayName()
                             ));
 }
        void FixedUpdate()
        {
            HandleAnimation();
            if (HighLogic.LoadedSceneIsFlight)
            {
                if (Enabled)
                {
                    CurrentPowerConsumption = -PowerCost;

                    vessel.GetConnectedResourceTotals(PartResourceLibrary.ElectricityHashcode, out double currentEC, out double maxEC);
                    double chargeRequest = PowerCost * TimeWarp.fixedDeltaTime;

                    float         angle         = 0f;
                    CelestialBody obscuringBody = null;

                    // check power
                    if (currentEC > chargeRequest + minResToLeave)
                    {
                        double consumption = part.RequestResource(PartResourceLibrary.ElectricityHashcode, chargeRequest);
                        if (consumption >= chargeRequest - 0.0001)

                        {
                            ITargetable target = part.vessel.targetObject;

                            if (target != null)
                            {
                                try
                                {
                                    CelestialBody targetBody;
                                    targetBody = (CelestialBody)target;
                                    Target     = targetBody.name;

                                    if (!Utils.CalculateBodyLOS(this.vessel, targetBody, transform, out angle, out obscuringBody))
                                    {
                                        SetScanUI(false);
                                        //Fields["ModifierUI"].guiActive = false;
                                        ScannerUI = Localizer.Format("#LOC_SpaceDust_ModuleSpaceDustTelescope_Field_Status_Blocked", obscuringBody.GetDisplayName());
                                        return;
                                    }

                                    if (this.vessel.atmDensity > 0.0001d)
                                    {
                                        //ModifierUI = Localizer.Format("#LOC_SpaceDust_ModuleSpaceDustTelescope_Field_Modifier_InAtmo", atmosphereScale);
                                        //Fields["ModifierUI"].guiActive = true;
                                    }
                                    else
                                    {
                                        // Fields["ModifierUI"].guiActive = false;
                                    }


                                    // do scanning
                                    ScannerUI = Localizer.Format("#LOC_SpaceDust_ModuleSpaceDustTelescope_Field_Status_Observing", part.vessel.targetObject.GetDisplayName());
                                    SetScanUI(true);
                                    for (int i = 0; i < instrumentSlots.Count; i++)
                                    {
                                        if (instrumentSlots[i].Instrument != null)
                                        {
                                            string response = instrumentSlots[i].Instrument.Scan(part.vessel, (CelestialBody)part.vessel.targetObject, ObjectiveDiameter, FieldOfView, TimeWarp.fixedDeltaTime);
                                            Fields[$"InstrumentUI_{i + 1}"].SetValue(response, this);
                                        }
                                    }
                                }
                                catch (InvalidCastException)
                                {
                                    Target = "";
                                    SetScanUI(false);
                                    // Fields["ModifierUI"].guiActive = false;
                                    ScannerUI = Localizer.Format("#LOC_SpaceDust_ModuleSpaceDustTelescope_Field_Status_NoTarget");
                                }
                            }
                            else
                            {
                                Target = "";
                                SetScanUI(false);
                                ScannerUI = Localizer.Format("#LOC_SpaceDust_ModuleSpaceDustTelescope_Field_Status_NoTarget");
                            }
                        }
                        else
                        {
                            Target = "";
                            SetScanUI(false);
                            ScannerUI = Localizer.Format("#LOC_SpaceDust_ModuleSpaceDustTelescope_Field_Status_NoPower");
                        }
                    }
                    else
                    {
                        Target = "";
                        SetScanUI(false);
                        ScannerUI = Localizer.Format("#LOC_SpaceDust_ModuleSpaceDustTelescope_Field_Status_NoPower");
                    }
                }
                else
                {
                    // Fields["ModifierUI"].guiActive = false;
                    CurrentPowerConsumption = 0f;
                    ScannerUI = Localizer.Format("#LOC_SpaceDust_ModuleSpaceDustTelescope_Field_Status_Disabled");
                    SetScanUI(false);
                }
            }
        }
 protected override string GetTitle()
 {
     return Localizer.Format("#autoLOC_StatSciParam_Title", experimentType.title, targetBody.GetDisplayName());
 }
        private static ImpactScienceData createSeismicData(CelestialBody crashBody, Vessel crashVessel, uint flightID)
        {
            double crashVelocity = crashVessel.srf_velocity.magnitude;

            Log("Velocity=" + crashVelocity);
            float  crashMasss  = crashVessel.GetTotalMass() * 1000;
            double crashEnergy = 0.5 * crashMasss * crashVelocity * crashVelocity; //KE of crash


            ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment("ImpactSeismometer");
            ScienceSubject    subject    = ResearchAndDevelopment.GetExperimentSubject(experiment, ExperimentSituations.SrfLanded, crashBody, "", "");
            double            science    = translateKEToScience(crashEnergy, crashBody, subject);

            String flavourText = "Impact of <<1>> on <<2>>";

            Log(" caluculated science =" + science);
            science = Math.Max(0.01, science - subject.science);
            Log("residual science =" + science);

            science /= subject.subjectValue;
            Log("divided science =" + science);

            ImpactScienceData data = new ImpactScienceData(ImpactScienceData.DataTypes.Seismic,
                                                           (float)crashEnergy, null, crashVessel.latitude,
                                                           (float)(science * subject.dataScale), 1f, 0, subject.id,
                                                           Localizer.Format(flavourText, energyFormat(crashEnergy), crashBody.GetDisplayName()), false, flightID);

            ScreenMessages.PostScreenMessage(
                Localizer.Format("#autoLOC_Screen_Seismic", energyFormat(crashEnergy), crashBody.GetDisplayName()),
                5.0f, ScreenMessageStyle.UPPER_RIGHT);


            return(data);
        }