예제 #1
0
파일: Pilot.cs 프로젝트: ursineasylum/EDAP
        /// <summary>
        /// Fly close past the star
        /// </summary>
        private void Scoop()
        {
            int scoopWaitSeconds   = Properties.Settings.Default.scoopWaitSeconds;
            int scoopFinishSeconds = Properties.Settings.Default.scoopFinishSeconds;

            //RIP-- WIP, I guess
            if (cruiseSensor.EmergencyDrop())
            {
                keyboard.Tap(keyThrottle0);
                state &= ~PilotState.Enabled; // disable! we're f****d!
                Sounds.Play("oh f**k.mp3");
                return;
            }

            // if we try to select the star earlier than this, sometimes it selects the wrong thing
            if (SecondsSinceFaceplant < 2)
            {
                return;
            }

            // roll so that the star is below (makes pitch up quicker -- less likely to collide in slow ships)
            if (OncePerJump(PilotState.SelectStar))
            {
                if (!SelectStar())
                {
                    keyboard.TapWait(keyThrottle0);
                    state &= ~PilotState.Enabled; // disable! we're f****d!
                    keyboard.TapWait(keySuperCruise);
                    Sounds.Play("oh f**k.mp3");
                    return;
                }
            }
            AlignCompass(bPitchYaw: false);

            //Set a value to confirm that we've actually started scooping
            if (OncePerJump(PilotState.ScoopStart))
            {
                keyboard.Tap(keyThrottle50); // 50% throttle
            }
            // (barely) avoid crashing into the star
            bool collisionImminent = cruiseSensor.MatchImpact() || compassRecognizer.MatchFaceplant();

            keyboard.SetKeyState(keyPitchUp, collisionImminent);

            // start speeding up towards the end so we don't crash/overheat
            // Keep the scoopwaitseconds as a "general idea" of when to start pulling up, at least until maybe a check for "full tank"
            if (SecondsSinceFaceplant > scoopWaitSeconds && OncePerJump(PilotState.ScoopMiddle))
            {
                keyboard.Tap(keyThrottle100);
            }

            //If the fueling is complete, we probably want to GTFO
            if (cruiseSensor.FuelComplete())
            {
                if (OncePerJump(PilotState.ScoopMiddle))
                {
                    keyboard.Tap(keyThrottle100);
                }
            }


            //If we've passed the expected wait point and the Scoop Active display is gone, flag appropriately and wait for scoopFinishSeconds to pass
            if (state.HasFlag(PilotState.ScoopMiddle) && !state.HasFlag(PilotState.ScoopDeactive) && !cruiseSensor.MatchScooping())
            {
                SecondsUntilScoopComplete = SecondsSinceFaceplant + scoopFinishSeconds;
                Console.WriteLine(string.Format("Match scooping is not true at {0}", SecondsSinceFaceplant));
                OncePerJump(PilotState.ScoopDeactive);
                status += string.Format("Finalizing scoop + {0:0.0}\n", SecondsSinceFaceplant);


                //We're far enough away from the scoop range for heat to be a non-issue
            }
            else if (state.HasFlag(PilotState.ScoopDeactive) && SecondsSinceFaceplant > SecondsUntilScoopComplete)
            {
                state  |= PilotState.scoopComplete;
                status += string.Format("Finalizing scoop + {0:0.0}\n", SecondsSinceFaceplant);
            }
            else
            {
                status += string.Format("Scoop wait + {0:0.0}\n", SecondsSinceFaceplant);
            }
        }