diff options
Diffstat (limited to 'crates/fparkan-runtime/src/clan_problem_conditions.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/clan_problem_conditions.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/crates/fparkan-runtime/src/clan_problem_conditions.rs b/crates/fparkan-runtime/src/clan_problem_conditions.rs index bace9ec6..00d39173 100644 --- a/crates/fparkan-runtime/src/clan_problem_conditions.rs +++ b/crates/fparkan-runtime/src/clan_problem_conditions.rs @@ -8,6 +8,7 @@ pub(super) enum Condition { BuildingCaptured(ObjectHandle), GroupDestroyed, GroupIdle, + TransportInactive(ObjectHandle), } impl Condition { @@ -17,6 +18,7 @@ impl Condition { clan: OwnerId, patrol: Option<&UnitPatrol>, group: Option<&CombatGroup>, + transport_active: impl Fn(ObjectHandle) -> bool, ) -> bool { let live = |unit| registration_sequence(world, unit).is_ok_and(|sequence| sequence.is_some()); @@ -30,6 +32,7 @@ impl Condition { Self::GroupDestroyed => { group.is_none_or(|group| group.members.iter().all(|&unit| !live(unit))) } + Self::TransportInactive(unit) => !live(unit) || !transport_active(unit), Self::GroupIdle => group.is_none_or(|group| { group.members.iter().all(|&unit| { !live(unit) || patrol.is_none_or(|patrol| !patrol.is_patrolling(unit)) @@ -53,13 +56,13 @@ mod tests { register_object(&mut world, target).unwrap(); let clan = OwnerId(1); set_owner(&mut world, target, Some(OwnerId(0))).unwrap(); - assert!(!Condition::BuildingCaptured(target).met(&world, clan, None, None)); - assert!(!Condition::ObjectDestroyed(Some(target)).met(&world, clan, None, None)); + assert!(!Condition::BuildingCaptured(target).met(&world, clan, None, None, |_| false)); + assert!(!Condition::ObjectDestroyed(Some(target)).met(&world, clan, None, None, |_| false)); set_owner(&mut world, target, Some(clan)).unwrap(); - assert!(Condition::BuildingCaptured(target).met(&world, clan, None, None)); + assert!(Condition::BuildingCaptured(target).met(&world, clan, None, None, |_| false)); fparkan_world::request_delete(&mut world, target).unwrap(); fparkan_world::step(&mut world, &fparkan_world::InputSnapshot).unwrap(); - assert!(Condition::ObjectDestroyed(Some(target)).met(&world, clan, None, None)); - assert!(!Condition::BuildingCaptured(target).met(&world, clan, None, None)); + assert!(Condition::ObjectDestroyed(Some(target)).met(&world, clan, None, None, |_| false)); + assert!(!Condition::BuildingCaptured(target).met(&world, clan, None, None, |_| false)); } } |
