aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/boarding.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 13:38:56 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 13:38:56 +0300
commit05da53f0344416a5f14211a73f1f48d72c88b954 (patch)
treed27d22f56a1bd185447b27223c79c9f97f7cc165 /crates/fparkan-runtime/src/boarding.rs
parent787279a1f514fbbaf09ca9dd6e5015bdce36635b (diff)
downloadfparkan-05da53f0344416a5f14211a73f1f48d72c88b954.tar.xz
fparkan-05da53f0344416a5f14211a73f1f48d72c88b954.zip
feat(ui): drive a strategic warbot with an automatic gunner
Diffstat (limited to 'crates/fparkan-runtime/src/boarding.rs')
-rw-r--r--crates/fparkan-runtime/src/boarding.rs24
1 files changed, 17 insertions, 7 deletions
diff --git a/crates/fparkan-runtime/src/boarding.rs b/crates/fparkan-runtime/src/boarding.rs
index 28ed6f61..b8ec9518 100644
--- a/crates/fparkan-runtime/src/boarding.rs
+++ b/crates/fparkan-runtime/src/boarding.rs
@@ -12,7 +12,10 @@ use fparkan_world::{
pub(super) const WARBOT_CLASS: u32 = 0x0100_8000;
mod remote_control;
-pub use remote_control::{can_control_warbot_remotely, control_warbot_remotely};
+pub use remote_control::{
+ can_control_warbot_remotely, control_warbot_remotely, remote_auto_gunner_weapons,
+ RemoteWarbotControl,
+};
/// Ownership and cockpit changes from one Enter command.
pub struct VehicleEntry {
@@ -34,13 +37,19 @@ impl VehicleEntry {
pub(super) struct Boarding {
pub(super) cockpit: StartingCockpit,
pub(super) hero: StartingCockpit,
- pub(super) remote: bool,
+ pub(super) remote: Option<RemoteWarbotControl>,
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],
}
+impl Boarding {
+ pub(super) fn controls_weapons(self) -> bool {
+ self.remote != Some(RemoteWarbotControl::AutoGunner)
+ }
+}
+
/// The vehicle cockpit while the player is aboard.
#[must_use]
pub fn player_vehicle(engine: &Engine) -> Option<StartingCockpit> {
@@ -167,7 +176,7 @@ pub fn board_friendly_warbot(
..hero_pose
},
)?;
- start_warbot_control(engine, hero, cockpit, false);
+ start_warbot_control(engine, hero, cockpit, None);
Ok(Some(cockpit))
}
@@ -175,7 +184,7 @@ fn start_warbot_control(
engine: &mut Engine,
hero: StartingCockpit,
cockpit: StartingCockpit,
- remote: bool,
+ remote: Option<RemoteWarbotControl>,
) {
let can_fly = crate::player_motion::warbot_can_fly(engine, cockpit.object_index);
if let Some(mission) = &mut engine.loaded {
@@ -306,7 +315,8 @@ pub fn disembark_warbot(engine: &mut Engine) -> Result<Option<StartingCockpit>,
return Ok(None);
};
let mut pose = transform_state(&engine.world, hero.handle)?;
- let vehicle_pose = (!remote)
+ let vehicle_pose = remote
+ .is_none()
.then(|| transform_state(&engine.world, vehicle.handle).ok())
.flatten();
if let Some(vehicle_pose) = vehicle_pose {
@@ -338,7 +348,7 @@ 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 !remote && !can_fly && !on_building_floor {
+ } else if remote.is_none() && !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
@@ -363,7 +373,7 @@ pub(super) fn move_passenger(
vehicle_pose: TransformState,
) -> Option<(ObjectHandle, TransformState)> {
let boarding = engine.loaded.as_ref()?.boarding.as_ref()?;
- if boarding.remote || boarding.cockpit.handle != cockpit.handle {
+ if boarding.remote.is_some() || boarding.cockpit.handle != cockpit.handle {
return None;
}
let hero = boarding.hero;