Exemple #1
0
        public void DrawOpsWindow()
        {
            bool biomeUnlocked = Utils.IsBiomeUnlocked(this.part.vessel);

            GUILayout.BeginHorizontal();

            drawAbundanceGUI();

            //C&C buttons
            GUILayout.BeginVertical();
            GUILayout.BeginScrollView(new Vector2(0, 0), new GUIStyle(GUI.skin.textArea), GUILayout.Width(300));

            //Biome analysis button
            if (biomeUnlocked == false)
            {
                if (GUILayout.Button("Perform biome analysis"))
                {
                    perfomBiomeAnalysys();
                }
            }

            //Review Data button
            int totalData = scienceContainer.GetStoredDataCount();

            if (totalData > 0)
            {
                if (GUILayout.Button("Review [" + totalData + "] Data"))
                {
                    scienceContainer.ReviewData();
                    swizzler.SwizzleResultsDialog();
                }
            }

            //Research projects
            drawResearchProjectsGUI(biomeUnlocked);

            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            //Update elapsed time
            if (ModuleIsActive() && currentExperiment != GeologyLabExperiments.None)
            {
                int elapsedTimeIndex = (int)currentExperiment;
                elapsedTimes[elapsedTimeIndex] = elapsedTime;
            }
        }
        public override void ReviewData()
        {
            float scienceCap   = WBIBiomeAnalysis.GetScienceCap(this.part);
            float totalScience = scienceAdded;

            if (totalScience < 0.001f)
            {
                ScreenMessages.PostScreenMessage(kNoScience, 5.0f, ScreenMessageStyle.UPPER_CENTER);
                return;
            }

            while (totalScience > 0.001f)
            {
                //Set the experiment title
                if (totalScience < scienceCap)
                {
                    dataAmount = totalScience;
                }
                else
                {
                    dataAmount = scienceCap;
                }

                //Generate lab data
                ScienceData data = WBIBiomeAnalysis.CreateData(this.part, dataAmount);
                scienceContainer.AddData(data);

                //Deduct from the total
                totalScience -= dataAmount;
                if (totalScience <= 0.001f)
                {
                    scienceAdded = 0f;
                }
            }

            //Make sure we have some science to transmit.
            if (scienceContainer.GetScienceCount() == 0)
            {
                ScreenMessages.PostScreenMessage(kNoScience, 5.0f, ScreenMessageStyle.UPPER_CENTER);
                return;
            }

            //Review the data
            scienceContainer.ReviewData();
            swizzler.SwizzleResultsDialog();
        }
        protected void drawView()
        {
            //Review Data button
            int totalData = scienceContainer.GetStoredDataCount();

            if (GUILayout.Button("Review [" + totalData + "] Data") && totalData > 0)
            {
                scienceContainer.ReviewData();
            }

            //Terrain uplink
            if (GUILayout.Button("T.E.R.R.A.I.N. Uplink"))
            {
                terrainUplinkView.parentView = this.parentView;
                terrainUplinkView.SetVisible(true);
            }
        }
		// Much credit to a.g. as his source helped to figure out how to utilize the experiment and its data
		// https://github.com/angavrilov/ksp-surface-survey/blob/master/SurfaceSurvey.cs#L276
		public void AnalyzeScienceSample ()
		{
			if (rover.ScienceSpotReached) {

				ScienceExperiment sciExperiment = ResearchAndDevelopment.GetExperiment ("RoverScienceExperiment");
				ScienceSubject sciSubject = ResearchAndDevelopment.GetExperimentSubject(sciExperiment, ExperimentSituations.SrfLanded, Vessel.mainBody, "", "");

				// 20 science per data
				sciSubject.subjectValue = 20;
				sciSubject.scienceCap = BodyScienceCap;

				// Divide by 20 to convert to data form
				float sciData = (rover.scienceSpot.potentialScience) / sciSubject.subjectValue;

                Utilities.LogVerbose ("sciData (potential/20): " + sciData);


                // Apply multipliers

                if (rover.AnomalySpotReached)
                {
                    Utilities.LogVerbose("analyzed science at anomaly");

                    if (!rover.anomaliesAnalyzed.Contains(rover.closestAnomaly.id))
                    {
                        rover.anomaliesAnalyzed.Add(rover.closestAnomaly.id);
                        Utilities.LogVerbose($"added anomaly id: {rover.closestAnomaly.id} to save!");
                    }

                } else
                {
                    // if a normal spot, we shall apply factors
                    Utilities.LogVerbose("analyzed science at science spot");
                    sciData = sciData * ScienceDecayScalar * BodyScienceScalar * scienceMaxRadiusBoost;
                }



                Utilities.LogVerbose("rover.scienceSpot.potentialScience: " + rover.scienceSpot.potentialScience);
                Utilities.LogVerbose("sciData (post scalar): " + sciData);
                Utilities.LogVerbose("scienceDecayScalar: " + ScienceDecayScalar);
                Utilities.LogVerbose("bodyScienceScalar: " + BodyScienceScalar);
               
				

				if (sciData > 0.1) {
					if (StoreScience (container, sciSubject, sciData)) {
						container.ReviewData ();
                        amountOfTimesAnalyzed++;
                        Utilities.LogVerbose ("Science retrieved! - " + sciData);
					} else {
                        Utilities.Log ("Failed to add science to container!");
					}
				} else {

                    ScreenMessages.PostScreenMessage ("#LOC_RoverScience_GUI_ScienceTooLow", 5, ScreenMessageStyle.UPPER_CENTER); // Science value was too low - deleting data!
				}

				rover.scienceSpot.Reset ();

			} else {
                Utilities.LogVerbose ("Tried to analyze while not at spot?");
			}
		}