aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/boarding.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-14 18:40:24 +0300
committerValentin Popov <valentin@popov.link>2026-11-14 18:40:24 +0300
commit99abb6bf77c259a1afb629f418f5aad64e20de75 (patch)
tree41b4fb8e4723789014af9853700e3430e0776990 /crates/fparkan-runtime/src/boarding.rs
parent5fee115996fdbb9235e96289c74c6b8f0244ebd6 (diff)
downloadfparkan-99abb6bf77c259a1afb629f418f5aad64e20de75.tar.xz
fparkan-99abb6bf77c259a1afb629f418f5aad64e20de75.zip
fix(player): require working Control device for boarding
Diffstat (limited to 'crates/fparkan-runtime/src/boarding.rs')
-rw-r--r--crates/fparkan-runtime/src/boarding.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/crates/fparkan-runtime/src/boarding.rs b/crates/fparkan-runtime/src/boarding.rs
index 257b81f7..ec786a21 100644
--- a/crates/fparkan-runtime/src/boarding.rs
+++ b/crates/fparkan-runtime/src/boarding.rs
@@ -1,5 +1,6 @@
use super::{
- component_cockpit, projectile::unit_sphere, starting_cockpit, Engine, EngineError,
+ component_cockpit, control_device_provider_value, projectile::unit_sphere, starting_cockpit,
+ Engine, EngineError, MissionControlDeviceTableState, MissionControlDeviceTableStatus,
StartingCockpit, SurfaceQuery, TransformState,
};
use fparkan_world::{
@@ -52,6 +53,13 @@ pub fn board_friendly_warbot(engine: &mut Engine) -> Result<Option<StartingCockp
if identity_metadata(&engine.world, handle).ok()?.owner_id != Some(owner) {
return None;
}
+ let table = mission
+ .control_device_tables
+ .iter()
+ .find(|table| table.handle == handle)?;
+ if !has_working_pilot_control(table) {
+ return None;
+ }
let state = transform_state(&engine.world, handle).ok()?;
let (center, radius) = unit_sphere(&mission.mission_assets, index, state)?;
let distance = center
@@ -90,6 +98,18 @@ pub fn board_friendly_warbot(engine: &mut Engine) -> Result<Option<StartingCockp
Ok(Some(cockpit))
}
+fn has_working_pilot_control(table: &MissionControlDeviceTableState) -> bool {
+ let MissionControlDeviceTableStatus::Available(devices) = &table.status else {
+ return false;
+ };
+ devices
+ .iter()
+ .find(|device| device.descriptor.tag == 1)
+ .is_some_and(|device| {
+ control_device_provider_value(table, device).is_ok_and(|value| value > 0.0)
+ })
+}
+
/// Leaves the vehicle and restores the hero's cockpit.
///
/// # Errors