示例#1
0
        public override bool Execute(FlightComputer f, FlightCtrlState fcs)
        {
            if (mAbort)
            {
                Mode   = FlightMode.Off;
                mAbort = false;
            }

            switch (Mode)
            {
            case FlightMode.Off:
                break;

            case FlightMode.KillRot:
                FlightCore.HoldOrientation(fcs, f, Orientation * Quaternion.AngleAxis(90, Vector3.left));
                break;

            case FlightMode.AttitudeHold:
                FlightCore.HoldAttitude(fcs, f, Frame, Attitude, Orientation);
                break;

            case FlightMode.AltitudeHold:
                break;
            }

            return(false);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#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);
        }
示例#5
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);
        }
示例#6
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;
            RemainingTime  = RemainingDelta / (FlightCore.GetTotalThrust(f.Vessel) / f.Vessel.GetTotalMass());
            return(true);
        }