Exemple #1
0
        public override bool Execute(FlightComputer f, FlightCtrlState fcs)
        {
            if (RemainingDelta > 0)
            {
                var forward     = Node.GetBurnVector(f.Vessel.orbit).normalized;
                var up          = (f.SignalProcessor.Body.position - f.SignalProcessor.Position).normalized;
                var orientation = Quaternion.LookRotation(forward, up);
                FlightCore.HoldOrientation(fcs, f, orientation);

                double thrustToMass = (FlightCore.GetTotalThrust(f.Vessel) / f.Vessel.GetTotalMass());
                if (thrustToMass == 0.0)
                {
                    EngineActivated = false;
                    return(false);
                }

                EngineActivated  = true;
                fcs.mainThrottle = 1.0f;
                RemainingTime    = RemainingDelta / thrustToMass;
                RemainingDelta  -= thrustToMass * TimeWarp.deltaTime;
                return(false);
            }
            f.Enqueue(AttitudeCommand.Off(), true, true, true);
            return(true);
        }
Exemple #2
0
        public override bool Pop(FlightComputer f)
        {
            var burn = f.ActiveCommands.FirstOrDefault(c => c is BurnCommand);

            if (burn != null)
            {
                f.Remove(burn);
            }

            OriginalDelta   = Node.DeltaV.magnitude;
            RemainingDelta  = Node.GetBurnVector(f.Vessel.orbit).magnitude;
            EngineActivated = true;

            double thrustToMass = FlightCore.GetTotalThrust(f.Vessel) / f.Vessel.GetTotalMass();

            if (thrustToMass == 0.0)
            {
                EngineActivated = false;
                RTUtil.ScreenMessage("[Flight Computer]: No engine to carry out the maneuver.");
            }
            else
            {
                RemainingTime = RemainingDelta / thrustToMass;
            }

            return(true);
        }
Exemple #3
0
        public override bool Execute(FlightComputer f, FlightCtrlState fcs)
        {
            if (mAbort)
            {
                fcs.mainThrottle = 0.0f;
                return(true);
            }

            if (Duration > 0)
            {
                fcs.mainThrottle = Throttle;
                Duration        -= TimeWarp.deltaTime;
            }
            else if (DeltaV > 0)
            {
                fcs.mainThrottle = Throttle;
                DeltaV          -= (Throttle * FlightCore.GetTotalThrust(f.Vessel) / f.Vessel.GetTotalMass()) * TimeWarp.deltaTime;
            }
            else
            {
                fcs.mainThrottle = 0.0f;
                return(true);
            }
            return(false);
        }
Exemple #4
0
        public static ManeuverCommand WithNode(ManeuverNode node, FlightComputer f)
        {
            double thrust  = FlightCore.GetTotalThrust(f.Vessel);
            double advance = f.Delay;

            if (thrust > 0)
            {
                advance += (node.DeltaV.magnitude / (thrust / f.Vessel.GetTotalMass())) / 2;
            }

            var newNode = new ManeuverCommand()
            {
                Node = new ManeuverNode()
                {
                    DeltaV            = node.DeltaV,
                    patch             = node.patch,
                    solver            = node.solver,
                    scaledSpaceTarget = node.scaledSpaceTarget,
                    nextPatch         = node.nextPatch,
                    UT           = node.UT,
                    nodeRotation = node.nodeRotation,
                },
                TimeStamp = node.UT - advance,
            };

            return(newNode);
        }
        public override bool Pop(FlightComputer f)
        {
            var burn = f.ActiveCommands.FirstOrDefault(c => c is BurnCommand);

            if (burn != null)
            {
                f.Remove(burn);
            }
            OriginalDelta  = Node.DeltaV.magnitude;
            RemainingDelta = Node.GetBurnVector(f.Vessel.orbit).magnitude;
            RemainingTime  = RemainingDelta / (FlightCore.GetTotalThrust(f.Vessel) / f.Vessel.GetTotalMass());
            return(true);
        }