aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/unit_patrol
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 10:09:58 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 10:09:58 +0300
commit5f0b8c076b40f8eca67e2745367c731f803914f4 (patch)
tree95bf85609d44cebfaabb86dede135c728d994cdb /crates/fparkan-runtime/src/unit_patrol
parent7dfbf534267011ad629c11c7140d0f9c0fe9cd3b (diff)
downloadfparkan-5f0b8c076b40f8eca67e2745367c731f803914f4.tar.xz
fparkan-5f0b8c076b40f8eca67e2745367c731f803914f4.zip
feat(ui): select units from the strategic warbot roster
Diffstat (limited to 'crates/fparkan-runtime/src/unit_patrol')
-rw-r--r--crates/fparkan-runtime/src/unit_patrol/orders.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/crates/fparkan-runtime/src/unit_patrol/orders.rs b/crates/fparkan-runtime/src/unit_patrol/orders.rs
index 560f2142..8e9260a1 100644
--- a/crates/fparkan-runtime/src/unit_patrol/orders.rs
+++ b/crates/fparkan-runtime/src/unit_patrol/orders.rs
@@ -50,6 +50,33 @@ pub(crate) fn supports_order(order: &Handler15Invocation) -> bool {
}
impl UnitPatrol {
+ pub(crate) fn active_order_code(&self, actor: ObjectHandle) -> u32 {
+ if self.is_leaving_factory(actor) {
+ return 0x14;
+ }
+ if self.is_shut_down(actor) {
+ return UnitOrder::Shutdown.opcode();
+ }
+ let Some(unit) = self.units.iter().find(|unit| unit.handle == actor) else {
+ return 0;
+ };
+ if unit.capture_target.is_some() {
+ 0x11
+ } else if unit.attack_target.is_some() || unit.raid_factory.is_some() {
+ 3
+ } else if unit
+ .destinations
+ .as_ref()
+ .is_some_and(|points| !points.is_empty())
+ {
+ 2
+ } else if unit.destinations.is_none() {
+ 4
+ } else {
+ 0
+ }
+ }
+
pub(crate) fn satellite_route(&self, actor: ObjectHandle) -> Vec<[f32; 2]> {
let active = self.units.iter().find(|unit| unit.handle == actor);
// iron3d+0x77ae0 prefers the path whenever there are unvisited points.