public void OnFixedUpdate() { // Re-attach periodically Vessel.OnFlyByWire -= OnFlyByWirePre; Vessel.OnFlyByWire -= OnFlyByWirePost; if (Vessel != SignalProcessor.Vessel) { SanctionedPilots.Clear(); Vessel = SignalProcessor.Vessel; } Vessel.OnFlyByWire = OnFlyByWirePre + Vessel.OnFlyByWire + OnFlyByWirePost; // Send updates for Target / Maneuver TargetCommand last = null; if (FlightGlobals.fetch.VesselTarget != DelayedTarget && ((mCommandQueue.FindLastIndex(c => (last = c as TargetCommand) != null)) == -1 || last.Target != FlightGlobals.fetch.VesselTarget)) { Enqueue(TargetCommand.WithTarget(FlightGlobals.fetch.VesselTarget)); } if (Vessel.patchedConicSolver != null && Vessel.patchedConicSolver.maneuverNodes.Count > 0) { if ((DelayedManeuver == null || (Vessel.patchedConicSolver.maneuverNodes[0].DeltaV != DelayedManeuver.DeltaV)) && (mManeuverQueue.Count == 0 || mManeuverQueue.Last.Value.Node.DeltaV != Vessel.patchedConicSolver.maneuverNodes[0].DeltaV)) { mManeuverQueue.AddLast(new DelayedManeuver(Vessel.patchedConicSolver.maneuverNodes[0])); } } }
/// <summary>Called by the <see cref="ModuleSPU.OnFixedUpdate"/> method during the "Physics" engine phase.</summary> public void OnFixedUpdate() { if (RTCore.Instance == null) { return; } if (Vessel == null) { Vessel = SignalProcessor.Vessel; RoverComputer.SetVessel(Vessel); PIDController.SetVessel(Vessel); } // only handle onFixedUpdate if the ship is unpacked if (Vessel.packed) { return; } // Do we have a loaded configuration? if (_fcLoadedConfigs != null) { // than load Load(_fcLoadedConfigs); _fcLoadedConfigs = null; } // Re-attach periodically Vessel.OnFlyByWire -= OnFlyByWirePre; Vessel.OnFlyByWire -= OnFlyByWirePost; if (Vessel != SignalProcessor.Vessel) { SanctionedPilots.Clear(); Vessel = SignalProcessor.Vessel; RoverComputer.SetVessel(Vessel); PIDController.SetVessel(Vessel); } // set flight control. Vessel.OnFlyByWire = OnFlyByWirePre + Vessel.OnFlyByWire + OnFlyByWirePost; //Update PID loop PIDController.OnFixedUpdate(); // Send updates for Target if (Vessel == FlightGlobals.ActiveVessel && FlightGlobals.fetch.VesselTarget != LastTarget.Target) { Enqueue(TargetCommand.WithTarget(FlightGlobals.fetch.VesselTarget)); UpdateLastTarget(); } }
public void OnFixedUpdate() { if (RTCore.Instance == null) { return; } if (Vessel == null) { Vessel = SignalProcessor.Vessel; mRoverComputer.SetVessel(Vessel); } // only handle onFixedUpdate if the ship is unpacked if (Vessel.packed) { return; } // Do we have a config? if (fcLoadedConfigs != null) { // than load load(fcLoadedConfigs); fcLoadedConfigs = null; } // Re-attach periodically Vessel.OnFlyByWire -= OnFlyByWirePre; Vessel.OnFlyByWire -= OnFlyByWirePost; if (Vessel != SignalProcessor.Vessel) { SanctionedPilots.Clear(); Vessel = SignalProcessor.Vessel; mRoverComputer.SetVessel(Vessel); } Vessel.OnFlyByWire = OnFlyByWirePre + Vessel.OnFlyByWire + OnFlyByWirePost; // Update proportional controller for changes in ship state updatePIDParameters(); // Send updates for Target if (Vessel == FlightGlobals.ActiveVessel && FlightGlobals.fetch.VesselTarget != lastTarget.Target) { Enqueue(TargetCommand.WithTarget(FlightGlobals.fetch.VesselTarget)); UpdateLastTarget(); } }