diff options
Diffstat (limited to 'crates/fparkan-runtime/src/cockpit_speedometer.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/cockpit_speedometer.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/crates/fparkan-runtime/src/cockpit_speedometer.rs b/crates/fparkan-runtime/src/cockpit_speedometer.rs index 021fc3ec..5069013b 100644 --- a/crates/fparkan-runtime/src/cockpit_speedometer.rs +++ b/crates/fparkan-runtime/src/cockpit_speedometer.rs @@ -55,13 +55,19 @@ pub(super) fn record_route_speed( mission: &mut LoadedMissionState, patrol: Option<&PreparedPatrol>, ) { - mission.cockpit_speed = mission + let driving = mission .boarding - .filter(|board| board.remote == Some(RemoteWarbotControl::Autopilot)) - .zip(patrol) - .map_or(0.0, |(board, patrol)| { - patrol.speed_of(board.cockpit.handle, board.can_fly) - }); + .as_mut() + .filter(|board| board.control_mode == RemoteWarbotControl::Autopilot) + .zip(patrol); + mission.cockpit_speed = driving.map_or(0.0, |(board, patrol)| { + if board.can_fly { + if let Some(velocity) = patrol.flight_velocity_of(board.cockpit.handle) { + board.flight_velocity = velocity; + } + } + patrol.speed_of(board.cockpit.handle, board.can_fly) + }); } pub(super) fn length(vector: [f32; 3]) -> f32 { |
