public override void Drive(FlightCtrlState s) { // Fix the Translatron behavuous with kill HS. // TODO : proper fix that register the attitude controler oustide of Drive if (!core.attitude.users.Contains(this) && (core.thrust.trans_kill_h && core.thrust.tmode != MechJebModuleThrustController.TMode.OFF)) { core.attitude.users.Add(this); } if (core.attitude.users.Contains(this) && (!core.thrust.trans_kill_h || core.thrust.tmode == MechJebModuleThrustController.TMode.OFF)) { core.attitude.users.Remove(this); } if (abort != AbortStage.OFF) { switch (abort) { case AbortStage.THRUSTOFF: FlightInputHandler.SetNeutralControls(); s.mainThrottle = 0; abort = AbortStage.DECOUPLE; break; case AbortStage.DECOUPLE: recursiveDecouple(); abort = AbortStage.BURNUP; burnUpTime = Planetarium.GetUniversalTime(); break; case AbortStage.BURNUP: if ((Planetarium.GetUniversalTime() - burnUpTime < 2) || (vesselState.speedVertical < 10)) { core.thrust.tmode = MechJebModuleThrustController.TMode.DIRECT; core.attitude.attitudeTo(Vector3d.up, AttitudeReference.SURFACE_NORTH, this); double int_error = Math.Abs(Vector3d.Angle(vesselState.up, vesselState.forward)); core.thrust.trans_spd_act = (int_error < 90) ? 100 : 0; } else { abort = AbortStage.LAND; } break; case AbortStage.LAND: core.thrust.users.Remove(this); core.GetComputerModule <MechJebModuleLandingAutopilot>().LandUntargeted(this); abort = AbortStage.LANDING; break; case AbortStage.LANDING: if (vessel.LandedOrSplashed) { abort = AbortStage.OFF; } break; } } base.Drive(s); }
public override void onControlLost() { if (abort != AbortStage.OFF) { abort = AbortStage.OFF; } base.onControlLost(); }
public override void Drive(FlightCtrlState s) { // Fix the Translatron behavuous with kill HS. // TODO : proper fix that register the attitude controler oustide of Drive if (!core.attitude.users.Contains(this) && ( core.thrust.trans_kill_h && core.thrust.tmode != MechJebModuleThrustController.TMode.OFF)) { core.attitude.users.Add(this); } if ( core.attitude.users.Contains(this) && (!core.thrust.trans_kill_h || core.thrust.tmode == MechJebModuleThrustController.TMode.OFF)) { core.attitude.users.Remove(this); } if (abort != AbortStage.OFF) { switch (abort) { case AbortStage.THRUSTOFF: FlightInputHandler.SetNeutralControls(); s.mainThrottle = 0; abort = AbortStage.DECOUPLE; break; case AbortStage.DECOUPLE: recursiveDecouple(); abort = AbortStage.BURNUP; burnUpTime = Planetarium.GetUniversalTime(); break; case AbortStage.BURNUP: if ((Planetarium.GetUniversalTime() - burnUpTime < 2) || (vesselState.speedVertical < 10)) { core.thrust.tmode = MechJebModuleThrustController.TMode.DIRECT; core.attitude.attitudeTo(Vector3d.up, AttitudeReference.SURFACE_NORTH, this); double int_error = Math.Abs(Vector3d.Angle(vesselState.up, vesselState.forward)); core.thrust.trans_spd_act = (int_error < 90) ? 100 : 0; } else { abort = AbortStage.LAND; } break; case AbortStage.LAND: core.thrust.users.Remove(this); core.GetComputerModule<MechJebModuleLandingAutopilot>().LandUntargeted(this); abort = AbortStage.LANDING; break; case AbortStage.LANDING: if (vessel.LandedOrSplashed) { abort = AbortStage.OFF; } break; } } base.Drive(s); }
public override void drive(FlightCtrlState s) { if (abort != AbortStage.OFF) { switch (abort) { case AbortStage.THRUSTOFF: FlightInputHandler.SetNeutralControls(); s.mainThrottle = 0; abort = AbortStage.DECOUPLE; break; case AbortStage.DECOUPLE: recursiveDecouple(); abort = AbortStage.BURNUP; burnUpTime = Planetarium.GetUniversalTime(); break; case AbortStage.BURNUP: if ((Planetarium.GetUniversalTime() - burnUpTime < 2) || (vesselState.speedVertical < 10)) { core.tmode = MechJebCore.TMode.DIRECT; core.attitudeTo(Vector3d.up, MechJebCore.AttitudeReference.SURFACE_NORTH, this); double int_error = Math.Abs(Vector3d.Angle(vesselState.up, vesselState.forward)); core.trans_spd_act = (int_error < 90) ? 100 : 0; } else { abort = AbortStage.LAND; } break; case AbortStage.LAND: core.controlRelease(this); core.landActivate(this); abort = AbortStage.OFF; break; } } base.drive(s); }
public void PanicSwitch() { if (abort != AbortStage.OFF) { if ((abort == AbortStage.LAND) || (abort == AbortStage.LANDING)) { core.GetComputerModule <MechJebModuleLandingAutopilot>().StopLanding(); } else { core.thrust.ThrustOff(); core.thrust.users.Remove(this); core.attitude.attitudeDeactivate(); } abort = AbortStage.OFF; } else { abort = AbortStage.THRUSTOFF; core.thrust.users.Add(this); } }
protected override void WindowGUI(int windowID) { GUIStyle sty = new GUIStyle(GUI.skin.button); sty.normal.textColor = sty.focused.textColor = Color.white; sty.hover.textColor = sty.active.textColor = Color.yellow; sty.onNormal.textColor = sty.onFocused.textColor = sty.onHover.textColor = sty.onActive.textColor = Color.green; sty.padding = new RectOffset(8, 8, 8, 8); GUILayout.BeginVertical(); if ((core.thrust.users.Count > 1) && !core.thrust.users.Contains(this)) { if (!autoMode) { windowPos = new Rect(windowPos.x, windowPos.y, 10, 10); autoMode = true; } sty.normal.textColor = Color.red; sty.onActive = sty.onFocused = sty.onHover = sty.onNormal = sty.active = sty.focused = sty.hover = sty.normal; GUILayout.Button("AUTO", sty, GUILayout.ExpandWidth(true)); } else { if (autoMode) { windowPos = new Rect(windowPos.x, windowPos.y, 10, 10); autoMode = false; } MechJebModuleThrustController.TMode oldMode = core.thrust.tmode; core.thrust.tmode = (MechJebModuleThrustController.TMode)GUILayout.SelectionGrid((int)core.thrust.tmode, trans_texts, 2, sty); if (core.thrust.tmode != oldMode) { core.thrust.trans_spd_act = Convert.ToInt16(trans_spd); windowPos = new Rect(windowPos.x, windowPos.y, 10, 10); if (core.thrust.tmode == MechJebModuleThrustController.TMode.OFF) { core.thrust.users.Remove(this); } else { core.thrust.users.Add(this); } } core.thrust.trans_kill_h = GUILayout.Toggle(core.thrust.trans_kill_h, "Kill H/S", GUILayout.ExpandWidth(true)); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Speed"); trans_spd = GUILayout.TextField(trans_spd, GUILayout.ExpandWidth(true)); trans_spd = Regex.Replace(trans_spd, @"[^\d.+-]", ""); GUILayout.EndHorizontal(); if (GUILayout.Button("EXECUTE", sty, GUILayout.ExpandWidth(true))) { core.thrust.trans_spd_act = Convert.ToSingle(trans_spd); GUIUtility.keyboardControl = 0; } } if (core.thrust.tmode != MechJebModuleThrustController.TMode.OFF) { GUILayout.Label("Active speed: " + MuMech.MuUtils.ToSI(core.thrust.trans_spd_act) + "m/s", GUILayout.ExpandWidth(true)); } GUILayout.FlexibleSpace(); GUIStyle tsty = new GUIStyle(GUI.skin.label); tsty.alignment = TextAnchor.UpperCenter; GUILayout.Label("Automation", tsty, GUILayout.ExpandWidth(true)); sty.normal.textColor = sty.focused.textColor = sty.hover.textColor = sty.active.textColor = sty.onNormal.textColor = sty.onFocused.textColor = sty.onHover.textColor = sty.onActive.textColor = (abort != AbortStage.OFF) ? Color.red : Color.green; if (GUILayout.Button((abort != AbortStage.OFF) ? "DON'T PANIC!" : "PANIC!!!", sty, GUILayout.ExpandWidth(true))) { if (abort != AbortStage.OFF) { if ((abort == AbortStage.LAND) || (abort == AbortStage.LANDING)) { core.GetComputerModule <MechJebModuleLandingAutopilot>().StopLanding(); } else { core.thrust.ThrustOff(); core.thrust.users.Remove(this); core.attitude.attitudeDeactivate(); } abort = AbortStage.OFF; } else { abort = AbortStage.THRUSTOFF; core.thrust.users.Add(this); } } GUILayout.EndVertical(); base.WindowGUI(windowID); }
public void PanicSwitch() { if (abort != AbortStage.OFF) { if ((abort == AbortStage.LAND) || (abort == AbortStage.LANDING)) { core.GetComputerModule<MechJebModuleLandingAutopilot>().StopLanding(); } else { core.thrust.ThrustOff(); core.thrust.users.Remove(this); core.attitude.attitudeDeactivate(); } abort = AbortStage.OFF; } else { abort = AbortStage.THRUSTOFF; core.thrust.users.Add(this); } }
protected override void WindowGUI(int windowID) { GUIStyle sty = new GUIStyle(GUI.skin.button); sty.normal.textColor = sty.focused.textColor = Color.white; sty.hover.textColor = sty.active.textColor = Color.yellow; sty.onNormal.textColor = sty.onFocused.textColor = sty.onHover.textColor = sty.onActive.textColor = Color.green; sty.padding = new RectOffset(8, 8, 8, 8); GUILayout.BeginVertical(); if ((core.controlModule != null) || core.trans_land) { if (!autoMode) { windowPos = new Rect(windowPos.x, windowPos.y, 10, 10); autoMode = true; } sty.normal.textColor = Color.red; sty.onActive = sty.onFocused = sty.onHover = sty.onNormal = sty.active = sty.focused = sty.hover = sty.normal; GUILayout.Button("AUTO", sty, GUILayout.ExpandWidth(true)); } else { if (autoMode) { windowPos = new Rect(windowPos.x, windowPos.y, 10, 10); autoMode = false; } MechJebCore.TMode oldMode = core.tmode; core.tmode = (MechJebCore.TMode)GUILayout.SelectionGrid((int)core.tmode, trans_texts, 2, sty); if (core.tmode != oldMode) { core.trans_spd_act = Convert.ToInt16(trans_spd); windowPos = new Rect(windowPos.x, windowPos.y, 10, 10); } core.trans_kill_h = GUILayout.Toggle(core.trans_kill_h, "Kill H/S", GUILayout.ExpandWidth(true)); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Speed"); trans_spd = GUILayout.TextField(trans_spd, GUILayout.ExpandWidth(true)); trans_spd = Regex.Replace(trans_spd, @"[^\d.+-]", ""); GUILayout.EndHorizontal(); if (GUILayout.Button("EXECUTE", sty, GUILayout.ExpandWidth(true))) { core.trans_spd_act = Convert.ToInt16(trans_spd); GUIUtility.keyboardControl = 0; } } if (core.tmode != MechJebCore.TMode.OFF) { GUILayout.Label("Active speed: " + MuMech.MuUtils.ToSI(core.trans_spd_act) + "m/s", GUILayout.ExpandWidth(true)); } GUILayout.FlexibleSpace(); GUIStyle tsty = new GUIStyle(GUI.skin.label); tsty.alignment = TextAnchor.UpperCenter; GUILayout.Label("Automation", tsty, GUILayout.ExpandWidth(true)); sty.normal.textColor = sty.focused.textColor = sty.hover.textColor = sty.active.textColor = sty.onNormal.textColor = sty.onFocused.textColor = sty.onHover.textColor = sty.onActive.textColor = (abort != AbortStage.OFF) ? Color.red : Color.green; if (GUILayout.Button((abort != AbortStage.OFF) ? "DON'T PANIC!" : "PANIC!!!", sty, GUILayout.ExpandWidth(true))) { abort = (abort == AbortStage.OFF) ? AbortStage.THRUSTOFF : AbortStage.OFF; if (abort == AbortStage.OFF) { core.controlRelease(this); } else { core.controlClaim(this, true); } } GUILayout.EndVertical(); base.WindowGUI(windowID); }