Esempio n. 1
0
        private IEnumerator OnControlClick(FlightControlOutput output)
        {
            yield return(null);

            if (mFlightComputer.InputAllowed)
            {
                switch (output)
                {
                case FlightControlOutput.IgnorePitch:
                    if ((mControlOutputMask & FlightControlOutput.IgnorePitch) == FlightControlOutput.IgnorePitch)
                    {
                        mControlOutputMask &= ~FlightControlOutput.IgnorePitch;
                    }
                    else
                    {
                        mControlOutputMask |= FlightControlOutput.IgnorePitch;
                    }
                    break;

                case FlightControlOutput.IgnoreHeading:
                    if ((mControlOutputMask & FlightControlOutput.IgnoreHeading) == FlightControlOutput.IgnoreHeading)
                    {
                        mControlOutputMask &= ~FlightControlOutput.IgnoreHeading;
                    }
                    else
                    {
                        mControlOutputMask |= FlightControlOutput.IgnoreHeading;
                    }
                    break;

                case FlightControlOutput.IgnoreRoll:
                    if ((mControlOutputMask & FlightControlOutput.IgnoreRoll) == FlightControlOutput.IgnoreRoll)
                    {
                        mControlOutputMask &= ~FlightControlOutput.IgnoreRoll;
                    }
                    else
                    {
                        mControlOutputMask |= FlightControlOutput.IgnoreRoll;
                    }
                    break;
                }

                bool pitch   = (mControlOutputMask & FlightControlOutput.IgnorePitch) == FlightControlOutput.IgnorePitch,
                     heading = (mControlOutputMask & FlightControlOutput.IgnoreHeading) == FlightControlOutput.IgnoreHeading,
                     roll    = (mControlOutputMask & FlightControlOutput.IgnoreRoll) == FlightControlOutput.IgnoreRoll;

                mFlightComputer.Enqueue(FlightControlCommand.WithPHR(pitch, heading, roll));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get the current active FlightMode and map it to the Computermode
        /// </summary>
        public void getActiveFlightMode()
        {
            // check the current flight mode
            if (mFlightComputer.CurrentFlightMode == null)
            {
                Reset();
                return;
            }

            // get active command
            SimpleTypes.ComputerModeMapper mappedCommand = mFlightComputer.CurrentFlightMode.mapFlightMode();
            mMode     = mappedCommand.computerMode;
            mAttitude = FlightAttitude.Null;

            if (mMode == ComputerMode.Orbital || mMode == ComputerMode.Surface || mMode == ComputerMode.TargetPos || mMode == ComputerMode.TargetVel)
            {
                mAttitude = mappedCommand.computerAttitude;
            }

            var activeIgnoreCmd = FlightControlCommand.findActiveControlCmd(mFlightComputer);

            if (activeIgnoreCmd != null)
            {
                mControlOutputMask = 0;
                if (activeIgnoreCmd.ignorePitchOutput)
                {
                    mControlOutputMask |= FlightControlOutput.IgnorePitch;
                }
                if (activeIgnoreCmd.ignoreHeadingOutput)
                {
                    mControlOutputMask |= FlightControlOutput.IgnoreHeading;
                }
                if (activeIgnoreCmd.ignoreRollOutput)
                {
                    mControlOutputMask |= FlightControlOutput.IgnoreRoll;
                }
            }
        }