aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/mission_events.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-14 20:36:18 +0300
committerValentin Popov <valentin@popov.link>2026-11-14 20:36:18 +0300
commit108dd67da99f9832d2e65e5e18f7d25cc2dfc9ed (patch)
treeed0e44c81aacd8fa91512e10ac0092353700bd5d /crates/fparkan-runtime/src/mission_events.rs
parentc930b4e3a4a693ebcee2e46005c32d42567449d7 (diff)
downloadfparkan-108dd67da99f9832d2e65e5e18f7d25cc2dfc9ed.tar.xz
fparkan-108dd67da99f9832d2e65e5e18f7d25cc2dfc9ed.zip
feat(ai): start the highest-priority clan script problem
Open the matching Start section after Problems0, expose its arguments, and support completion and unreserved placed-unit selection. Two Fortresses enters its laboratory job and reaches Handler(6). Timing, ties and continuation remain explicit approximations.
Diffstat (limited to 'crates/fparkan-runtime/src/mission_events.rs')
-rw-r--r--crates/fparkan-runtime/src/mission_events.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/crates/fparkan-runtime/src/mission_events.rs b/crates/fparkan-runtime/src/mission_events.rs
index b97b154f..d040e4f8 100644
--- a/crates/fparkan-runtime/src/mission_events.rs
+++ b/crates/fparkan-runtime/src/mission_events.rs
@@ -158,6 +158,29 @@ impl MissionEvents {
.count() as u32
}
+ pub(super) fn first_available_placed_unit(
+ &self,
+ mission: &super::MissionDocument,
+ world: &World,
+ clan: usize,
+ class: u32,
+ ) -> Option<u32> {
+ self.placed_clan_objects
+ .iter()
+ .find_map(|&(handle, candidate)| {
+ if candidate != class || self.reserved_units.contains(&(clan, handle)) {
+ return None;
+ }
+ registration_sequence(world, handle).ok()??;
+ let identity = identity_metadata(world, handle).ok()?;
+ if identity.owner_id != Some(OwnerId(clan as u16)) {
+ return None;
+ }
+ let object = mission.objects.get(identity.original_id?.0 as usize)?;
+ Some(object.identity_or_clan_raw)
+ })
+ }
+
pub(super) fn set_reservation(
&mut self,
mission: &super::MissionDocument,