Inheritance: IDisposable
示例#1
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;
        }
示例#2
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;
        }
        public FlightComputerWindow(FlightComputer fc)
            : base(Guid.NewGuid(), "Flight Computer", new Rect(100, 100, 0, 0), WindowAlign.Floating)
        {
            mFlightComputer = fc;

            mAttitude = new AttitudeFragment(fc, () => mQueueEnabled = !mQueueEnabled);
            mQueue = new QueueFragment(fc);
            mQueueEnabled = false;
        }
        public FlightComputerWindow(FlightComputer fc)
            : base("", new Rect(100, 100, 0, 0), WindowAlign.Floating)
        {
            mFlightComputer = fc;

            mAttitude = new AttitudeFragment(fc, () => mQueueEnabled = !mQueueEnabled);
            mRover = new RoverFragment(fc, () => mQueueEnabled = !mQueueEnabled);
            mAerial = new AerialFragment(fc);
            mBifrost = new BifrostFragment(fc);
            mQueue = new QueueFragment(fc);
            mQueueEnabled = false;
        }
示例#5
0
 public override bool Pop(FlightComputer f)
 {
     if (Command == null)
     {
         f.Reset();
     }
     else
     {
         f.Remove(Command);
     }
     return false;
 }
示例#6
0
 public override void OnStart(StartState state)
 {
     if (state != StartState.Editor)
     {
         GameEvents.onVesselWasModified.Add(OnVesselModified);
         GameEvents.onPartUndock.Add(OnPartUndock);
         mRegisteredId = vessel.id; 
         RTCore.Instance.Satellites.Register(vessel, this);
         FlightComputer = new FlightComputer(this);
     }
     Fields["GUI_Status"].guiActive = ShowGUI_Status;
 }
        public override bool Pop(FlightComputer f)
        {
            f.Vessel.ActionGroups.ToggleGroup(ActionGroup);
            if (ActionGroup == KSPActionGroup.Stage && !(f.Vessel == FlightGlobals.ActiveVessel && FlightInputHandler.fetch.stageLock))
            {
                Staging.ActivateNextStage();
                ResourceDisplay.Instance.Refresh();
            }
            if (ActionGroup == KSPActionGroup.RCS && f.Vessel == FlightGlobals.ActiveVessel)
            {
                FlightInputHandler.fetch.rcslock = !FlightInputHandler.RCSLock;
            }

            return false;
        }
示例#8
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);
         fcs.mainThrottle = 1.0f;
         RemainingTime -= TimeWarp.deltaTime;
         RemainingDelta -= (FlightCore.GetTotalThrust(f.Vessel) / f.Vessel.GetTotalMass()) * TimeWarp.deltaTime;
         return false;
     }
     f.Enqueue(AttitudeCommand.Off(), true, true, true);
     return true;
 }
示例#9
0
        public RemoteCore(Vessel v, float energyDrain)
        {
            if (v == null) return;
            vessel = v;
            this.EnergyDrain = energyDrain;

            settings = new SatSettings(this);
            computer = new FlightComputer(this);
            flightComputerGUI = new FlightComputerGUI(this);

            Rnode = new RelayNode(vessel);

            try
            {
                vessel.OnFlyByWire -= new FlightInputCallback(this.drive);
            }
            catch { }
            try
            {
                vessel.OnFlyByWire += new FlightInputCallback(this.drive);
            }
            catch { }

            GetCommandPath();

            UpdateOtherModules();

            planetariumCamera = (PlanetariumCamera)GameObject.FindObjectOfType(typeof(PlanetariumCamera));

            obj = new GameObject("Line");

            line = null;

            obj.layer = 9;
            line = obj.AddComponent<LineRenderer>();
            line.useWorldSpace = true;
            line.material = new Material(Shader.Find("Particles/Additive"));
            line.SetColors(Color.blue, Color.blue);
            line.SetWidth(0, 0);

            localControl = vessel.GetCrewCount() > 0 || MechJeb;
        }
示例#10
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;
        }
 public BifrostFragment(FlightComputer fc)
 {
     mFlightComputer = fc;
 }
示例#12
0
 public override bool Execute(FlightComputer f, FlightCtrlState fcs) { return false; }
示例#13
0
 // true: move to active.
 public virtual bool Pop(FlightComputer f)
 {
     return(false);
 }
示例#14
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;
 }
 public RoverFragment(FlightComputer fc, OnClick queue)
 {
     mFlightComputer = fc;
     mOnClickQueue = queue;
 }
示例#16
0
 public override void OnStart(StartState state)
 {
     if (RTCore.Instance != null) {
         GameEvents.onVesselWasModified.Add(OnVesselModified);
         GameEvents.onPartUndock.Add(OnPartUndock);
         mRegisteredId = RTCore.Instance.Satellites.Register(Vessel, this);
         if (FlightComputer == null) {
             FlightComputer = new FlightComputer(this);
         }
     }
     Fields["Status"].guiActive = ShowGUI_Status;
 }
示例#17
0
 // true: move to active.
 public virtual bool Pop(FlightComputer f)
 {
     return false;
 }
示例#18
0
 public override bool Pop(FlightComputer f)
 {
     f.Remove(Command);
     return false;
 }
示例#19
0
 // true: delete afterwards.
 public virtual bool Execute(FlightComputer f, FlightCtrlState fcs)
 {
     return true;
 }
示例#20
0
 public static void HoldOrientation(FlightCtrlState fs, FlightComputer f, Quaternion target)
 {
     f.Vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, false);
     kOS.SteeringHelper.SteerShipToward(target, fs, f.Vessel);
 }
示例#21
0
 public static void HoldAttitude(FlightCtrlState fs, FlightComputer f, ReferenceFrame frame, FlightAttitude attitude, Quaternion extra)
 {
     var v = f.Vessel;
     var forward = Vector3.zero;
     var up = Vector3.zero;
     var rotationReference = Quaternion.identity;
     switch (frame)
     {
         case ReferenceFrame.Orbit:
             forward = v.GetObtVelocity();
             up = (v.mainBody.position - v.CoM);
             break;
         case ReferenceFrame.Surface:
             forward = v.GetSrfVelocity();
             up = (v.mainBody.position - v.CoM);
             break;
         case ReferenceFrame.North:
             up = (v.mainBody.position - v.CoM);
             forward = Vector3.Exclude(up,
                 v.mainBody.position + v.mainBody.transform.up * (float)v.mainBody.Radius - v.CoM
              );
             break;
         case ReferenceFrame.Maneuver:
             up = v.transform.up;
             if (f.DelayedManeuver != null)
             {
                 forward = f.DelayedManeuver.GetBurnVector(v.orbit);
                 up = (v.mainBody.position - v.CoM);
             }
             else
             {
                 forward = v.GetObtVelocity();
                 up = (v.mainBody.position - v.CoM);
             }
             break;
         case ReferenceFrame.TargetVelocity:
             if (f.DelayedTarget != null && f.DelayedTarget is Vessel)
             {
                 forward = v.GetObtVelocity() - f.DelayedTarget.GetObtVelocity();
                 up = (v.mainBody.position - v.CoM);
             }
             else
             {
                 up = (v.mainBody.position - v.CoM);
                 forward = v.GetObtVelocity();
             }
             break;
         case ReferenceFrame.TargetParallel:
             if (f.DelayedTarget != null && f.DelayedTarget is Vessel)
             {
                 forward = f.DelayedTarget.GetTransform().position - v.CoM;
                 up = (v.mainBody.position - v.CoM);
             }
             else
             {
                 up = (v.mainBody.position - v.CoM);
                 forward = v.GetObtVelocity();
             }
             break;
     }
     Vector3.OrthoNormalize(ref forward, ref up);
     rotationReference = Quaternion.LookRotation(forward, up);
     switch (attitude)
     {
         case FlightAttitude.Prograde:
             break;
         case FlightAttitude.Retrograde:
             rotationReference = rotationReference * Quaternion.AngleAxis(180, Vector3.up);
             break;
         case FlightAttitude.NormalPlus:
             rotationReference = rotationReference * Quaternion.AngleAxis(90, Vector3.up);
             break;
         case FlightAttitude.NormalMinus:
             rotationReference = rotationReference * Quaternion.AngleAxis(90, Vector3.down);
             break;
         case FlightAttitude.RadialPlus:
             rotationReference = rotationReference * Quaternion.AngleAxis(90, Vector3.right);
             break;
         case FlightAttitude.RadialMinus:
             rotationReference = rotationReference * Quaternion.AngleAxis(90, Vector3.left);
             break;
         case FlightAttitude.Surface:
             rotationReference = rotationReference * extra;
             break;
     }
     HoldOrientation(fs, f, rotationReference);
 }
示例#22
0
 // true: delete afterwards.
 public virtual bool Execute(FlightComputer f, FlightCtrlState fcs)
 {
     return(true);
 }
示例#23
0
 public override bool Pop(FlightComputer f)
 {
     BaseEvent.Invoke();
     return false;
 }
示例#24
0
 public AttitudeFragment(FlightComputer fc, Action queue)
 {
     mFlightComputer = fc;
     mOnClickQueue = queue;
 }
 public QueueFragment(FlightComputer fc)
 {
     mFlightComputer = fc;
     Delay = 0;
 }
 public ProgcomFragment(FlightComputer fc)
 {
     mFlightComputer = fc;
 }
示例#27
0
 public override bool Pop(FlightComputer f)
 {
     f.DelayedTarget = Target;
     return true;
 }
 public QueueFragment(FlightComputer fc)
 {
     mFlightComputer = fc;
     Delay           = 0;
 }
示例#29
0
 public override bool Pop(FlightComputer f)
 {
     BaseEvent.Invoke();
     return(false);
 }
示例#30
0
 public AerialFragment(FlightComputer fc)
 {
     mFlightComputer = fc;
 }
示例#31
0
 public override bool Pop(FlightComputer f)
 {
     return true;
 }
 public BifrostFragment(FlightComputer fc)
 {
     mFlightComputer = fc;
 }
示例#33
0
 public override bool Pop(FlightComputer f)
 {
     if (Mode == FlightMode.KillRot)
     {
         Orientation = f.Vessel.transform.rotation;
     }
     return true;
 }
示例#34
0
 public override bool Pop(FlightComputer f)
 {
     return(true);
 }
示例#35
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;
        }
示例#36
0
 public QueueFragment(FlightComputer fc)
 {
     mFlightComputer = fc;
     mExtraDelay = "0";
 }