diff options
Diffstat (limited to 'crates/fparkan-runtime/src/unit_patrol')
| -rw-r--r-- | crates/fparkan-runtime/src/unit_patrol/orders.rs | 27 |
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. |
