예제 #1
0
        public static bool HasThrustersInEveryDirection(this IMyCubeGrid Grid, IMyCockpit _cockpit = null)
        {
            IMyCockpit Cockpit = _cockpit != null ? _cockpit : GetFirstCockpit(Grid);

            if (Cockpit == null)
            {
                return(false);
            }
            List <IMyThrust> Thrusters = Grid.GetWorkingBlocks <IMyThrust>();

            if (Thrusters.Count < 6)
            {
                return(false);                     // There physically can't be a thruster in every direction
            }
            bool HasForwardThrust  = false;
            bool HasBackwardThrust = false;
            bool HasUpThrust       = false;
            bool HasDownThrust     = false;
            bool HasLeftThrust     = false;
            bool HasRightThrust    = false;

            foreach (IMyThrust Thruster in Grid.GetWorkingBlocks <IMyThrust>())
            {
                if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Forward)
                {
                    HasForwardThrust = true;
                }
                else if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Backward)
                {
                    HasBackwardThrust = true;
                }
                else if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Up)
                {
                    HasUpThrust = true;
                }
                else if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Down)
                {
                    HasDownThrust = true;
                }
                else if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Left)
                {
                    HasLeftThrust = true;
                }
                else if (Thruster.WorldMatrix.Forward == Cockpit.WorldMatrix.Right)
                {
                    HasRightThrust = true;
                }
            }

            return(HasForwardThrust && HasBackwardThrust && HasUpThrust && HasDownThrust && HasLeftThrust && HasRightThrust);
        }
예제 #2
0
 public static void DisableGyroOverride(this IMyCubeGrid Grid)
 {
     foreach (IMyGyro Gyro in Grid.GetWorkingBlocks <IMyGyro>())
     {
         Gyro.SetValueBool("Override", false);
     }
 }
예제 #3
0
        public static bool HasPower(this IMyCubeGrid Grid)
        {
            foreach (IMySlimBlock Reactor in Grid.GetWorkingBlocks <IMyReactor>())
            {
                if (Reactor != null && Reactor.FatBlock.IsWorking)
                {
                    return(true);
                }
            }
            foreach (IMySlimBlock Battery in Grid.GetWorkingBlocks <IMyBatteryBlock>())
            {
                if ((Battery as IMyBatteryBlock).CurrentStoredPower > 0f)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
 public static bool Has <T>(this IMyCubeGrid Grid) where T : class, IMyTerminalBlock
 {
     return(Grid.GetWorkingBlocks <T>().Count > 0);
 }
예제 #5
0
 public static IMyCockpit GetFirstCockpit(this IMyCubeGrid Grid)
 {
     return(Grid.GetWorkingBlocks <IMyCockpit>()[0]);
 }
예제 #6
0
 public static bool HasAnyThrusters(this IMyCubeGrid Grid)
 {
     return(Grid.GetWorkingBlocks <IMyThrust>().Count > 0);
 }
예제 #7
0
 public static bool HasGyros(this IMyCubeGrid Grid)
 {
     return(Grid.GetWorkingBlocks <IMyGyro>().Count > 0);
 }
예제 #8
0
 public static bool HasCockpit(this IMyCubeGrid Grid)
 {
     return(Grid.GetWorkingBlocks <IMyCockpit>().Count > 0);
 }