// Constructor
 public Control(Navigator navigator, Controls controls, float [] angles, float throttle, bool sailon, double duration, int iwarp, string frame)
 {
     // Navigator
     this.navigator = navigator;
     // Parent controls object
     this.controls = controls;
     // Reference frame for control angles
     this.frame = Frame.Frames[frame];
     // Frame window
     frameWindow = new FrameWindow(this);
     // Angles
     this.angles = angles;
     // Angle strings
     anglestr = new string [3];
     for (int i = 0; i < 3; i++) {
     anglestr[i] = angles[i].ToString();
     }
     // Throttle
     throttle_str = throttle.ToString();
     this.throttle = throttle;
     // Sail on
     sailon_str = sailon.ToString();
     this.sailon = sailon;
     // Time
     this.duration = duration;
     this.days = Math.Floor(duration / SecondsPerDay);
     this.days_str = days.ToString();
     this.hours = Math.Floor(duration % SecondsPerDay / SecondsPerHour);
     this.hours_str = this.hours.ToString();
     this.duration = days * SecondsPerDay + hours * SecondsPerHour;
     duration_str = duration.ToString();
     // Warp factor
     this.iwarp = iwarp;
     warp = warpLevels[iwarp];
 }
 public static Control Default(Navigator navigator, Controls controls)
 {
     var frame = Frame.Frames[navigator.defaultFrame];
     var defaultAngles = new float [] { navigator.defaultAngle0, navigator.defaultAngle1, navigator.defaultAngle2 };
     var defaultDuration = navigator.defaultDays * SecondsPerDay + navigator.defaultHours * SecondsPerHour;
     return new Control(navigator, controls, defaultAngles, navigator.defaultThrottle, navigator.defaultSailon, defaultDuration, navigator.defaultIWarp, navigator.defaultFrame);
 }
        // Initialization
        public override void OnStart(StartState state)
        {
            // Base initialization
            base.OnStart(state);

            if (state != StartState.None && state != StartState.Editor) {

            // Find sails and persistent engines
            foreach (Part p in vessel.parts) {
            foreach (PartModule pm in p.Modules) {
            if (pm is SolarSailPart) {
                solarSails.Add((SolarSailPart)pm);
            } else if (pm is PersistentEngine) {
                var pm2 = (PersistentEngine)pm;
                if (pm2.IsPersistentEngine) {
                persistentEngines.Add((PersistentEngine)pm);
                }
            }
            }
            }

            if (solarSails.Count > 0 || persistentEngines.Count > 0) {
            // Persistent propulsion found
            anyPersistent = true;

            // Sail controls
            controls = new Controls(this);

            // Draw controls
            if (IsControlled) {
            RenderingManager.AddToPostDrawQueue(3, new Callback(controls.DrawControls));
            }
            } else {
            anyPersistent = false;
            Events["ShowControls"].active = false;
            Events["HideControls"].active = false;
            }
            }
        }