Got VesselRegister ported, and coupled into the Rendezvous window as before. This seems a little messy.
[VOID.git] / VOID_Rendezvous.cs
blob:a/VOID_Rendezvous.cs -> blob:b/VOID_Rendezvous.cs
--- a/VOID_Rendezvous.cs
+++ b/VOID_Rendezvous.cs
@@ -20,6 +20,8 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 using KSP;
 using System;
+using System.Collections.Generic;
+using System.Linq;
 using UnityEngine;
 
 namespace VOID
@@ -32,7 +34,7 @@
 		[AVOID_SaveValue("toggleExtendedOrbital")]
 		protected VOID_SaveValue<bool> toggleExtendedOrbital = false;
 
-		protected Vessel selectedVessel;
+		protected VOID_VesselRegister RegisterModule;
 
 		public VOID_Rendezvous()
 		{
@@ -44,6 +46,8 @@
 			Vessel rendezvessel = new Vessel();
 			CelestialBody rendezbody = new CelestialBody();
 
+			this.RegisterModule = VOID_Core.Instance.Modules.Where(m => typeof(VOID_VesselRegister).IsAssignableFrom(m.GetType())).FirstOrDefault() as VOID_VesselRegister;
+
 			GUILayout.BeginVertical();
 
 			//display both
@@ -79,16 +83,16 @@
 			}
 
 			//Show Vessel Register vessel info
-			if (untoggleRegisterInfo == false)
+			if (untoggleRegisterInfo == false && this.RegisterModule != default(IVOID_Module))
 			{
 				GUILayout.Label("Vessel Register:", VOID_Core.Instance.LabelStyles["center_bold"]);
-				if (selectedVessel != null)
-				{
-					rendezvessel = selectedVessel;
+				if (this.RegisterModule.selectedVessel != null)
+				{
+					rendezvessel = this.RegisterModule.selectedVessel;
 					display_rendezvous_info(rendezvessel, null);
 
 					//show set/unset buttons
-					if (FlightGlobals.fetch.VesselTarget == null || (FlightGlobals.fetch.VesselTarget != null && FlightGlobals.fetch.VesselTarget.GetVessel() != selectedVessel))
+					if (FlightGlobals.fetch.VesselTarget == null || (FlightGlobals.fetch.VesselTarget != null && FlightGlobals.fetch.VesselTarget.GetVessel() != this.RegisterModule.selectedVessel))
 					{
 						//no Tgt set or Tgt is not this vessel
 						//show a Set button