diff options
Diffstat (limited to 'crates/fparkan-runtime/src/boarding.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/boarding.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/fparkan-runtime/src/boarding.rs b/crates/fparkan-runtime/src/boarding.rs index 53ce8c81..e9dd7531 100644 --- a/crates/fparkan-runtime/src/boarding.rs +++ b/crates/fparkan-runtime/src/boarding.rs @@ -4,6 +4,7 @@ use super::{ starting_cockpit, Engine, EngineError, MissionControlDeviceTableState, MissionControlDeviceTableStatus, StartingCockpit, SurfaceQuery, TransformState, }; +use crate::player_motion::FLOOR_CLEARANCE; use fparkan_world::{ handle_by_original_id, identity_metadata, set_transform, transform_state, ObjectHandle, }; @@ -16,6 +17,7 @@ pub(super) struct Boarding { pub(super) hero: StartingCockpit, pub(super) can_fly: bool, pub(super) ground: Option<crate::ground_support::GroundSupport>, + pub(super) on_building_floor: bool, pub(super) flight_velocity: [f32; 3], } @@ -139,6 +141,7 @@ pub fn board_friendly_warbot( hero, can_fly, ground, + on_building_floor: false, flight_velocity: [0.0; 3], }); mission.player_pitch_bits = 0; @@ -186,6 +189,8 @@ pub fn disembark_warbot(engine: &mut Engine) -> Result<Option<StartingCockpit>, let Some(Boarding { cockpit: vehicle, hero, + can_fly, + on_building_floor, .. }) = mission.boarding else { @@ -211,7 +216,7 @@ pub fn disembark_warbot(engine: &mut Engine) -> Result<Option<StartingCockpit>, .height_at(xy) .map_err(EngineError::Terrain)? { - exit = Some([xy[0], xy[1], ground + 0.02]); + exit = Some([xy[0], xy[1], ground + FLOOR_CLEARANCE]); break; } } @@ -221,6 +226,17 @@ pub fn disembark_warbot(engine: &mut Engine) -> Result<Option<StartingCockpit>, pose.position = exit.map(f32::to_bits); pose.orientation[2] = yaw.to_bits(); set_transform(&mut engine.world, hero.handle, pose)?; + } else if !can_fly && !on_building_floor { + // The passenger still has the destroyed chassis's root height. + let [x, y, _] = pose.position.map(f32::from_bits); + if let Some(ground) = mission + .terrain + .height_at([x, y]) + .map_err(EngineError::Terrain)? + { + pose.position[2] = (ground + FLOOR_CLEARANCE).to_bits(); + set_transform(&mut engine.world, hero.handle, pose)?; + } } mission.boarding = None; mission.player_pitch_bits = 0; |
