aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/unit_patrol/orders.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/fparkan-runtime/src/unit_patrol/orders.rs')
-rw-r--r--crates/fparkan-runtime/src/unit_patrol/orders.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/crates/fparkan-runtime/src/unit_patrol/orders.rs b/crates/fparkan-runtime/src/unit_patrol/orders.rs
index b956c599..8198b17d 100644
--- a/crates/fparkan-runtime/src/unit_patrol/orders.rs
+++ b/crates/fparkan-runtime/src/unit_patrol/orders.rs
@@ -16,6 +16,7 @@ pub(crate) enum UnitOrder {
Route(Vec<[f32; 2]>),
StrategicPatrol(PatrolTarget),
SearchAndDestroy,
+ Recharge,
Shutdown,
Resume(Box<PatrollingUnit>),
}
@@ -27,6 +28,7 @@ impl UnitOrder {
Self::Attack(..) => 3,
Self::Patrol(..) | Self::StrategicPatrol(_) => 4,
Self::SearchAndDestroy => 5,
+ Self::Recharge => 8,
Self::Shutdown => 0x13,
Self::Stand => 0x15,
Self::Resume(_) => unreachable!("a suspended order has already started"),
@@ -86,6 +88,8 @@ impl UnitPatrol {
0x11
} else if unit.search.is_some() {
UnitOrder::SearchAndDestroy.opcode()
+ } else if unit.recharge.is_some() {
+ UnitOrder::Recharge.opcode()
} else if unit.attack_target.is_some() || unit.raid_factory.is_some() {
3
} else if unit
@@ -105,7 +109,9 @@ impl UnitPatrol {
let active = self.units.iter().find(|unit| unit.handle == actor);
// iron3d+0x77ae0 draws published waypoints. Search does not publish its
// internal navigation path to the satellite map.
- if let Some(unit) = active.filter(|unit| unit.search.is_none() && !unit.points.is_empty()) {
+ if let Some(unit) = active.filter(|unit| {
+ unit.search.is_none() && unit.recharge.is_none() && !unit.points.is_empty()
+ }) {
return unit.points.iter().copied().collect();
}
let mut points = Vec::new();
@@ -127,7 +133,8 @@ impl UnitPatrol {
UnitOrder::Attack(..)
| UnitOrder::Shutdown
| UnitOrder::Stand
- | UnitOrder::SearchAndDestroy => {}
+ | UnitOrder::SearchAndDestroy
+ | UnitOrder::Recharge => {}
}
}
}
@@ -308,6 +315,7 @@ impl UnitPatrol {
return true;
}
UnitOrder::SearchAndDestroy => return self.start_search(world, actor),
+ UnitOrder::Recharge => return self.start_recharge(world, actor),
UnitOrder::Route(route) => {
for (index, &point) in route.iter().enumerate() {
self.move_to(world, actor, point, index != 0);
@@ -399,7 +407,7 @@ impl UnitPatrol {
.iter()
.find(|unit| unit.handle == actor)
.is_none_or(|unit| {
- if unit.capture_target.is_some() {
+ if unit.capture_target.is_some() || unit.recharge.is_some() {
return false;
}
if let Some(points) = &unit.destinations {
@@ -434,6 +442,9 @@ impl UnitPatrol {
impl PatrollingUnit {
fn append_point_orders(&self, points: &mut Vec<[f32; 2]>) {
+ if self.recharge.is_some() {
+ return;
+ }
if let Some(destinations) = &self.destinations {
points.extend(destinations);
} else if self.patrols_point(self.center) && self.raid_factory.is_none() {