/// <summary> /// Here we copy the flight state we received and apply to the specific vessel. /// This method is called by ksp as it's a delegate. It's called on every FixedUpdate /// </summary> private void LunaOnVesselFlyByWire(Guid id, FlightCtrlState st) { if (FlightStatesDictionary.TryGetValue(id, out var value)) { if (value.CanInterpolate) { if (VesselCommon.IsSpectating) { st.CopyFrom(value.GetInterpolatedValue()); } else { //If we are close to a vessel and we both are in space don't copy the //input controls as then the vessel jitters, specially if the other player has SAS on if (FlightGlobals.ActiveVessel.situation > Vessel.Situations.FLYING) { var interpolatedState = value.GetInterpolatedValue(); st.mainThrottle = interpolatedState.mainThrottle; st.gearDown = interpolatedState.gearDown; st.gearUp = interpolatedState.gearUp; st.headlight = interpolatedState.headlight; st.killRot = interpolatedState.killRot; } } } } }
/// <summary> /// Here we copy the flight state we received and apply to the specific vessel. /// This method is called by ksp as it's a delegate. It's called on every FixedUpdate /// </summary> public void LunaOnVesselFlyByWire(Guid id, FlightCtrlState st) { if (!Enabled || !FlightStateSystemReady) { return; } if (FlightStatesDictionary.TryGetValue(id, out var value)) { if (VesselCommon.IsSpectating) { st.CopyFrom(value.GetInterpolatedValue(st)); } else { //If we are close to a vessel and we both are in space don't copy the //input controls as then the vessel jitters, specially if the other player has SAS on if (FlightGlobals.ActiveVessel?.situation > Vessel.Situations.FLYING) { var interpolatedState = value.GetInterpolatedValue(st); st.mainThrottle = interpolatedState.mainThrottle; st.gearDown = interpolatedState.gearDown; st.gearUp = interpolatedState.gearUp; st.headlight = interpolatedState.headlight; st.killRot = interpolatedState.killRot; } else { st.CopyFrom(value.GetInterpolatedValue(st)); } } } else { var vessel = FlightGlobals.FindVessel(id); if (vessel != null && !FlightGlobals.FindVessel(id).packed) { AddVesselToSystem(vessel); } } }