private void EngageSmartASSOrbitalControl(MechJebModuleSmartASS.Target target) { MechJebCore masterMechJeb = this.vessel.GetMasterMechJeb(); if (masterMechJeb != null) { MechJebModuleSmartASS masterSmartASS = masterMechJeb.GetComputerModule <MechJebModuleSmartASS>(); if (masterSmartASS != null) { masterSmartASS.mode = MechJebModuleSmartASS.Mode.ORBITAL; masterSmartASS.target = target; masterSmartASS.Engage(); } else { Debug.LogError("MechJeb couldn't find MechJebModuleSmartASS for orbital control via action group."); } } else { Debug.LogError("MechJeb couldn't find the master MechJeb module for the current vessel."); } }
private void EngageSmartASSOrbitalControl(MechJebModuleSmartASS.Target target) { MechJebCore masterMechJeb = this.vessel.GetMasterMechJeb(); if (masterMechJeb != null) { MechJebModuleSmartASS masterSmartASS = masterMechJeb.GetComputerModule <MechJebModuleSmartASS>(); if (masterSmartASS != null && !masterSmartASS.hidden) { masterSmartASS.mode = MechJebModuleSmartASS.Mode.ORBITAL; masterSmartASS.target = target; masterSmartASS.Engage(); } else { //Log.err(Localizer.Format("#MechJeb_LogError_msg1"));//"MechJeb couldn't find MechJebModuleSmartASS for orbital control via action group." Log.err("couldn't find MechJebModuleSmartASS for orbital control via action group."); } } else { //Log.err(Localizer.Format("#MechJeb_LogError_msg0"));//"MechJeb couldn't find the master MechJeb module for the current vessel." Log.err("couldn't find the master MechJeb module for the current vessel."); } }
public void EngageSmartASSControl(MechJebModuleSmartASS.Mode mode, MechJebModuleSmartASS.Target target, bool forceEnable) { MechJebCore masterMechJeb = this.vessel.GetMasterMechJeb(); if (masterMechJeb != null) { MechJebModuleSmartASS masterSmartASS = masterMechJeb.GetComputerModule <MechJebModuleSmartASS>(); if (masterSmartASS != null) { if (forceEnable) { // Prevent that the presence of other attitude controllers disables SmartASS masterSmartASS.autoDisableSmartASS = false; } masterSmartASS.mode = mode; masterSmartASS.target = target; masterSmartASS.Engage(); masterSmartASS.enabled = true; // show GUI } else { Debug.LogError("MechJeb couldn't find MechJebModuleSmartASS for control."); } } else { Debug.LogError("MechJeb couldn't find the master MechJeb module for the current vessel."); } }
private void EngageSmartASSOrbitalControl(MechJebModuleSmartASS.Target target) { MechJebCore masterMechJeb = this.vessel.GetMasterMechJeb(); if (masterMechJeb != null) { MechJebModuleSmartASS masterSmartASS = masterMechJeb.GetComputerModule <MechJebModuleSmartASS>(); if (!masterSmartASS.hidden) { EngageSmartASSControl(MechJebModuleSmartASS.Mode.ORBITAL, target, false); } } }
public MechJebModuleScriptActionSmartASS(MechJebModuleScript scriptModule, MechJebCore core, MechJebModuleScriptActionsList actionsList) : base(scriptModule, core, actionsList, NAME) { this.smartAss = core.GetComputerModule <MechJebModuleSmartASS>(); int modeIdx = 0; foreach (MechJebModuleSmartASS.Target target in Enum.GetValues(typeof(MechJebModuleSmartASS.Target))) { if (TargetIsMode[(int)target] && target != MechJebModuleSmartASS.Target.AUTO) { isTargetMode.Add(true); modeModes.Add((MechJebModuleSmartASS.Mode) 0); targetModes.Add(target); modeStrings.Add(TargetTexts[(int)target]); targetModeSelectorIdxs[(int)target] = modeIdx++; } } foreach (MechJebModuleSmartASS.Mode mode in Enum.GetValues(typeof(MechJebModuleSmartASS.Mode))) { if (mode != MechJebModuleSmartASS.Mode.AUTO) { modeModes.Add(mode); isTargetMode.Add(false); targetModes.Add((MechJebModuleSmartASS.Target) 0); modeStrings.Add(ModeTexts[(int)mode]); modeModeSelectorIdxs[(int)mode] = modeIdx++; targets[(int)mode] = new List <MechJebModuleSmartASS.Target>(); targetStrings[(int)mode] = new List <String>(); } } foreach (MechJebModuleSmartASS.Target target in Enum.GetValues(typeof(MechJebModuleSmartASS.Target))) { if (!TargetIsMode[(int)target]) { MechJebModuleSmartASS.Mode mode = Target2Mode[(int)target]; targetSelectorIdxs[(int)target] = targets[(int)mode].Count; targets[(int)mode].Add(target); targetStrings[(int)mode].Add(TargetTexts[(int)target]); } } }
/* Note to self: foreach (ThatEnumType item in (ThatEnumType[]) Enum.GetValues(typeof(ThatEnumType))) can save a lot of time here. */ private void UpdateJebReferences() { activeJeb = vessel.GetMasterMechJeb(); // Node executor is activeJeb.node activeSmartass = activeJeb != null ? activeJeb.GetComputerModule<MechJebModuleSmartASS>() : null; }
private static bool ReturnTargetState(MechJebModuleSmartASS.Target action, Vessel ourVessel) { MechJebCore activeJeb = ourVessel.GetMasterMechJeb(); if (activeJeb == null) return false; MechJebModuleSmartASS activeSmartass = activeJeb.GetComputerModule<MechJebModuleSmartASS>(); if (activeSmartass == null) return false; return action == activeSmartass.target; }
// and these are the two functions that actually do the work. private static void EnactTargetAction(MechJebModuleSmartASS.Target action, Vessel ourVessel) { MechJebCore activeJeb = ourVessel.GetMasterMechJeb(); if (activeJeb == null) return; MechJebModuleSmartASS activeSmartass = activeJeb.GetComputerModule<MechJebModuleSmartASS>(); if (activeSmartass == null) return; activeSmartass.target = action; activeSmartass.Engage(); }