From 05da53f0344416a5f14211a73f1f48d72c88b954 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 14:38:56 +0400 Subject: feat(ui): drive a strategic warbot with an automatic gunner --- apps/fparkan-game/src/strategic_view.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'apps/fparkan-game/src/strategic_view.rs') diff --git a/apps/fparkan-game/src/strategic_view.rs b/apps/fparkan-game/src/strategic_view.rs index 6e94d28a..8dc0e57c 100644 --- a/apps/fparkan-game/src/strategic_view.rs +++ b/apps/fparkan-game/src/strategic_view.rs @@ -12,6 +12,7 @@ use fparkan_runtime::strategic_view::{ use fparkan_runtime::{ projectile_unit_hit, satellite_contacts, strategic_orders::{self, PatrolTarget}, + RemoteWarbotControl, }; use fparkan_terrain::{FullSurfaceMask, SurfaceHit, SurfaceQuery}; use fparkan_world::ObjectHandle; @@ -388,9 +389,14 @@ impl StaticVulkanApp { view.warbots_open = false; return; } - Some(ListHit::ManualControl) => { + Some(mode @ (ListHit::ManualControl | ListHit::AutoGunner)) => { if let Some(row) = selected { - self.take_manual_warbot_control(row.handle); + let mode = if mode == ListHit::ManualControl { + RemoteWarbotControl::Manual + } else { + RemoteWarbotControl::AutoGunner + }; + self.take_warbot_control(row.handle, mode); } return; } @@ -451,24 +457,32 @@ impl StaticVulkanApp { } } - fn take_manual_warbot_control(&mut self, target: ObjectHandle) { + fn take_warbot_control(&mut self, target: ObjectHandle, mode: RemoteWarbotControl) { let Some((engine, hero)) = self.mission_engine.as_mut().zip(self.cockpit) else { return; }; - let Some(vehicle) = fparkan_runtime::control_warbot_remotely(engine, hero, target) else { + let Some(vehicle) = fparkan_runtime::control_warbot_remotely(engine, hero, target, mode) + else { return; }; self.remote_command_view = self.command_view.take(); if let Some(view) = &mut self.remote_command_view { view.order_input = None; view.pointer = None; + if mode == RemoteWarbotControl::AutoGunner { + view.warbots_open = false; + } } self.cockpit = Some(vehicle); self.boarded_hero_index = Some(hero.object_index); self.boarding_target = None; self.player_mouse = [0.0; 2]; self.player_move_pressed = Default::default(); - if let Some(layout) = self.player_weapon_layouts.get(&vehicle.object_index) { + if let Some(layout) = self + .player_weapon_layouts + .get(&vehicle.object_index) + .filter(|_| mode == RemoteWarbotControl::Manual) + { self.player_weapon_banks .entry(vehicle.handle) .or_insert_with(|| layout.weapons.clone()); -- cgit v1.2.3