diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-14 07:13:33 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-14 07:13:33 +0300 |
| commit | 8a4d037791e031d4e09b5fa9093f3adf71bdb675 (patch) | |
| tree | 218be845d3de83370fc0c6e88859eb4e7228c961 /crates/fparkan-runtime/src/lib.rs | |
| parent | 00c30534a2a01913c50cc7546fd450398251e063 (diff) | |
| download | fparkan-8a4d037791e031d4e09b5fa9093f3adf71bdb675.tar.xz fparkan-8a4d037791e031d4e09b5fa9093f3adf71bdb675.zip | |
test(game): verify firing range objectives via projectile hits
Diffstat (limited to 'crates/fparkan-runtime/src/lib.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/lib.rs | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index d5caabb1..ff0cdf69 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -17267,6 +17267,14 @@ mod tests { None ] ); + let laser = load_player_projectile( + &engine, + &weapons.weapons()[2].projectile_archive, + &weapons.weapons()[2].projectile, + ) + .unwrap(); + let damage = laser.volume.unwrap(); + assert_eq!(damage, 249.0); let first = frame(&mut engine, 5).unwrap().mission_event.unwrap(); assert_eq!( first.notices, @@ -17288,15 +17296,15 @@ mod tests { first_target, ); assert_eq!( - apply_projectile_hit(&mut engine, first_target, 249.0).unwrap(), + apply_projectile_hit(&mut engine, first_target, damage).unwrap(), Some((251.0, false)), ); assert_eq!( - apply_projectile_hit(&mut engine, first_target, 249.0).unwrap(), + apply_projectile_hit(&mut engine, first_target, damage).unwrap(), Some((2.0, false)), ); assert_eq!( - apply_projectile_hit(&mut engine, first_target, 249.0).unwrap(), + apply_projectile_hit(&mut engine, first_target, damage).unwrap(), Some((0.0, true)), ); assert!(projectile_unit_hit(&engine, cockpit.handle, segment).is_none()); @@ -17364,11 +17372,29 @@ mod tests { .unit_dat_header_flags .is_some_and(|class| class & 0x0100_0000 != 0) }) - .filter_map(|draft| mission_object_handle(&engine, draft.original_id?)) + .filter_map(|draft| { + Some(( + mission_object_handle(&engine, draft.original_id?)?, + draft.position, + )) + }) .collect::<Vec<_>>(); assert!(!handles.is_empty()); - for handle in handles { - fparkan_world::request_delete(&mut engine.world, handle).unwrap(); + for (handle, [x, y, z]) in handles { + let segment = [[x - 10.0, y, z], [x + 10.0, y, z]]; + for _ in 0..6 { + let contact = + projectile_unit_hit(&engine, cockpit.handle, segment).unwrap(); + assert_eq!(contact.handle, handle); + let (_, removed) = + apply_projectile_hit(&mut engine, contact.handle, damage) + .unwrap() + .unwrap(); + if removed { + break; + } + } + assert!(transform_state(&engine.world, handle).is_err()); } } let tick = frame(&mut engine, time).unwrap().mission_event.unwrap(); |
