Example #1
0
        public void SetAilerons(IEnumerable <IMyMotorStator> rotors, float sensitivity, float trim)
        {
            m_controlSensitivity.Z = sensitivity;
            m_trim.Z = trim;

            List <FlightControlStator> statorList = new List <FlightControlStator>();

            foreach (IMyMotorStator stator in rotors)
            {
                Vector3 facing = stator.LocalMatrix.Up;
                if (facing == Pseudo.LocalMatrix.Forward || facing == Pseudo.LocalMatrix.Backward)
                {
                    Log.AlwaysLog("Facing the wrong way: " + stator.nameWithId() + ", facing: " + facing + ", local flight matrix: " + Pseudo.LocalMatrix, Logger.severity.WARNING);
                    continue;
                }

                FlightControlStator flightControl = new FlightControlStator(stator);
                if (!stator.IsOnSide(facing))
                {
                    Log.DebugLog("On " + Base6Directions.GetDirection(-facing) + " side and facing " + Base6Directions.GetDirection(facing));
                    flightControl.Flip();
                }

                statorList.Add(flightControl);
            }
            m_aileron = statorList.ToArray();
        }
Example #2
0
        public void SetRudders(IEnumerable <IMyMotorStator> rotors, float sensitivity, float trim)
        {
            m_controlSensitivity.Y = sensitivity;
            m_trim.Y = trim;

            List <FlightControlStator> statorList = new List <FlightControlStator>();

            foreach (IMyMotorStator stator in rotors)
            {
                Vector3 facing    = stator.LocalMatrix.Up;
                bool    isForward = stator.IsOnSide(Pseudo.LocalMatrix.Forward);
                Log.DebugLog(stator.DisplayNameText + " is on " + (isForward ? "forward" : "backward") + " side");

                FlightControlStator flightControl = new FlightControlStator(stator);
                if (facing == Pseudo.LocalMatrix.Up)
                {
                    if (!isForward)
                    {
                        Log.DebugLog("Aft and facing up: " + stator.DisplayNameText);
                        flightControl.Flip();
                    }
                }
                else if (facing == Pseudo.LocalMatrix.Down)
                {
                    if (isForward)
                    {
                        Log.DebugLog("Fore and facing down: " + stator.DisplayNameText);
                        flightControl.Flip();
                    }
                }
                else
                {
                    Log.AlwaysLog("Facing the wrong way: " + stator.nameWithId() + ", facing: " + facing + ", local flight matrix: " + Pseudo.LocalMatrix, Logger.severity.WARNING);
                    continue;
                }

                statorList.Add(flightControl);
            }
            m_rudder = statorList.ToArray();
        }