예제 #1
0
파일: Pilot.cs 프로젝트: ursineasylum/EDAP
        /// <summary>
        /// This handles cruising behaviour. The main function is already keeping us aligned;
        /// we just need to drop to 75% speed.
        /// This function could also do the final part:
        ///  1. press G when the "SAFE DISENGAGE" graphic is detected
        ///  2. Wait 5 seconds
        ///  3. Press Tab, X, 1,E,E,Space,S,Space to boost, cut throttle, and request docking (so the docking computer takes over).
        /// </summary>
        private void Cruise()
        {
            if (SecondsSinceFaceplant > 20 && OncePerJump(PilotState.cruiseStart))
            {
                Sounds.Play("cruise mode engaged.mp3");
                keyboard.Tap(keyThrottle100);      // full throttle
                keyboard.Tap(keyThrottleReduce25); // drop 25% throttle, to 75%
            }

            if (!state.HasFlag(PilotState.CruiseEnd) && cruiseSensor.MatchSafDisengag())
            {
                keyboard.Tap(keyHyperspace); // "Safe Disengage"
                state |= PilotState.DisengageStarted;
                return;
            }

            // disengage can take a while so wait for it to finish before continuing
            if (!state.HasFlag(PilotState.CruiseEnd) &&
                state.HasFlag(PilotState.DisengageStarted) &&
                !cruiseSensor.MatchSafDisengag())
            {
                state |= PilotState.CruiseEnd;
                state &= ~PilotState.Enabled;                                   // disable! we've arrived!
                // these commands will initiate docking if we have a computer
                Task.Delay(1000).ContinueWith(t => keyboard.Tap(keyBoost));     // boost
                Task.Delay(5000).ContinueWith(t => keyboard.Tap(keyThrottle0)); // cut throttle
                Task.Delay(8000).ContinueWith(t =>                              // request docking
                {
                    if (!state.HasFlag(PilotState.Cruise))
                    {
                        return; // abort docking request if cruise gets turned off
                    }
                    Sounds.PlayOneOf("time to dock.mp3", "its dock oclock.mp3", "autopilot disengaged.mp3");
                    keyboard.TapWait(keyNavMenu);      // nav menu
                    keyboard.TapWait(keyMenuTabRight); // tab right
                    keyboard.Tap(keyMenuTabRight);     // tab right
                    keyboard.Tap(keySelect);           // select first contact (the station)
                    keyboard.Tap(keyDown);             // down to the second option (request docking)
                    keyboard.Tap(keySelect);           // select request docking
                    keyboard.Tap(keyNavMenu);          // close nav menu

                    state &= ~PilotState.Cruise;       // disable! we've arrived!
                });
            }
        }
예제 #2
0
파일: Pilot.cs 프로젝트: ursineasylum/EDAP
 private bool OncePerJump(PilotState flag)
 {
     if (!state.HasFlag(flag))
     {
         state |= flag;
         return(true);
     }
     return(false);
 }