Пример #1
0
        private void AttachVessel()
        {
            Util.DebugLog("Loading profiles for vessel");

            AttachedVessel = FlightGlobals.ActiveVessel;

            if (AttachedVessel == null)
            {
                Util.DebugLog("No vessel");
                DescentProfile.Clear();
                TargetProfile.Clear();
                TargetProfile.ManualText = "";
            }
            else
            {
                TrajectoriesVesselSettings module = AttachedVessel.Parts.SelectMany(p => p.Modules.OfType <TrajectoriesVesselSettings>()).FirstOrDefault();
                if (module == null)
                {
                    Util.DebugLog("No TrajectoriesVesselSettings module");
                    DescentProfile.Clear();
                    TargetProfile.Clear();
                    TargetProfile.ManualText = "";
                }
                else if (!module.Initialized)
                {
                    Util.DebugLog("Initializing TrajectoriesVesselSettings module");
                    DescentProfile.Clear();
                    DescentProfile.Save(module);
                    TargetProfile.Clear();
                    TargetProfile.ManualText = "";
                    TargetProfile.Save(module);
                    module.Initialized = true;
                    Util.Log("New vessel, profiles created");
                }
                else
                {
                    Util.DebugLog("Reading profile settings...");
                    // descent profile
                    if (DescentProfile.Ready)
                    {
                        DescentProfile.RetrogradeEntry        = module.RetrogradeEntry;
                        DescentProfile.AtmosEntry.AngleRad    = module.EntryAngle;
                        DescentProfile.AtmosEntry.Horizon     = module.EntryHorizon;
                        DescentProfile.HighAltitude.AngleRad  = module.HighAngle;
                        DescentProfile.HighAltitude.Horizon   = module.HighHorizon;
                        DescentProfile.LowAltitude.AngleRad   = module.LowAngle;
                        DescentProfile.LowAltitude.Horizon    = module.LowHorizon;
                        DescentProfile.FinalApproach.AngleRad = module.GroundAngle;
                        DescentProfile.FinalApproach.Horizon  = module.GroundHorizon;
                        DescentProfile.RefreshGui();
                    }

                    // target profile
                    TargetProfile.SetFromLocalPos(FlightGlobals.Bodies.FirstOrDefault(b => b.name == module.TargetBody),
                                                  new Vector3d(module.TargetPosition_x, module.TargetPosition_y, module.TargetPosition_z));
                    TargetProfile.ManualText = module.ManualTargetTxt;
                    Util.Log("Profiles loaded");
                }
            }
        }
Пример #2
0
 internal void OnDestroy()
 {
     Util.DebugLog("");
     AttachedVessel = null;
     AppLauncherButton.DestroyToolbarButton();
     MainGUI.DeSpawn();
     NavBallOverlay.DestroyTransforms();
     FlightOverlay.Destroy();
     MapOverlay.DestroyRenderer();
     Trajectory.Destroy();
     DescentProfile.Clear();
 }