void ManeuveringThrust()
        {
            if (maneuveringThrusters.Count == 0)
            {
                Echo("No side thrust found");
            }

            GridTerminalSystem.SearchBlocksOfName(maneuveringThrustersName, maneuveringThrusters);
            for (int i = 0; i < maneuveringThrusters.Count; i++)
            {
                IMyThrust Thrust = maneuveringThrusters[i] as IMyThrust;
                Thrust.ApplyAction("OnOff_On");
            }
        }
        void ThrusterOverride()
        {
            if (forwardThrusters.Count == 0)
            {
                Echo("No forward thrust found");
            }

            GridTerminalSystem.SearchBlocksOfName(forwardThrustName, forwardThrusters);
            for (int i = 0; i < forwardThrusters.Count; i++)
            {
                IMyThrust Thrust = forwardThrusters[i] as IMyThrust;
                Thrust.ApplyAction("OnOff_On");
                Thrust.SetValue <float>("Override", float.MaxValue);
            }
        }
Esempio n. 3
0
        public void thrusterControllr(IMyThrust thruster)
        {
            var   Orientation = cockpit.WorldMatrix.Forward;
            float ang         = 10;

            var move = cockpit.MoveIndicator;
            var Rota = cockpit.RotationIndicator;
            var Roll = cockpit.RollIndicator;

            //str = "MoveIndicator:" + cockpit.Name + cockpit.MoveIndicator.ToString() + "\r\n";
            //str = str + "RotationIndicator:" + cockpit.RotationIndicator.ToString() + "\r\n";
            //str = str + "RollIndicator:"  + cockpit.RollIndicator.ToString() + "\r\n" + "\r\n" + "\r\n";

            if (move.Length() == 0 && Rota.Length() == 0 && Roll == 0)
            {
                thruster.ApplyAction("OnOff_On");
                return;
            }


            if (move.Z > 0)
            {
                var angle = Math.Acos(Vector3D.Normalize(thruster.WorldMatrix.Forward).Dot(Vector3D.Normalize(cockpit.WorldMatrix.Up)));
                if (MathHelper.ToDegrees(angle) < ang && MathHelper.ToDegrees(angle) > 0)
                {
                    thruster.ApplyAction("OnOff_On");
                    str = str + MathHelper.ToDegrees(angle).ToString() + "\r\n";
                    thruster.ThrustOverridePercentage = 100;
                    return;
                }
                else if (MathHelper.ToDegrees(angle) > (180 - ang))
                {
                    thruster.ApplyAction("OnOff_Off");
                }
            }
            else if (move.Z < 0)
            {
                //var angle = Math.Acos(thruster.WorldMatrix.Forward.Dot(cockpit.WorldMatrix.Down));
                var angle = Math.Acos(Vector3D.Normalize(thruster.WorldMatrix.Forward).Dot(Vector3D.Normalize(cockpit.WorldMatrix.Down)));
                if (MathHelper.ToDegrees(angle) < ang && MathHelper.ToDegrees(angle) > 0)
                {
                    thruster.ApplyAction("OnOff_On");
                    str = str + MathHelper.ToDegrees(angle).ToString() + "\r\n";
                    thruster.ThrustOverridePercentage = 100;
                    return;
                }
                else if (MathHelper.ToDegrees(angle) > (180 - ang))
                {
                    thruster.ApplyAction("OnOff_Off");
                }
            }

            if (move.X > 0)
            {
                var angle = Math.Acos(Vector3D.Normalize(thruster.WorldMatrix.Forward).Dot(Vector3D.Normalize(cockpit.WorldMatrix.Right)));
                //var angle = Math.Acos(thruster.WorldMatrix.Forward.Dot(cockpit.WorldMatrix.Right));
                if (MathHelper.ToDegrees(angle) < ang && MathHelper.ToDegrees(angle) > 0)
                {
                    thruster.ApplyAction("OnOff_On");
                    str = str + MathHelper.ToDegrees(angle).ToString() + "\r\n";
                    thruster.ThrustOverridePercentage = 100;
                    return;
                }
                else if (MathHelper.ToDegrees(angle) > (180 - ang))
                {
                    thruster.ApplyAction("OnOff_Off");
                }
            }
            else if (move.X < 0)
            {
                var angle = Math.Acos(Vector3D.Normalize(thruster.WorldMatrix.Forward).Dot(Vector3D.Normalize(cockpit.WorldMatrix.Left)));
                //var angle = Math.Acos(thruster.WorldMatrix.Forward.Dot(cockpit.WorldMatrix.Left));
                if (MathHelper.ToDegrees(angle) < ang && MathHelper.ToDegrees(angle) > 0)
                {
                    thruster.ApplyAction("OnOff_On");
                    str = str + MathHelper.ToDegrees(angle).ToString() + "\r\n";
                    thruster.ThrustOverridePercentage = 100;
                    return;
                }
                else if (MathHelper.ToDegrees(angle) > (180 - ang))
                {
                    thruster.ApplyAction("OnOff_Off");
                }
            }



            if (move.Y > 0)
            {
                var angle = Math.Acos(Vector3D.Normalize(thruster.WorldMatrix.Forward).Dot(Vector3D.Normalize(cockpit.WorldMatrix.Backward)));
                //var angle = Math.Acos(thruster.WorldMatrix.Forward.Dot(cockpit.WorldMatrix.Backward));
                if (MathHelper.ToDegrees(angle) < ang && MathHelper.ToDegrees(angle) > 0)
                {
                    thruster.ApplyAction("OnOff_On");
                    str = str + MathHelper.ToDegrees(angle).ToString() + "\r\n";
                    thruster.ThrustOverridePercentage = 100;
                    return;
                }
                else if (MathHelper.ToDegrees(angle) > (180 - ang))
                {
                    thruster.ApplyAction("OnOff_Off");
                }
            }
            else if (move.Y < 0)
            {
                var angle = Math.Acos(Vector3D.Normalize(thruster.WorldMatrix.Forward).Dot(Vector3D.Normalize(cockpit.WorldMatrix.Forward)));
                //var angle = Math.Acos(thruster.WorldMatrix.Forward.Dot(cockpit.WorldMatrix.Forward));
                if (MathHelper.ToDegrees(angle) < ang && MathHelper.ToDegrees(angle) > 0)
                {
                    thruster.ApplyAction("OnOff_On");
                    str = str + MathHelper.ToDegrees(angle).ToString() + "\r\n";
                    thruster.ThrustOverridePercentage = 100;
                    return;
                }
                else if (MathHelper.ToDegrees(angle) > (180 - ang))
                {
                    thruster.ApplyAction("OnOff_On");
                    thruster.ApplyAction("OnOff_Off");
                }
            }

            //thruster.ApplyAction("OnOff_Off");
            thruster.ThrustOverridePercentage = 0;
            //text.WritePublicText(str);
        }
Esempio n. 4
0
 public void stop()
 {
     th.ApplyAction("OnOff_On");
     _set(0);
 }