Code:

bool ShipIsPiloted() { List<IMyTerminalBlock> controlStations = new List<IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType<IMyCockpit>(controlStations); for (int i = 0; i < controlStations.Count; i++) { if ((controlStations[i] as IMyCockpit).IsUnderControl) { return true; } } return false; }