コード例 #1
0
		private void UpdateBodies( )
		{
			var bodies = FlightGlobals.Bodies;



			// Handle added and updated bodies
				foreach( var CelBody in bodies )
				{
//					String s = String.Format( "Body {0} - {1}.", CelBody.flightGlobalsIndex, CelBody.name );
//					_logger.Trace( s );
					if( !_bodyList.ContainsKey( CelBody ) )
					{
						var B = new Body( CelBody );
						_bodyList.Add( CelBody, B );
					}
					else
						_bodyList[ CelBody ].Update( );
				}



				// Handle deleted bodies
				foreach( var CC in _bodyList )
				{
					if( !bodies.Contains( CC.Key ) )
					{
						_bodyList.Remove( CC.Key );
					}
				}
		}
コード例 #2
0
ファイル: AllBodies.cs プロジェクト: jrossignol/KSP-X-Science
 public void Reset( )
 {
     _bodyList = new Dictionary<int, Body>( );
     var bodies = FlightGlobals.Bodies;
     foreach( var body in bodies )
     {
     //				String s = String.Format( "Body {0} - {1}.", body.flightGlobalsIndex, body.name );
     //				_logger.Trace( s );
         var B = new Body( body );
         _bodyList.Add( body.flightGlobalsIndex, B );
     }
 }
コード例 #3
0
ファイル: Situation.cs プロジェクト: npt/KSP-X-Science
		/// <summary>
		/// Creates a new instance of the Situation class.
		/// </summary>
		/// <param name="body">The CelestialBody around which this situation is for.</param>
		/// <param name="situation">The ExperimentSituations flag which this situation is for.</param>
		/// <param name="biome">Optionally, the biome which this situation is for.</param>
		/// <param name="subBiome">Optionally, the KSC biome which this situation is for.</param>
		public Situation( Body body, ExperimentSituations situation, string biome = null, string subBiome = null ) {
			_body = body;
			_situation = situation;
			_biome = biome;
			_subBiome = subBiome;
			_formattedBiome = BiomeToString(_biome);
			_formattedSubBiome = BiomeToString(_subBiome);
			_description = string.Format("{0} {1}{2}",
				ToString(_situation),
				Body.CelestialBody.theName,
				string.IsNullOrEmpty(_formattedBiome)
					? string.Empty
					: string.IsNullOrEmpty(_formattedSubBiome)
						? string.Format("'s {0}", _formattedBiome)
						: string.Format("'s {0} ({1})", _formattedSubBiome, _formattedBiome));
		}
コード例 #4
0
        /// <summary>
        /// Recalculates the current situation of the active vessel.
        /// </summary>
        public void RecalculateSituation()
        {
            var vessel = FlightGlobals.ActiveVessel;
            if (vessel == null) {
                if (_filter.CurrentSituation != null) {
                    _filter.CurrentSituation = 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 dataCount = vessel.FindPartModulesImplementing<IScienceDataContainer>().Sum(x => x.GetData().Length);

            if (_lastDataCount != dataCount) {
                _lastDataCount = dataCount;
                UpdateExperiments();
            }

            if (_filter.CurrentSituation != null && _filter.CurrentSituation.Biome == biome && _filter.CurrentSituation.ExperimentSituation == situation && _filter.CurrentSituation.Body.CelestialBody == body && _filter.CurrentSituation.SubBiome == subBiome) {
                return;
            }
            var Body = new Body( body );
            _filter.CurrentSituation = new Situation(Body, situation, biome, subBiome);
        }
コード例 #5
0
        // 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" );
        }