/// <summary> /// Creates a new instance of the Experiment class. /// </summary> /// <param name="experiment">The ScienceExperiment to be used.</param> /// <param name="situation">The Situation this experiment is valid in.</param> /// <param name="onboardScience">A collection of all onboard ScienceData.</param> public ScienceInstance( ScienceExperiment experiment, Situation situation, ScienceContext Sci ) { _experiment = experiment; _situation = situation; ScienceSubject = null; Update( Sci ); }
/// <summary> /// Creates a new instance of the Experiment class. /// </summary> /// <param name="experiment">The ScienceExperiment to be used.</param> /// <param name="situation">The Situation this experiment is valid in.</param> /// <param name="onboardScience">A collection of all onboard ScienceData.</param> public Experiment( ScienceExperiment experiment, Situation situation, Dictionary<string, List<ScienceData>> onboardScience, Dictionary<string, ScienceSubject> SciDict, UnlockedExperimentList AvailableExperiments ) { _experiment = experiment; _situation = situation; ScienceSubject = null; Update( onboardScience, SciDict, AvailableExperiments ); }
// Recalculates the current situation of the active vessel. private void RecalculateSituation( ) { //_logger.Trace( "RecalculateSituation Start" ); var vessel = FlightGlobals.ActiveVessel; if (vessel == null) { if (_currentSituation != null) { _currentSituation = null; if (SituationChanged != null) { SituationChanged(this, null); } } return; } var body = vessel.mainBody; var situation = ScienceUtil.GetExperimentSituation(vessel); var biome = ScienceUtil.GetExperimentBiome(body, vessel.latitude, vessel.longitude); var subBiome = string.IsNullOrEmpty(vessel.landedAt) ? null : Vessel.GetLandedAtString(vessel.landedAt).Replace(" ", ""); var Parts = vessel.FindPartModulesImplementing <IScienceDataContainer>( ); var dataCount = 0; for (var x = 0; x < Parts.Count; x++) { dataCount += Parts[x].GetData( ).Length; } if (_lastDataCount != dataCount) { // _logger.Trace( "Collected new science!" ); _lastDataCount = dataCount; ScheduleExperimentUpdate( ); } if ( _currentSituation != null && _currentSituation.Biome == biome && _currentSituation.ExperimentSituation == situation && _currentSituation.Body.CelestialBody == body && _currentSituation.SubBiome == subBiome ) { return; } var Body = new Body(body); _currentSituation = new Situation(Body, situation, biome, subBiome); if (SituationChanged != null) { SituationChanged(this, new NewSituationData(Body, situation, biome, subBiome)); } //_logger.Trace( "RecalculateSituation Done" ); }