diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-03 18:00:18 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-03 18:00:18 +0300 |
| commit | 099e48fa775b849654d1102a6c1d9e84ded7e1f4 (patch) | |
| tree | 25864aa84bdb465d0ca52f5d28c5a1b20a23e041 /crates/fparkan-runtime/src/cockpit_speedometer.rs | |
| parent | 4b9277258224ab846b84cafe1d6a3b91e29a05c5 (diff) | |
| download | fparkan-099e48fa775b849654d1102a6c1d9e84ded7e1f4.tar.xz fparkan-099e48fa775b849654d1102a6c1d9e84ded7e1f4.zip | |
feat(game): cycle warbot cockpit control modes
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 { |
