示例#1
0
 private void onVesselRename(GameEvents.HostedFromToAction <Vessel, string> data)
 {
     SoundtrackEditor.CurrentSituation.vesselType = Enums.VesselTypetoCustomVesselType(data.host.vesselType);
     if (MonitorVesselType)
     {
         SoundtrackEditor.Instance.OnSituationChanged();
     }
 }
示例#2
0
 public bool CheckVesselType(Vessel v)
 {
     Enums.CustomVesselType vt = Enums.VesselTypetoCustomVesselType(v.vesselType);
     if ((vt & vesselType) != vt)
     {
         Utils.Log("Prereq failed: Expected situation " + vesselType + ", but was " + vt);
         return(false);
     }
     return(true);
 }
示例#3
0
        private bool IsFlightSituationChanged()
        {
            bool   changed = false;
            Vessel v       = SoundtrackEditor.InitialLoadingComplete ? FlightGlobals.ActiveVessel : null;

            if (v != null)
            {
                Enums.Selector inAtmosphere = v.atmDensity > 0 ? Enums.Selector.True : Enums.Selector.False;
                if (SoundtrackEditor.CurrentSituation.inAtmosphere != inAtmosphere)
                {
                    SoundtrackEditor.CurrentSituation.inAtmosphere = inAtmosphere;
                    if (MonitorInAtmosphere)
                    {
                        Utils.Log("In atmosphere changed");
                        changed = true;
                    }
                }

                // For surface velocity, orbital velocity and altitude, check if we crossed the monitored point going in either direction.
                if (MonitorSurfaceVelocity)
                {
                    if ((v.srf_velocity.magnitude > _maxSrfVel && v.srf_velocity.magnitude < _previousSrfVel) ||
                        (v.srf_velocity.magnitude < _maxSrfVel && v.srf_velocity.magnitude > _previousSrfVel))
                    {
                        changed = true;
                    }
                    if ((v.srf_velocity.magnitude > _minSrfVel && v.srf_velocity.magnitude < _previousSrfVel) ||
                        (v.srf_velocity.magnitude < _minSrfVel && v.srf_velocity.magnitude > _previousSrfVel))
                    {
                        changed = true;
                    }
                    _previousSrfVel = v.srf_velocity.magnitude;
                }
                if (MonitorOrbitalVelocity)
                {
                    if ((v.obt_velocity.magnitude > _maxObtVel && v.obt_velocity.magnitude < _previousObtVel) ||
                        (v.obt_velocity.magnitude < _maxObtVel && v.obt_velocity.magnitude > _previousObtVel))
                    {
                        changed = true;
                    }
                    if ((v.obt_velocity.magnitude > _minObtVel && v.obt_velocity.magnitude < _previousObtVel) ||
                        (v.obt_velocity.magnitude < _minObtVel && v.obt_velocity.magnitude > _previousObtVel))
                    {
                        changed = true;
                    }
                    _previousObtVel = v.obt_velocity.magnitude;
                }

                if (MonitorAltitude)
                {
                    if ((v.altitude > _maxAlt && v.altitude < _previousAlt) ||
                        (v.altitude < _maxAlt && v.altitude > _previousAlt))
                    {
                        changed = true;
                    }
                    if ((v.altitude > _minAlt && v.altitude < _previousAlt) ||
                        (v.altitude < _minAlt && v.altitude > _previousAlt))
                    {
                        changed = true;
                    }
                    _previousAlt = v.altitude;
                }

                if (MonitorNearestVessel)
                {
                    Vessel newVessel = Utils.GetNearestVessel(_minVesselDist, _maxVesselDist, v);
                    if (newVessel != null && NearestVessel != newVessel)
                    {
                        NearestVessel = newVessel;
                        changed       = true;
                    }
                }

                if (MonitorVesselState)
                {
                    if (_previousVesselState != Enums.ConvertVesselState(v.state))
                    {
                        Utils.Log("Vessel state changed");
                        _previousVesselState = Enums.ConvertVesselState(v.state);
                        changed = true;
                    }
                }
                if (MonitorVesselType)
                {
                    if (_previousVesselType != Enums.VesselTypetoCustomVesselType(v.vesselType))
                    {
                        Utils.Log("Vessel type changed");
                        _previousVesselType = Enums.VesselTypetoCustomVesselType(v.vesselType);
                        changed             = true;
                    }
                }
            }
            return(changed);
        }