diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 10:59:08 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 10:59:08 +0300 |
| commit | 61208d874cb3d9bf93e9f7c60aceebc287454b62 (patch) | |
| tree | e23585ccd89bfd73b36174742acc1777f569afa2 /crates/fparkan-runtime/src/strategic_orders.rs | |
| parent | 20161fbf4fab9080a2d0d6ceedbf1344435cfda0 (diff) | |
| download | fparkan-61208d874cb3d9bf93e9f7c60aceebc287454b62.tar.xz fparkan-61208d874cb3d9bf93e9f7c60aceebc287454b62.zip | |
feat(ui): give warbots standing and route orders
Bind the first two commands to the live selection and shared route controller. Build the order panel from the installed compound controls and game font. In stock Two Fortresses, checked Stand, route drafting on the satellite map and terrain, and movement after confirmation with Vulkan validation.
Diffstat (limited to 'crates/fparkan-runtime/src/strategic_orders.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/strategic_orders.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/crates/fparkan-runtime/src/strategic_orders.rs b/crates/fparkan-runtime/src/strategic_orders.rs new file mode 100644 index 00000000..9e364786 --- /dev/null +++ b/crates/fparkan-runtime/src/strategic_orders.rs @@ -0,0 +1,44 @@ +//! Orders issued by the player from the strategic warbot panel. + +use crate::{strategic_roster::warbot_rows, unit_patrol::UnitPatrol, Engine, StartingCockpit}; +use fparkan_world::ObjectHandle; + +/// Stops the selected warbot and clears its outstanding movement orders. +pub fn stand(engine: &mut Engine, cockpit: StartingCockpit, actor: ObjectHandle) -> bool { + issue(engine, cockpit, actor, None) +} + +/// Replaces the selected warbot's order with the confirmed sequence of world points. +pub fn follow_route( + engine: &mut Engine, + cockpit: StartingCockpit, + actor: ObjectHandle, + points: &[[f32; 2]], +) -> bool { + if points.is_empty() || !points.iter().flatten().all(|value| value.is_finite()) { + return false; + } + issue(engine, cockpit, actor, Some(points.to_vec())) +} + +fn issue( + engine: &mut Engine, + cockpit: StartingCockpit, + actor: ObjectHandle, + route: Option<Vec<[f32; 2]>>, +) -> bool { + if !warbot_rows(engine, cockpit) + .iter() + .any(|row| row.handle == actor && row.selectable) + { + return false; + } + let Some(mission) = engine.loaded.as_mut() else { + return false; + }; + mission + .unit_patrol + .get_or_insert_with(UnitPatrol::scripted) + .command_order(&engine.world, actor, route); + true +} |
