diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 18:57:36 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 18:57:36 +0300 |
| commit | 1fd51e5bbcfb4d5590fbc1ded8308fc40f6158f4 (patch) | |
| tree | 9ef8276c399e238a2a692862de09f54bf5dcee65 /crates/fparkan-runtime/src/player_motion.rs | |
| parent | 077bead07a76908ac4e0e2b84de3940256cf6fd1 (diff) | |
| download | fparkan-1fd51e5bbcfb4d5590fbc1ded8308fc40f6158f4.tar.xz fparkan-1fd51e5bbcfb4d5590fbc1ded8308fc40f6158f4.zip | |
feat(ui): enable manual control from the bunker list
Use the active Control camera record and its separate CPT origin and direction for the fixed turret. The original hand control opens the cockpit, its two weapon slots and aim tracks while leaving the operator at the command post.
Verified from the stock Two Fortresses start against the GOG cockpit with Vulkan validation. The licensed tests cover the native camera pose, mounted weapon selection and stationary bunker and operator.
Diffstat (limited to 'crates/fparkan-runtime/src/player_motion.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/player_motion.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/crates/fparkan-runtime/src/player_motion.rs b/crates/fparkan-runtime/src/player_motion.rs index be910936..6733f921 100644 --- a/crates/fparkan-runtime/src/player_motion.rs +++ b/crates/fparkan-runtime/src/player_motion.rs @@ -72,6 +72,7 @@ pub struct PlayerMotionStep { flight_velocity: Option<[f32; 3]>, hero_walk_velocity: Option<[f32; 2]>, hero_look: Option<HeroLook>, + turret: Option<crate::TurretAim>, max_floor_clearance: f32, previous_terrain_height: Option<f32>, terrain_height: Option<f32>, @@ -228,6 +229,7 @@ mod tests { flight_velocity: None, hero_walk_velocity: None, hero_look: None, + turret: None, max_floor_clearance: FLOOR_CLEARANCE, previous_terrain_height: None, terrain_height: Some(11.5), @@ -268,6 +270,7 @@ mod tests { flight_velocity: None, hero_walk_velocity: None, hero_look: None, + turret: None, max_floor_clearance: 1.25, previous_terrain_height: Some(10.0), terrain_height: Some(10.0), @@ -293,6 +296,7 @@ mod tests { flight_velocity: None, hero_walk_velocity: None, hero_look: None, + turret: None, max_floor_clearance: FLOOR_CLEARANCE, previous_terrain_height: None, terrain_height: None, @@ -429,6 +433,31 @@ fn plan_player_steps( let boarded = mission .boarding .filter(|boarding| boarding.cockpit.handle == cockpit.handle); + if let Some(aim) = boarded.and_then(|boarding| boarding.turret) { + if [input.mouse_x, input.mouse_y] == [0.0; 2] && !mission.hero_look.has_state() { + return Ok(None); + } + if ![input.mouse_x, input.mouse_y] + .into_iter() + .all(f32::is_finite) + { + return Err(EngineError::Movement("invalid gunner input".into())); + } + let (look, aim) = + crate::bunker_control::advance(engine, cockpit, input, mission.hero_look, aim); + let mut step = plan_motion( + &mission.terrain, + pose, + aim.elevation, + 0.0, + None, + [0.0; 2], + PlayerMotion::default(), + )?; + step.hero_look = Some(look); + step.turret = Some(aim); + return Ok(Some(step)); + } let driving = boarded.filter(|boarding| boarding.controls_chassis()); if boarded.is_some() && driving.is_none() { input.movement = [0.0; 2]; @@ -633,6 +662,9 @@ pub(super) fn commit_motion_state( if boarding.cockpit.handle != cockpit.handle { return; } + if let Some(aim) = step.turret { + boarding.turret = Some(aim); + } if let Some(velocity) = step.flight_velocity { boarding.flight_velocity = if blocked { [0.0; 3] } else { velocity }; } else if !blocked && step.sweep.is_some() { @@ -743,6 +775,7 @@ fn plan_motion( flight_velocity, hero_walk_velocity: None, hero_look: None, + turret: None, max_floor_clearance: FLOOR_CLEARANCE, previous_terrain_height, terrain_height, |
