public static DelayedCommand Cancel(DelayedCommand dc) { return(new DelayedCommand() { CancelCommand = dc, TimeStamp = RTUtil.GetGameTime() }); }
private void PopCommand() { if (mCommandBuffer.Count > 0) { for (int i = 0; i < mCommandBuffer.Count && mCommandBuffer[i].TimeStamp < RTUtil.GetGameTime(); i++) { DelayedCommand dc = mCommandBuffer[i]; if (dc.ExtraDelay > 0) { dc.ExtraDelay -= TimeWarp.deltaTime; } else { if (dc.ActionGroupCommand != null) { KSPActionGroup ag = dc.ActionGroupCommand.ActionGroup; mAttachedVessel.ActionGroups.ToggleGroup(ag); if (ag == KSPActionGroup.Stage && !FlightInputHandler.fetch.stageLock) { Staging.ActivateNextStage(); ResourceDisplay.Instance.Refresh(); } if (ag == KSPActionGroup.RCS) { FlightInputHandler.fetch.rcslock = !FlightInputHandler.RCSLock; } } if (dc.AttitudeCommand != null) { mKillrot = mAttachedVessel.transform.rotation * Quaternion.AngleAxis(90, Vector3.left); mCommand = dc; } if (dc.BurnCommand != null) { mLastSpeed = mAttachedVessel.obt_velocity.magnitude; mCommand.BurnCommand = dc.BurnCommand; } if (dc.DriveCommand != null) { mRoverComputer.InitMode(dc.DriveCommand); mCommand.DriveCommand = dc.DriveCommand; } if (dc.Event != null) { dc.Event.BaseEvent.Invoke(); } mCommandBuffer.RemoveAt(i); } } } }
public static DelayedCommand Group(KSPActionGroup group) { return(new DelayedCommand() { ActionGroupCommand = new ActionGroupCommand() { ActionGroup = group, }, TimeStamp = RTUtil.GetGameTime(), }); }
public static DelayedCommand Off() { return(new DelayedCommand() { DriveCommand = new DriveCommand() { mode = DriveMode.Off, }, TimeStamp = RTUtil.GetGameTime() }); }
public static DelayedCommand Event(BaseEvent ev) { return(new DelayedCommand() { EventCommand = new EventCommand() { BaseEvent = ev, }, TimeStamp = RTUtil.GetGameTime(), }); }
public static DelayedCommand Off() { return(new DelayedCommand() { BurnCommand = new BurnCommand() { Throttle = Single.NaN, Duration = 0, DeltaV = 0, }, TimeStamp = RTUtil.GetGameTime() }); }
public static DelayedCommand WithDeltaV(float throttle, double delta) { return(new DelayedCommand() { BurnCommand = new BurnCommand() { Throttle = throttle, Duration = 0, DeltaV = delta, }, TimeStamp = RTUtil.GetGameTime() }); }
public static DelayedCommand Turn(float steering, float degrees, float speed) { return(new DelayedCommand() { DriveCommand = new DriveCommand() { mode = DriveMode.Turn, steering = steering, target = degrees, speed = speed, }, TimeStamp = RTUtil.GetGameTime() }); }
public static DelayedCommand Distance(float distance, float steerClamp, float speed) { return(new DelayedCommand() { DriveCommand = new DriveCommand() { mode = DriveMode.Distance, steering = steerClamp, target = distance, speed = speed, }, TimeStamp = RTUtil.GetGameTime() }); }
public static DelayedCommand WithAltitude(float height) { return(new DelayedCommand() { AttitudeCommand = new AttitudeCommand() { Mode = FlightMode.AltitudeHold, Attitude = FlightAttitude.Prograde, Frame = ReferenceFrame.North, Orientation = Quaternion.identity, Altitude = height, }, TimeStamp = RTUtil.GetGameTime() }); }
public static DelayedCommand WithAttitude(FlightAttitude att, ReferenceFrame frame) { return(new DelayedCommand() { AttitudeCommand = new AttitudeCommand() { Mode = FlightMode.AttitudeHold, Attitude = att, Frame = frame, Orientation = Quaternion.identity, Altitude = Single.NaN, }, TimeStamp = RTUtil.GetGameTime() }); }
public static DelayedCommand ManeuverNode() { return(new DelayedCommand() { AttitudeCommand = new AttitudeCommand() { Mode = FlightMode.AttitudeHold, Attitude = FlightAttitude.Prograde, Frame = ReferenceFrame.Maneuver, Orientation = Quaternion.identity, Altitude = Single.NaN, }, TimeStamp = RTUtil.GetGameTime() }); }
public static DelayedCommand Coord(float steerClamp, float latitude, float longitude, float speed) { return(new DelayedCommand() { DriveCommand = new DriveCommand() { mode = DriveMode.Coord, steering = steerClamp, target = latitude, target2 = longitude, speed = speed, }, TimeStamp = RTUtil.GetGameTime() }); }
private void PopQueue() { while (mQueue.Count > 0 && mQueue.Peek().TimeStamp < RTUtil.GetGameTime()) { DelayedCommand dc = mQueue.Dequeue(); if (dc.Program != null) { LoadProgram(dc.Program); } if (dc.Numpad != null) { mProgcom.Memory[mOffset + INPUT_NUM] = dc.Numpad ?? 0; mProgcom.Memory[mOffset + INPUT_NUM + 1] = 1; } } }
private void PopFlightCtrlState(FlightCtrlState fcs) { FlightCtrlState delayed = mPreviousCtrl; // Pop any due flightctrlstates off the queue while (mFlightCtrlBuffer.Count > 0 && mFlightCtrlBuffer.Peek().TimeStamp < RTUtil.GetGameTime()) { delayed = mFlightCtrlBuffer.Dequeue().State; } if (!InputAllowed) { float keepThrottle = mPreviousCtrl.mainThrottle; delayed.Neutralize(); delayed.mainThrottle = keepThrottle; } fcs.CopyFrom(delayed); }
public static DelayedCommand WithSurface(double pitch, double yaw, double roll) { Quaternion rotation = Quaternion.Euler(new Vector3d(Double.IsNaN(pitch) ? 0 : pitch, Double.IsNaN(yaw) ? 0 : -yaw, Double.IsNaN(roll) ? 0 : 180 - roll)); return(new DelayedCommand() { AttitudeCommand = new AttitudeCommand() { Mode = FlightMode.AttitudeHold, Attitude = FlightAttitude.Surface, Frame = ReferenceFrame.North, Orientation = rotation, Altitude = Single.NaN, }, TimeStamp = RTUtil.GetGameTime() }); }
public DelayedFlightCtrlState(FlightCtrlState fcs) { State = new FlightCtrlState(); State.CopyFrom(fcs); TimeStamp = RTUtil.GetGameTime(); }
private String Format(DelayedCommand dc) { StringBuilder s = new StringBuilder(); if (dc.AttitudeCommand != null) { switch (dc.AttitudeCommand.Mode) { case FlightMode.Off: s.Append("Mode: Off"); break; case FlightMode.KillRot: s.Append("Mode: Kill rotation"); break; case FlightMode.AttitudeHold: s.Append("Mode: Hold, "); switch (dc.AttitudeCommand.Attitude) { case FlightAttitude.Prograde: s.Append("Prograde"); break; case FlightAttitude.Retrograde: s.Append("Retrograde"); break; case FlightAttitude.NormalPlus: s.Append("Normal +"); break; case FlightAttitude.NormalMinus: s.Append("Normal -"); break; case FlightAttitude.RadialPlus: s.Append("Radial +"); break; case FlightAttitude.RadialMinus: s.Append("Radial -"); break; case FlightAttitude.Surface: s.Append(dc.AttitudeCommand.Orientation.eulerAngles.x.ToString("F1")); s.Append(", "); s.Append(dc.AttitudeCommand.Orientation.eulerAngles.y.ToString("F1")); s.Append(", "); s.Append(dc.AttitudeCommand.Orientation.eulerAngles.z.ToString("F1")); break; } break; case FlightMode.AltitudeHold: s.Append("Mode: Hold, "); s.Append(RTUtil.FormatSI(dc.AttitudeCommand.Altitude, "m")); break; } } else if (dc.ActionGroupCommand != null) { s.Append("Toggle "); s.Append(dc.ActionGroupCommand.ActionGroup.ToString()); } else if (dc.BurnCommand != null) { s.Append("Burn "); s.Append(dc.BurnCommand.Throttle.ToString("P2")); if (dc.BurnCommand.Duration != Single.NaN) { s.Append(", "); s.Append(dc.BurnCommand.Duration.ToString("F2")); s.Append("s"); } if (dc.BurnCommand.DeltaV != Single.NaN) { s.Append(", "); s.Append(dc.BurnCommand.DeltaV.ToString("F2")); s.Append("m/s"); } } else if (dc.DriveCommand != null) { dc.DriveCommand.GetDescription(s); } else if (dc.Event != null) { s.Append(dc.Event.BaseEvent.listParent.part.partInfo.title); s.Append(": "); s.Append(dc.Event.BaseEvent.GUIName); } double delay = Math.Max(dc.TimeStamp - RTUtil.GetGameTime(), 0); if (delay > 0 || dc.ExtraDelay > 0) { s.AppendLine(); s.Append("Signal delay: "); s.Append(delay.ToString("F2")); s.Append("s"); if (dc.ExtraDelay > 0) { s.Append(" (+"); s.Append(dc.ExtraDelay.ToString("F2")); s.Append("s)"); } } return(s.ToString()); }
public DelayedCommand() { TimeStamp = RTUtil.GetGameTime(); }