protected override void Update()
        {
            if (!IsActive)
            {
                return;
            }
            Vector3 dV;

            if (CFG.AP1[Autopilot1.MatchVel])
            {
                dV = CFG.Target.GetObtVelocity() - VSL.vessel.obt_velocity;
                VSL.Engines.RequestClusterActivationForManeuver(dV);
                Executor.Execute(dV, GLB.THR.MinDeltaV);
            }
            else
            {
                double ApprUT;
                var    tOrb = CFG.Target.GetOrbit();
                var    dist = TrajectoryCalculator.NearestApproach(VSL.orbit, tOrb, VSL.Physics.UT, VSL.Geometry.MinDistance + 10, out ApprUT);
                TTA = (float)(ApprUT - VSL.Physics.UT);
                switch (stage)
                {
                case Stage.Start:
                    if (dist > MVA.MaxApproachDistance)
                    {
                        Status(string.Format("<color=yellow>WARNING:</color> Nearest approach distance is <color=magenta><b>{0}</b></color>\n" +
                                             "<color=red><b>Push to proceed. At your own risk.</b></color>",
                                             Utils.formatBigValue((float)dist, "m")));
                        stage = Stage.Wait;
                        goto case Stage.Wait;
                    }
                    stage = Stage.Brake;
                    goto case Stage.Brake;

                case Stage.Wait:
                    if (!string.IsNullOrEmpty(TCAGui.StatusMessage))
                    {
                        break;
                    }
                    stage = Stage.Brake;
                    goto case Stage.Brake;

                case Stage.Brake:
                    dV = (tOrb.getOrbitalVelocityAtUT(ApprUT) - VSL.orbit.getOrbitalVelocityAtUT(ApprUT)).xzy;
                    VSL.Engines.RequestClusterActivationForManeuver(dV);
                    if (Executor.Execute(dV, GLB.THR.MinDeltaV, StartCondition))
                    {
                        break;
                    }
                    reset();
                    break;
                }
            }
        }
Exemplo n.º 2
0
        protected override void Update()
        {
            Vector3 dV;

            if (CFG.AP1[Autopilot1.MatchVel])
            {
                Working = true;
                dV      = CFG.Target.GetObtVelocity() - VSL.vessel.obt_velocity;
                if (!Executor.Execute(dV, MinDeltaV))
                {
                    Executor.Reset();
                }
            }
            else
            {
                var tOrb = CFG.Target.GetOrbit();
                var dist = Working? 0 :
                           TrajectoryCalculator.NearestApproach(VSL.orbit, tOrb, VSL.Physics.UT, VSL.Geometry.MinDistance + 10, out ApprUT);
                TTA = (float)(ApprUT - VSL.Physics.UT);
                switch (stage)
                {
                case Stage.Start:
                    if (dist > C.MaxApproachDistance)
                    {
                        Status(Colors.Warning.Tag("WARNING: ") +
                               "Nearest approach distance is " +
                               Colors.Selected2.Tag("<b>{0}</b>\n") +
                               Colors.Danger.Tag("<b>Push to proceed. At your own risk.</b>"),
                               Utils.formatBigValue((float)dist, "m"));
                        stage = Stage.Wait;
                        goto case Stage.Wait;
                    }
                    stage = Stage.Brake;
                    goto case Stage.Brake;

                case Stage.Wait:
                    if (!string.IsNullOrEmpty(TCAGui.StatusMessage))
                    {
                        break;
                    }
                    stage = Stage.Brake;
                    goto case Stage.Brake;

                case Stage.Brake:
                    dV = (TrajectoryCalculator.NextOrbit(tOrb, ApprUT).GetFrameVelAtUT(ApprUT) - VSL.orbit.GetFrameVelAtUT(ApprUT)).xzy;
                    if (!Executor.Execute(dV, MinDeltaV, StartCondition))
                    {
                        Reset();
                    }
                    break;
                }
            }
        }