diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-26 22:11:31 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-26 22:11:31 +0300 |
| commit | f626d7759e371ba29efbb733c394751fea547d04 (patch) | |
| tree | 8b5bf344f461d6a47cdbf2c5db8cc97ab22aa6ad /crates/fparkan-runtime/src | |
| parent | 2259ef230be7940a2bd64846e5d3001fa14a772c (diff) | |
| download | fparkan-f626d7759e371ba29efbb733c394751fea547d04.tar.xz fparkan-f626d7759e371ba29efbb733c394751fea547d04.zip | |
fix(combat): show muzzle flashes for manual fire
Send the player's linked Control row through the existing firing flash sampler. On the stock Constructor start, the 25 mm cannon emits the authored sprite and a light at the muzzle from an external camera. Full node-driven mode-4 phase remains open.
Diffstat (limited to 'crates/fparkan-runtime/src')
| -rw-r--r-- | crates/fparkan-runtime/src/player_weapon.rs | 27 | ||||
| -rw-r--r-- | crates/fparkan-runtime/src/unit_combat.rs | 9 |
2 files changed, 25 insertions, 11 deletions
diff --git a/crates/fparkan-runtime/src/player_weapon.rs b/crates/fparkan-runtime/src/player_weapon.rs index 0ab0613f..8e350d16 100644 --- a/crates/fparkan-runtime/src/player_weapon.rs +++ b/crates/fparkan-runtime/src/player_weapon.rs @@ -28,7 +28,7 @@ pub struct PlayerWeapon { pub projectile_archive: String, /// Optional type-4 effect started by this weapon. pub effect: Option<(String, String)>, - pub(super) effect_row: Option<(usize, usize)>, + effect_row: Option<(usize, usize)>, windup_sound_rows: Vec<(usize, usize)>, windup_started: bool, barrels: Vec<Barrel>, @@ -230,6 +230,17 @@ impl PlayerWeapon { shot } + /// The Control effect instance bound to this weapon's release. + pub fn firing_effect(&self, object_index: usize) -> Option<FiringEffectInstance> { + self.effect_row + .map(|(table_index, row_index)| FiringEffectInstance { + object_index, + component_index: self.component_index, + table_index, + row_index, + }) + } + /// Prepared node-attached sound rows belonging to this device. pub fn windup_sounds( &self, @@ -477,7 +488,7 @@ mod tests { projectile: String::from("test"), projectile_archive: String::from("test.rlb"), effect: None, - effect_row: None, + effect_row: Some((2, 3)), windup_sound_rows: vec![(0, 1)], windup_started: false, barrels: vec![Barrel { @@ -535,7 +546,17 @@ mod tests { assert!(weapons.fire(false, 10).next().is_none()); weapons.apply_firing_pose(0, &mut node_times); assert_eq!(node_times, [Some(6.0)]); - assert_eq!(weapons.fire(false, 11).next().unwrap().0, 0); + let (slot, weapon, _) = weapons.fire(false, 11).next().unwrap(); + assert_eq!(slot, 0); + assert_eq!( + weapon.firing_effect(7), + Some(FiringEffectInstance { + object_index: 7, + component_index: 0, + table_index: 2, + row_index: 3, + }) + ); assert!(weapons.fire(false, 16).next().is_none()); weapons.apply_firing_pose(0, &mut node_times); assert_eq!(node_times, [Some(7.0)]); diff --git a/crates/fparkan-runtime/src/unit_combat.rs b/crates/fparkan-runtime/src/unit_combat.rs index c43cc302..10c13f01 100644 --- a/crates/fparkan-runtime/src/unit_combat.rs +++ b/crates/fparkan-runtime/src/unit_combat.rs @@ -671,14 +671,7 @@ impl AutoDemoCombat { target, projectile, effect: unit.effects[slot], - effect_instance: weapon.effect_row.map(|(table_index, row_index)| { - FiringEffectInstance { - object_index: unit.index, - component_index: weapon.component_index, - table_index, - row_index, - } - }), + effect_instance: weapon.firing_effect(unit.index), muzzle_bits: from.map(f32::to_bits), }); } else { |
