RelayExtensions: Added Vessel.HasConnectedRelay.
[AntennaRange.git] / RelayExtensions.cs
blob:a/RelayExtensions.cs -> blob:b/RelayExtensions.cs
--- a/RelayExtensions.cs
+++ b/RelayExtensions.cs
@@ -76,6 +76,24 @@
 		{
 			return RelayDatabase.Instance[vessel].Values.ToList();
 		}
+
+		/// <summary>
+		/// Determines if the specified vessel has a connected relay.
+		/// </summary>
+		/// <returns><c>true</c> if the specified vessel has a connected relay; otherwise, <c>false</c>.</returns>
+		/// <param name="vessel"></param>
+		public static bool HasConnectedRelay(this Vessel vessel)
+		{
+			foreach (IAntennaRelay relay in RelayDatabase.Instance[vessel].Values)
+			{
+				if (relay.CanTransmit())
+				{
+					return true;
+				}
+			}
+
+			return false;
+		}
 	}
 }