diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-14 06:47:56 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-14 06:47:56 +0300 |
| commit | c6888a10b8f0512c9b978dd03f0a347b3cac1c0e (patch) | |
| tree | 0eb9301907e19a7eff8da7f962932190891550c8 /crates/fparkan-runtime/src/lib.rs | |
| parent | 9b689e52f59b55ca89307c7b3d10e770c715e565 (diff) | |
| download | fparkan-c6888a10b8f0512c9b978dd03f0a347b3cac1c0e.tar.xz fparkan-c6888a10b8f0512c9b978dd03f0a347b3cac1c0e.zip | |
feat(game): damage and remove units hit by player projectiles
Diffstat (limited to 'crates/fparkan-runtime/src/lib.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/lib.rs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index 302733e5..c527b65a 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -56,7 +56,8 @@ pub use mission_events::{MissionEventStop, MissionEventTick, MissionNotice}; pub use player_motion::{plan_player_motion, PlayerMotion, PlayerMotionStep}; pub use player_weapon::{starting_player_weapons, PlayerWeapons}; pub use projectile::{ - load_player_projectile, projectile_crosses_terrain, PlayerProjectile, ProjectileAssets, + apply_projectile_hit, load_player_projectile, projectile_terrain_hit, projectile_unit_hit, + PlayerProjectile, ProjectileAssets, ProjectileContact, }; const MISSION_DECODED_PAYLOAD_CACHE_ENTRIES: usize = 256; @@ -17269,7 +17270,28 @@ mod tests { assert!(first.stop.is_none()); assert!(frame(&mut engine, 2_004).unwrap().mission_event.is_none()); let first_target = mission_object_handle(&engine, OriginalObjectId(1)).unwrap(); - fparkan_world::request_delete(&mut engine.world, first_target).unwrap(); + let target = &engine.loaded.as_ref().unwrap().object_drafts[1]; + let [x, y, z] = target.position; + let segment = [[x - 10.0, y, z], [x + 10.0, y, z]]; + assert_eq!( + projectile_unit_hit(&engine, cockpit.handle, segment) + .unwrap() + .handle, + first_target, + ); + assert_eq!( + apply_projectile_hit(&mut engine, first_target, 249.0).unwrap(), + Some((251.0, false)), + ); + assert_eq!( + apply_projectile_hit(&mut engine, first_target, 249.0).unwrap(), + Some((2.0, false)), + ); + assert_eq!( + apply_projectile_hit(&mut engine, first_target, 249.0).unwrap(), + Some((0.0, true)), + ); + assert!(projectile_unit_hit(&engine, cockpit.handle, segment).is_none()); let next = frame(&mut engine, 2_005).unwrap().mission_event.unwrap(); assert!(next.stop.is_none()); assert_eq!(next.notices, [MissionNotice::Information(17)]); |
