public override bool Deploy()
        {
            if (!Available || !IsReadyOnboard)
            {
                return(false);
            }
            if (FlightGlobals.ActiveVessel == null)
            {
                return(false);
            }

            if (!FlightGlobals.ActiveVessel.isEVA)
            {
                if (FlightGlobals.getStaticPressure() > Settings.Instance.EvaAtmospherePressureWarnThreshold)
                {
                    if (FlightGlobals.ActiveVessel.GetSrfVelocity().magnitude > Settings.Instance.EvaAtmosphereVelocityWarnThreshold)
                    {
                        DialogGUIBase[] options = new DialogGUIBase[2]
                        {
                            new DialogGUIButton("Science is worth a little risk", OnConfirmEva),
                            new DialogGUIButton("No, it would be a PR nightmare", null)
                        };

                        var multiOptionDialog = new MultiOptionDialog(
                            "It looks dangerous out there. Are you sure you want to send someone out? They might lose their grip!",
                            "It looks dangerous out there. Are you sure you want to send someone out? They might lose their grip!",
                            "Dangerous Condition Alert",
                            HighLogic.UISkin, options);
                        PopupDialog.SpawnPopupDialog(multiOptionDialog, false, HighLogic.UISkin);
                        return(true);
                    }
                }
                return(ExpelCrewman());
            }

            var evas = FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleScienceExperiment>();

            for (int i = evas.Count - 1; i >= 0; i--)
            {
                ModuleScienceExperiment exp = evas[i];
                if (!exp.Deployed && exp.experimentID == experiment.id && !ExcludeFilters.IsExcluded(exp))
                {
                    //exp.DeployExperiment();
                    if (!(DMagicFactory.DMagic_IsInstalled && DMagicFactory.RunExperiment(experiment.id, exp)) &&
                        !(DMagicFactory.DMagicScienceAnimateGeneric_IsInstalled && DMagicFactory.RunSciAnimGenExperiment(experiment.id, exp)))
                    {
                        exp.DeployExperiment();
                    }
                    break;
                }
            }
            return(true);
        }
Beispiel #2
0
        public virtual void Rescan()
        {
            modules = new ScienceModuleList();
            if (FlightGlobals.ActiveVessel == null)
            {
                return;
            }

            ScienceModuleList potentials = FlightGlobals.ActiveVessel
                                           .FindPartModulesImplementing <ModuleScienceExperiment>();

            for (int i = potentials.Count - 1; i >= 0; i--)
            {
                ModuleScienceExperiment potential = potentials[i];
                if (potential.experimentID == experiment.id && !ExcludeFilters.IsExcluded(potential))
                {
                    modules.Add(potential);
                }
            }
        }
Beispiel #3
0
        public int RebuildObserverList()
        {
            //Log.Write("ExperimentManager.RebuildObserverList", Log.LEVEL.INFO);
            observers.Clear();
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return(0);
            }
            ScanInterface scanInterface = GetComponent <ScanInterface>();

            if (scanInterface == null)
            {
                Log.Error("ExperimentManager.RebuildObserverList: No ScanInterface component found"); // this is bad; things won't break if the scan interface
            }
            // construct the experiment observer list ...
            for (int i = ResearchAndDevelopment.GetExperimentIDs().Count - 1; i >= 0; i--)
            {
                string expid = ResearchAndDevelopment.GetExperimentIDs()[i];

                if (expid != "evaReport" && expid != "surfaceSample") // special cases
                {
                    var m = FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleScienceExperiment>().Where(mse => mse.experimentID == expid).ToList();
                    if (m.Count > 0)
                    {
                        if (!ExcludeFilters.IsExcluded(m[0]))
                        {
                            observers.Add(new ExperimentObserver(vesselStorage, ProfileManager.ActiveProfile[expid], biomeFilter, scanInterface, expid, m[0]));
                        }
                    }
                }
            }
            observers.Add(new SurfaceSampleObserver(vesselStorage, ProfileManager.ActiveProfile["surfaceSample"], biomeFilter, scanInterface));

            try
            {
                if (ProfileManager.ActiveProfile["evaReport"].Enabled)
                {
                    if (Settings.Instance.EvaReportOnTop)
                    {
                        observers = observers.OrderBy(obs => obs.ExperimentTitle).ToList();
                        observers.Insert(0, new EvaReportObserver(vesselStorage, ProfileManager.ActiveProfile["evaReport"], biomeFilter, scanInterface));
                    }
                    else
                    {
                        observers.Add(new EvaReportObserver(vesselStorage, ProfileManager.ActiveProfile["evaReport"], biomeFilter, scanInterface));
                        observers = observers.OrderBy(obs => obs.ExperimentTitle).ToList();
                    }
                }
                else
                {
                    observers = observers.OrderBy(obs => obs.ExperimentTitle).ToList();
                }
            }
            catch (NullReferenceException e)
            {
                Log.Error("ExperimentManager.RebuildObserverList: Active profile does not seem to have an \"evaReport\" entry; {0}", e);
            }

            watcher = UpdateObservers(); // to prevent any problems by rebuilding in the middle of enumeration
            OnObserversRebuilt();

            return(observers.Count);
        }