Beispiel #1
0
 public PlaneChange(MechJebCore core) : base(core)
 {
 }
        /// <summary>
        /// Indicate whether a Hohmann Transfer Orbit can be plotted
        /// </summary>
        /// <returns>true if a transfer can be plotted, false if not</returns>
        public bool ButtonPlotHohmannTransferState()
        {
            MechJebCore activeJeb = vessel.GetMasterMechJeb();

            if (activeJeb == null)
            {
                return(false);
            }

            // Most of these conditions are directly from MJ, or derived from
            // it.
            if (!activeJeb.target.NormalTargetExists)
            {
                return(false);
            }

            Orbit o = vessel.orbit;

            if (o.eccentricity > 0.2)
            {
                // Need fairly circular orbit to plot.
                return(false);
            }

            if (o.referenceBody == activeJeb.target.TargetOrbit.referenceBody)
            {
                // Target is in our SoI

                if (activeJeb.target.TargetOrbit.eccentricity >= 1.0)
                {
                    // can't intercept hyperbolic targets
                    return(false);
                }

                if (o.RelativeInclination(activeJeb.target.TargetOrbit) > 30.0 && o.RelativeInclination(activeJeb.target.TargetOrbit) < 150.0)
                {
                    // Target is in a drastically different orbital plane.
                    return(false);
                }
            }
            else
            {
                // Target is not in our SoI
                if (o.referenceBody.referenceBody == null)
                {
                    // Can't plot a transfer from an orbit around the sun (really?)
                    return(false);
                }
                if (o.referenceBody.referenceBody != activeJeb.target.TargetOrbit.referenceBody)
                {
                    return(false);
                }
                if (o.referenceBody.orbit.RelativeInclination(activeJeb.target.TargetOrbit) > 30.0)
                {
                    // Can't handle highly inclined targets
                    return(false);
                }
            }

            // Did we get through all the tests?  Then we can plot an orbit!
            return(true);
        }
Beispiel #3
0
 /* 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;
 }
 public KillHorizontalVelocity(MechJebCore core) : base(core)
 {
 }
 public ModExtensionDemo(MechJebCore core) : base(core)
 {
 }
Beispiel #6
0
 public DecelerationBurn(MechJebCore core) : base(core)
 {
 }
 public CoastToDeceleration(MechJebCore core) : base(core)
 {
 }
Beispiel #8
0
            double gee; //convience for mainbody gee ASL in m/s²

            public FinalDescent(MechJebCore core) : base(core)
            {
                useChute = mainBody.atmosphere && core.landing.deployChutes && vesselState.parachutes.Count > 0;
                gee      = mainBody.GeeASL * PhysicsGlobals.GravitationalAcceleration;
            }
Beispiel #9
0
 public FinalDescent(MechJebCore core) : base(core)
 {
 }
Beispiel #10
0
            public AtmosphericDeorbit(MechJebCore core) : base(core)
            {
                doAfterExecution = new AtmosphericCorrection(core);

                targetInfo = new TrajectoriesConnector.TargetInfo(core.target);
            }
 public UntargetedDeorbit(MechJebCore core) : base(core)
 {
 }
 public ModExtensionDemo(MechJebCore core) : base(core) { }
 public UntargetedDeorbit(MechJebCore core) : base(core)
 {
 }
Beispiel #14
0
        protected override void LateUpdate()
        {
            if (shutdown)
            {
                return;
            }

            if (!HighLogic.LoadedSceneIsFlight || !FlightGlobals.ready)
            {
                return;
            }

            if (SCANcontroller.controller == null)
            {
                way = null;
                return;
            }

            if (!SCANcontroller.controller.mechJebTargetSelection)
            {
                way = null;
                return;
            }

            v = FlightGlobals.ActiveVessel;

            if (v == null)
            {
                SCANcontroller.controller.MechJebLoaded = false;
                way = null;
                return;
            }

            if (v.mainBody != SCANcontroller.controller.LandingTargetBody)
            {
                SCANcontroller.controller.LandingTargetBody = v.mainBody;
            }

            data = SCANUtil.getData(v.mainBody);

            if (data == null)
            {
                SCANcontroller.controller.MechJebLoaded = false;
                way = null;
                return;
            }

            if (v.FindPartModulesImplementing <MechJebCore>().Count <= 0)
            {
                SCANcontroller.controller.MechJebLoaded = false;
                way = null;
                return;
            }

            core = v.GetMasterMechJeb();

            if (core == null)
            {
                SCANcontroller.controller.MechJebLoaded = false;
                way = null;
                return;
            }

            if (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX)
            {
                if (guidanceModule == null)
                {
                    guidanceModule = (DisplayModule)core.GetComputerModule("MechJebModuleLandingGuidance");
                }

                if (guidanceModule == null)
                {
                    SCANcontroller.controller.MechJebLoaded = false;
                    way = null;
                    return;
                }

                if (!guidanceModule.unlockChecked)
                {
                    return;
                }

                if (guidanceModule.hidden)
                {
                    SCANcontroller.controller.MechJebLoaded = false;
                    shutdown = true;
                    way      = null;
                    return;
                }
            }

            target = core.target;

            if (target == null)
            {
                SCANcontroller.controller.MechJebLoaded = false;
                way = null;
                return;
            }

            if (!SCANcontroller.controller.MechJebLoaded)
            {
                SCANcontroller.controller.MechJebLoaded = true;
                RenderingManager.AddToPostDrawQueue(1, drawTarget);
            }

            if (SCANcontroller.controller.LandingTarget != null)
            {
                way = SCANcontroller.controller.LandingTarget;
            }

            if (SCANcontroller.controller.TargetSelecting)
            {
                way             = null;
                selectingTarget = true;
                if (SCANcontroller.controller.TargetSelectingActive)
                {
                    selectingInMap = true;
                }
                else
                {
                    selectingInMap = false;
                }
                coords = SCANcontroller.controller.LandingTargetCoords;
                return;
            }
            else if (selectingTarget)
            {
                selectingTarget = false;
                if (selectingInMap)
                {
                    selectingInMap = false;
                    coords         = SCANcontroller.controller.LandingTargetCoords;
                    way            = new SCANwaypoint(coords.y, coords.x, siteName);
                    target.SetPositionTarget(SCANcontroller.controller.LandingTargetBody, way.Latitude, way.Longitude);
                }
            }

            selectingInMap  = false;
            selectingTarget = false;

            if (target.Target == null)
            {
                way = null;
                return;
            }

            if (target.targetBody != v.mainBody)
            {
                way = null;
                return;
            }

            if (!(target.Target is PositionTarget))
            {
                way = null;
                return;
            }

            coords.x = target.targetLongitude;
            coords.y = target.targetLatitude;

            if (way != null)
            {
                if (!SCANUtil.ApproxEq(coords.x, way.Longitude) || !SCANUtil.ApproxEq(coords.y, way.Latitude))
                {
                    way = new SCANwaypoint(coords.y, coords.x, siteName);
                    SCANcontroller.controller.LandingTarget = way;
                    data.addToWaypoints();
                }
            }
            else
            {
                way = new SCANwaypoint(coords.y, coords.x, siteName);
                SCANcontroller.controller.LandingTarget = way;
                data.addToWaypoints();
            }
        }
Beispiel #15
0
 public DeorbitBurn(MechJebCore core) : base(core)
 {
 }
 public DeorbitBurn(MechJebCore core) : base(core)
 {
 }
Beispiel #17
0
 public FinalDescent(MechJebCore core) : base(core)
 {
 }
Beispiel #18
0
 protected override void onPartAwake()
 {
     core      = new MechJebCore();
     core.part = this;
     base.onPartAwake();
 }
Beispiel #19
0
 public CourseCorrection(MechJebCore core) : base(core)
 {
 }
Beispiel #20
0
 public CoastToDeceleration(MechJebCore core) : base(core)
 {
 }
 public DecelerationBurn(MechJebCore core) : base(core)
 {
 }
Beispiel #22
0
 public PlaneChange(MechJebCore core) : base(core)
 {
 }
 public CourseCorrection(MechJebCore core) : base(core)
 {
 }
 public KillHorizontalVelocity(MechJebCore core) : base(core)
 {
 }