static JSIChatterer() { try { var loadedChattererAssy = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.name == "Chatterer"); if (loadedChattererAssy == null) { chattererFound = false; return; } //--- Process all the reflection info // MechJebCore chatterer_t = loadedChattererAssy.assembly.GetExportedTypes() .SingleOrDefault(t => t.FullName == "Chatterer.chatterer"); if (chatterer_t == null) { JUtil.LogErrorMessage(null, "Did not find Chatterer.chatterer"); return; } MethodInfo txMethod = chatterer_t.GetMethod("VesselIsTransmitting", BindingFlags.Instance | BindingFlags.Public); if (txMethod == null) { throw new NotImplementedException("txMethod"); } chattererTx = DynamicMethodDelegateFactory.CreateFuncBool(txMethod); MethodInfo rxMethod = chatterer_t.GetMethod("VesselIsReceiving", BindingFlags.Instance | BindingFlags.Public); if (rxMethod == null) { throw new NotImplementedException("rxMethod"); } chattererRx = DynamicMethodDelegateFactory.CreateFuncBool(rxMethod); MethodInfo chatterMethod = chatterer_t.GetMethod("InitiateChatter", BindingFlags.Instance | BindingFlags.Public); if (chatterMethod == null) { throw new NotImplementedException("chatterMethod"); } chattererStartTalking = DynamicMethodDelegateFactory.CreateAction(chatterMethod); } catch (Exception e) { chatterer_t = null; JUtil.LogMessage(null, "Exception initializing JSIChatterer: {0}", e); } if (chatterer_t != null && chattererStartTalking != null) { chattererFound = true; } else { chattererFound = false; } }
static JSIParachute() { try { rcModuleRealChute = AssemblyLoader.loadedAssemblies.SelectMany( a => a.assembly.GetExportedTypes()) .SingleOrDefault(t => t.FullName == "RealChute.RealChuteModule"); if (rcModuleRealChute == null) { rcFound = false; JUtil.LogMessage(null, "rcModuleRealChute is null"); return; } PropertyInfo rcAnyDeployed = rcModuleRealChute.GetProperty("AnyDeployed", BindingFlags.Instance | BindingFlags.Public); if (rcAnyDeployed == null) { JUtil.LogMessage(null, "rcAnyDeployed is null"); } MethodInfo rcGetAnyDeployed = rcAnyDeployed.GetGetMethod(); getAnyDeployed = DynamicMethodDelegateFactory.CreateFuncBool(rcGetAnyDeployed); if (getAnyDeployed == null) { JUtil.LogMessage(null, "getAnyDeployed is null"); } MethodInfo rcArmChute = rcModuleRealChute.GetMethod("GUIArm", BindingFlags.Instance | BindingFlags.Public); armChute = DynamicMethodDelegateFactory.CreateAction(rcArmChute); if (armChute == null) { JUtil.LogMessage(null, "armChute is null"); } MethodInfo rcDisarmChute = rcModuleRealChute.GetMethod("GUIDisarm", BindingFlags.Instance | BindingFlags.Public); disarmChute = DynamicMethodDelegateFactory.CreateAction(rcDisarmChute); if (disarmChute == null) { JUtil.LogMessage(null, "disarmChute is null"); } MethodInfo rcDeployChute = rcModuleRealChute.GetMethod("GUIDeploy", BindingFlags.Instance | BindingFlags.Public); deployChute = DynamicMethodDelegateFactory.CreateAction(rcDeployChute); if (deployChute == null) { JUtil.LogMessage(null, "deployChute is null"); } MethodInfo rcCutChute = rcModuleRealChute.GetMethod("GUICut", BindingFlags.Instance | BindingFlags.Public); cutChute = DynamicMethodDelegateFactory.CreateAction(rcCutChute); if (cutChute == null) { JUtil.LogMessage(null, "cutChute is null"); } rcArmed = rcModuleRealChute.GetField("armed", BindingFlags.Instance | BindingFlags.Public); if (rcArmed == null) { JUtil.LogMessage(null, "rcArmed is null"); } rcSafeState = rcModuleRealChute.GetField("safeState", BindingFlags.Instance | BindingFlags.Public); if (rcSafeState == null) { JUtil.LogMessage(null, "rcSafeState is null"); } } catch (Exception e) { JUtil.LogMessage(null, "static JSIParachute exception {0}", e); rcModuleRealChute = null; getAnyDeployed = null; armChute = null; disarmChute = null; deployChute = null; cutChute = null; rcArmed = null; rcSafeState = null; } if (rcModuleRealChute != null && armChute != null && getAnyDeployed != null && disarmChute != null && deployChute != null && cutChute != null && rcArmed != null && rcSafeState != null ) { rcFound = true; } else { rcFound = false; } }