/* MONOBEHAVIOUR METHODS */ public static void Initialize() { Debug.Log("[PR] Initializing MechJeb wrapper..."); mjAvailable = false; try { mjCore_t = Reflection.GetExportedType("MechJeb2", "MuMech.MechJebCore"); if (mjCore_t == null) { return; } mjVesselExtensions_t = Reflection.GetExportedType("MechJeb2", "MuMech.VesselExtensions"); if (mjVesselExtensions_t == null) { return; } Type mjModuleSmartass_t = Reflection.GetExportedType("MechJeb2", "MuMech.MechJebModuleSmartASS"); if (mjModuleSmartass_t == null) { return; } saTarget_t = mjModuleSmartass_t.GetField("target", BindingFlags.Instance | BindingFlags.Public); if (saTarget_t == null) { return; } MethodInfo GetMasterMechJeb_t = mjVesselExtensions_t.GetMethod("GetMasterMechJeb", BindingFlags.Static | BindingFlags.Public); if (GetMasterMechJeb_t == null) { return; } GetMasterMechJeb = Reflection.CreateFunc <Vessel>(GetMasterMechJeb_t); if (GetMasterMechJeb == null) { return; } MethodInfo GetComputerModule_t = mjCore_t.GetMethod("GetComputerModule", new Type[] { typeof(string) }); if (GetComputerModule_t == null) { return; } GetComputerModule = Reflection.CreateFunc <object, string>(GetComputerModule_t); if (GetComputerModule == null) { return; } Type mjComputerModule_t = Reflection.GetExportedType("MechJeb2", "MuMech.ComputerModule"); if (mjComputerModule_t == null) { return; } PropertyInfo mjModuleEnabledProperty = mjComputerModule_t.GetProperty("enabled", BindingFlags.Instance | BindingFlags.Public); MethodInfo mjModuleEnabled = null; if (mjModuleEnabledProperty != null) { mjModuleEnabled = mjModuleEnabledProperty.GetGetMethod(); } if (mjModuleEnabled == null) { return; } ModuleEnabled = Reflection.CreateFuncBool <object>(mjModuleEnabled); mjAvailable = true; Debug.Log("[PR] MechJeb reflection successfull!"); } catch { Debug.LogWarning("[PR] MechJeb exception."); } }