diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-14 07:40:25 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-14 07:40:25 +0300 |
| commit | a5e3539789aa3eba2b486b3bdfd7961761bc7df4 (patch) | |
| tree | f149c01bc7be47d5ff174d3b72a599a7d9d12013 /crates/fparkan-runtime/src/lib.rs | |
| parent | 72d0ef912751f621d11d7d045e506904003c0b9a (diff) | |
| download | fparkan-a5e3539789aa3eba2b486b3bdfd7961761bc7df4.tar.xz fparkan-a5e3539789aa3eba2b486b3bdfd7961761bc7df4.zip | |
fix(game): schedule player fire from authored weapon phases
Diffstat (limited to 'crates/fparkan-runtime/src/lib.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/lib.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index 78949222..3fae8ea6 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -17246,6 +17246,25 @@ mod tests { .collect::<Vec<_>>(), [Some(500), Some(150), None, Some(4)] ); + let mut weapons = weapons; + let mut shots = [const { Vec::new() }; 4]; + let mut missile_points = Vec::new(); + for ms in (0..=9000).step_by(17) { + for (slot, _, muzzle) in weapons.fire(true, ms) { + shots[slot].push(ms); + if slot == 3 { + missile_points.push(muzzle.position); + } + } + } + assert_eq!(&shots[0][..4], [136, 408, 680, 952]); + assert_eq!(&shots[1][..4], [255, 1020, 1785, 2550]); + assert_eq!(&shots[2][..4], [136, 595, 1054, 1513]); + assert_eq!(shots[3], [510, 2465, 4420, 6375]); + assert_ne!(missile_points[0], missile_points[1]); + assert_eq!(missile_points[0], missile_points[2]); + assert_eq!(missile_points[1], missile_points[3]); + assert_eq!(weapons.weapons()[3].rounds_remaining(), Some(0)); for (weapon, (speed, lifetime_ms)) in weapons.weapons().iter().zip([ (350.0, 1000), (150.0, 5000), |
