예제 #1
0
        public void RunStandardModuleScienceExperiment(ModuleScienceExperiment exp)
        {
            if (exp.Inoperable)
            {
                return;
            }

            if (Config.HideExperimentResultsDialog)
            {
                if (!exp.useStaging)
                {
                    exp.useStaging = true;
                    exp.OnActive();
                    exp.useStaging = false;
                }
                else
                {
                    exp.OnActive();
                }
            }
            else
            {
                exp.DeployExperiment();
            }
        }
예제 #2
0
        public void RunStandardModuleScienceExperiment(ModuleScienceExperiment exp)
        {
            if (exp.Inoperable)
            {
                return;
            }

            if (_parent.Config.ShowResultsWindow)
            {
                exp.DeployExperiment( );
            }
            else
            {
                if (!exp.useStaging)
                {
                    exp.useStaging = true;
                    exp.OnActive();
                    exp.useStaging = false;
                }
                else
                {
                    exp.OnActive();
                }
            }
        }
 /// <summary>
 /// Attempts to call DeployExperiment() on subclasses. Falls back to default on failure.
 /// </summary>
 /// <param name="moduleScienceExperiment"></param>
 public static void DeployExperimentUsingReflection(this ModuleScienceExperiment moduleScienceExperiment)
 {
     try {
         moduleScienceExperiment.GetType().InvokeMember("DeployExperiment", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.IgnoreReturn | System.Reflection.BindingFlags.InvokeMethod, null, moduleScienceExperiment, null);
     } catch {
         moduleScienceExperiment.DeployExperiment();
     }
 }
예제 #4
0
            public void Deploy()
            {
                var gatherDataMethod = experiment.GetType()
                                       .GetMethod("gatherData", BindingFlags.NonPublic | BindingFlags.Instance);

                experiment.DeployExperiment();
                object result = gatherDataMethod !.Invoke(experiment, new object[] { false });

                experiment.StartCoroutine(result as IEnumerator);
            }
예제 #5
0
 bool Deploy(ModuleScienceExperiment exp)
 {
     Log.Info("AYA_Science.Deploy, exp: " + exp.experimentID);
     if (!(DMagicFactory.DMagic_IsInstalled && DMagicFactory.RunExperiment(exp.experimentID, exp)) &&
         !(DMagicFactory.DMagicScienceAnimateGeneric_IsInstalled && DMagicFactory.RunSciAnimGenExperiment(exp.experimentID, exp)))
     {
         exp.DeployExperiment();
         return(true);
     }
     return(false);
 }
예제 #6
0
        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);
        }
예제 #7
0
 public void DeployExperiment(ModuleScienceExperiment baseExperiment)
 {
     if (_AutomatedScienceSamplerInstance.craftSettings.hideScienceDialog)
     {
         var stagingSetting = baseExperiment.useStaging;
         baseExperiment.useStaging = true;           //work the way around the staging
         baseExperiment.OnActive();                  //run the experiment without causing the report to show up
         baseExperiment.useStaging = stagingSetting; //set the staging back
     }
     else
     {
         baseExperiment.DeployExperiment();
     }
 }
예제 #8
0
        public void StartSEIS()
        {
            BaseEvent deplo  = Events["StartSEIS"];
            BaseEvent deplo2 = Events["StartHeat"];

            deplo.guiActive  = false;
            deplo2.guiActive = false;
            timer            = 0;
            brazo1           = part.FindModelTransform("arm_01 (1)").gameObject;
            brazo2           = part.FindModelTransform("arm_01 (2)").gameObject;
            brazo1.SetActive(true);
            brazo2.SetActive(false);
            Quesoy(false);
            pre.DeployExperiment();
            aniactive = true;
        }
 private void DeployExperiment(ModuleScienceExperiment currentExperiment)
 {
     try//taken from ScienceAlert since .DeployExperiment() didnt work and i didnt know about this
       {
     // Get the most-derived type and use its DeployExperiment so we don't
     // skip any plugin-derived versions
     currentExperiment.GetType().InvokeMember("DeployExperiment", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.IgnoreReturn | System.Reflection.BindingFlags.InvokeMethod, null, currentExperiment, null);
       }
       catch (Exception e)
       {
     Utilities.debug(modName, Utilities.LogMode.Error, "Failed to invoke \"DeployExperiment\" using GetType(), falling back to base type after encountering exception " + e);
     currentExperiment.DeployExperiment();
       }
 }
예제 #10
0
    private void OnWindow(int windowID)
    {
        GUI.skin = KSPScienceSettings.getSkin();
        //         GUILayout.BeginHorizontal();
        //         autoPauseOnNew = GUILayout.Toggle(autoPauseOnNew, "Auto Pause on new Science: " + autoPauseOnNew);
        //         GUILayout.EndHorizontal();
        scrollVector2 = GUILayout.BeginScrollView(scrollVector2);


        GUILayout.BeginHorizontal();
        for (int i = 0; i <= 6; i++)
        {
            GUILayout.BeginVertical();
            switch (i)
            {
            case 0:
                GUILayout.Label("ID");
                break;

            case 1:
                GUILayout.Label("Earned");
                break;

            case 2:
                GUILayout.Label("Max");
                break;

            case 3:
                GUILayout.Label("Remains");
                break;

            case 4:
                GUILayout.Label("OnShip");
                break;

            case 5:
                GUILayout.Label("NextExp");
                break;

            case 6:
                if (KSPScienceSettings.getBoolSetting("ShowDeployButton"))
                {
                    GUILayout.Label("Deploy");
                }
                break;
            }
            foreach (ExperimentView experimentView in Output)
            {
                if (experimentView.EarnedScience >= experimentView.FullScience && !experimentView.OnShip)
                {
                    continue;
                }
                GUIStyle style = new GUIStyle();
                if (experimentView.OnShip)
                {
                    style = KSPScienceSettings.getStyleSetting("MonitorOnShipExperiments");
                }
                else if (experimentView.EarnedScience > 0)
                {
                    style = KSPScienceSettings.getStyleSetting("MonitorKSCExperiments");
                }
                else
                {
                    style = KSPScienceSettings.getStyleSetting("MonitorNewExperiments");
                    if (OnShip.Exists(view => view.FullExperimentId == experimentView.FullExperimentId))
                    {
                        continue;
                    }
                }
                switch (i)
                {
                case 0:
                    GUILayout.Label(experimentView.FullExperimentId, style);
                    break;

                case 1:
                {
                    string strout = Math.Round(experimentView.EarnedScience, 1).ToString();
                    if (strout == "0")
                    {
                        strout = "-";
                    }
                    GUILayout.Label(strout, style);
                }
                break;

                case 2:
                {
                    string strout = Math.Round(experimentView.FullScience, 1).ToString();
                    if (strout == "0")
                    {
                        strout = "-";
                    }
                    GUILayout.Label(strout, style);
                }
                break;

                case 3:
                    double percent = (experimentView.FullScience - experimentView.EarnedScience) / experimentView.FullScience * 100;
                    if (experimentView.FullScience == 0)
                    {
                        GUILayout.Label("-", style);
                    }
                    else if (percent >= 30)
                    {
                        GUIStyle tmpstyle = style;
                        style = KSPScienceSettings.getStyleSetting("MonitorNewExperiments");
                        GUILayout.Label(Math.Round(percent) + "%", style);
                        style = tmpstyle;
                    }
                    else
                    {
                        GUILayout.Label(Math.Round(percent) + "%", style);
                    }
                    break;

                case 4:
                    GUILayout.Label(experimentView.OnShip ? "\u221a" : " ", style);
                    break;

                case 5:
                {
                    string strout = Math.Round(experimentView.NextExperimentScience, 1).ToString();
                    if (strout == "0")
                    {
                        strout = "-";
                    }
                    GUILayout.Label(strout, style);
                }
                break;

                case 6:
                {
                    if (KSPScienceSettings.getBoolSetting("ShowDeployButton"))
                    {
                        GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
                        buttonStyle.margin           = new RectOffset(0, 0, 0, 0);
                        buttonStyle.normal.textColor = style.normal.textColor;
                        if (experimentView.FullExperimentId.Split('@')[0] == "asteroidSample")
                        {
                            //ModuleAsteroid[] asteroids = FindObjectsOfType<ModuleAsteroid>();
                            //ModuleScienceContainer collector = FlightGlobals.ActiveVessel.FindPartModulesImplementing<ModuleScienceContainer>().First<ModuleScienceContainer>();
                            //will be added in next version.
                            GUILayout.Button("------", buttonStyle, GUILayout.Height(15));
                        }
                        else
                        {
                            bool foundFreeSpaceForExperiment = false;
                            ModuleScienceExperiment moduleScienceExperiment = null;
                            foreach (ModuleScienceExperiment _moduleScienceExperiment in FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleScienceExperiment>())
                            {
                                if (_moduleScienceExperiment.experimentID == experimentView.FullExperimentId.Split('@')[0])
                                {
                                    if (!_moduleScienceExperiment.Deployed && !_moduleScienceExperiment.Inoperable && _moduleScienceExperiment.GetScienceCount() == 0)
                                    {
                                        foundFreeSpaceForExperiment = true;
                                        moduleScienceExperiment     = _moduleScienceExperiment;
                                        break;
                                    }
                                }
                            }
                            if (foundFreeSpaceForExperiment)
                            {
                                if (GUILayout.Button("deploy", buttonStyle, GUILayout.Height(15)))
                                {
                                    moduleScienceExperiment.DeployExperiment();
                                }
                            }
                            else
                            {
                                GUILayout.Button("------", buttonStyle, GUILayout.Height(15));
                            }
                        }
                    }
                }
                break;
                }
                //                 if (autoPauseOnNew && style.normal.textColor == Color.green)
                //                 {
                //                     //activate pause
                //                     TimeWarp.SetRate(0, true);
                //                     FlightDriver.SetPause(true);
                //                 }
            }
            GUILayout.EndVertical();
        }
        GUILayout.EndHorizontal();

        GUILayout.EndScrollView();
        //GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.Space(20);
        GUILayout.EndHorizontal();
        GUILayout.Space(20);
        if (GUI.Button(new Rect(windowPosition.width - 42, 0, 21, 21), "S"))
        {
            KSPScienceSettings.Toggle();
        }
        if (GUI.Button(new Rect(windowPosition.width - 21, 0, 21, 21), "X"))
        {
            Hide();
        }
        if (GUI.RepeatButton(new Rect(windowPosition.width - 21, windowPosition.height - 21, 21, 21), "\u21d8"))
        {
            resizingWindow = true;
        }
        GUI.DragWindow(new Rect(0, 0, 10000, 20));
    }
예제 #11
0
    void drawExperiment(ModuleScienceExperiment experiment)
    {
        var page = pages.Find(p => p.host == experiment.part);
        var data = experiment.GetData()[0];
        bool hasData = data != null;
        string stats = "";

        if (hasData) {
            var sv = simulateScience(data);
            var tsv = simulateScience(data, true);
            dataAmount += data.dataAmount;
            returnScience += sv;
            transmitScience += tsv;
            stats = string.Format("( {0:F1} / {1:F1} )", sv, tsv);

            if (page != null) {
                var sub = ResearchAndDevelopment.GetSubjectByID(data.subjectID);
                if (sub.science < sub.scienceCap) {
                    page.OnKeepData(page.pageData);
                }
                else {
                    page.OnDiscardData(page.pageData);
                }
            }
        }

        ScienceExperiment exp = ResearchAndDevelopment.GetExperiment(experiment.experiment.id);
        string tooltip = "";

        CelestialBody body = experiment.vessel.mainBody;
        foreach (ExperimentSituations sit in Enum.GetValues(typeof(ExperimentSituations)))
        {
            if (exp.IsAvailableWhile(sit, body) &&
                 !((sit == ExperimentSituations.FlyingHigh || sit == ExperimentSituations.FlyingLow) && !body.atmosphere) &&
                 !(sit == ExperimentSituations.SrfSplashed && !body.ocean)
               )
            {
                string key;
                if (exp.BiomeIsRelevantWhile(sit))
                {
                    if (body.BiomeMap != null && body.BiomeMap.Attributes != null)
                        foreach (CBAttributeMap.MapAttribute biome in body.BiomeMap.Attributes)
                        {
                            ScienceSubject sub = ResearchAndDevelopment.GetExperimentSubject(exp, sit, body, biome.name);
                            tooltip += body.name + " " + sit.ToString() + " " + biome.name + " " + sub.science.ToString("F1") + "/" + Mathf.RoundToInt(sub.scienceCap) + "\n";

                        }
                    if (body.name == "Kerbin")
                    {
                        string[] specials = { "KSC", "Runway", "Launchpad" };
                        foreach (string special in specials)
                        {
                            ScienceSubject sub = ResearchAndDevelopment.GetExperimentSubject(exp, sit, body, special);
                            tooltip += body.name + " " + sit.ToString() + " " + special + " " + sub.science.ToString("F1") + "/" + Mathf.RoundToInt(sub.scienceCap) + "\n";

                        }
                    }
                }
                else
                {
                    key = body.name + sit.ToString();
                    ScienceSubject sub = ResearchAndDevelopment.GetExperimentSubject(exp, sit, body, "");
                    if (sub != null)
                        tooltip += body.name + " " + sit.ToString() + " " +  sub.science.ToString("F1") + "/" + Mathf.RoundToInt(sub.scienceCap) + "\n";
                    else
                        tooltip += body.name + " " + sit.ToString() + " 0/" + Mathf.RoundToInt(exp.scienceCap) + "\n";
                }
            }
        }

        GUILayout.BeginVertical();

        GUILayout.BeginHorizontal(GUILayout.MaxHeight(18));
        GUILayout.Label(new GUIContent(experiment.experimentID + (stats != "" ? " - " + stats : ""), tooltip), styleTitle);
        if (hasData) {
            GUILayout.Label(data.title, styleTitle);
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button((hasData ? "Reset" : "Deploy"), new GUILayoutOption[] { GUILayout.MaxHeight(18), GUILayout.ExpandWidth(false) })) {
            if (hasData) {
                experiment.ResetExperiment();
            }
            else {
                experiment.DeployExperiment();
        //				experiment.StartCoroutine((IEnumerator)miGatherData.Invoke(experiment, new object[] { false })); // KSP doesn't like window free results yet
            }
        }
        GUILayout.Space(5);
        GUILayout.EndHorizontal();

        GUILayout.EndVertical();
    }
예제 #12
0
    void drawExperiment(ModuleScienceExperiment experiment)
    {
        var page = pages.Find(p => p.host == experiment.part);
        var data = experiment.GetData()[0];
        bool hasData = data != null;
        string stats = "";

        if (hasData) {
            var sv = simulateScience(data);
            var tsv = simulateScience(data, true);
            dataAmount += data.dataAmount;
            returnScience += sv;
            transmitScience += tsv;
            stats = string.Format("( {0:F1} / {1:F1} )", sv, tsv);

            if (page != null) {
                var sub = ResearchAndDevelopment.GetSubjectByID(data.subjectID);
                if (sub.science < sub.scienceCap) {
                    page.OnKeepData(page.pageData);
                }
                else {
                    page.OnDiscardData(page.pageData);
                }
            }
        }

        GUILayout.BeginVertical();

        GUILayout.BeginHorizontal(GUILayout.MaxHeight(18));
        GUILayout.Label(experiment.experimentID + (stats != "" ? " - " + stats : ""), styleTitle);
        if (hasData) {
            GUILayout.Label(data.title, styleTitle);
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button((hasData ? "Reset" : "Deploy"), new GUILayoutOption[] { GUILayout.MaxHeight(18), GUILayout.ExpandWidth(false) })) {
            if (hasData) {
                experiment.ResetExperiment();
            }
            else {
                experiment.DeployExperiment();
        //				experiment.StartCoroutine((IEnumerator)miGatherData.Invoke(experiment, new object[] { false })); // KSP doesn't like window free results yet
            }
        }
        GUILayout.Space(5);
        GUILayout.EndHorizontal();

        GUILayout.EndVertical();
    }
예제 #13
0
 public void deployExperiment(ModuleScienceExperiment exp)
 {
     exp.DeployExperiment();
 }