diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-26 05:52:25 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-26 05:52:25 +0300 |
| commit | 3dd13b710e1e559ef3f5cf15f3c6b50e8377d161 (patch) | |
| tree | e025018284116f03f10a1fa09b5546a58aaa2ff6 /apps/fparkan-game | |
| parent | 5a2aa6ff6b6f4ab2480eed5be90957377d00c9e2 (diff) | |
| download | fparkan-3dd13b710e1e559ef3f5cf15f3c6b50e8377d161.tar.xz fparkan-3dd13b710e1e559ef3f5cf15f3c6b50e8377d161.zip | |
feat(combat): activate mounted flash effects on autonomous shots
Carry the prepared effect row with each shot. Use the existing mode 4 visual effect for that component at release, with its authored geometry, lights and CPT placement. Keep the one-shot sound on its existing event path.
Verified stock AutoDemo shot frames submit the authored muzzle light with Vulkan validation clean. A matched on-screen comparison and the full flash curve remain open.
Diffstat (limited to 'apps/fparkan-game')
| -rw-r--r-- | apps/fparkan-game/src/control_effects.rs | 45 | ||||
| -rw-r--r-- | apps/fparkan-game/src/main.rs | 22 |
2 files changed, 63 insertions, 4 deletions
diff --git a/apps/fparkan-game/src/control_effects.rs b/apps/fparkan-game/src/control_effects.rs index e70b33e5..a21606d4 100644 --- a/apps/fparkan-game/src/control_effects.rs +++ b/apps/fparkan-game/src/control_effects.rs @@ -4,8 +4,8 @@ use super::{ MissionRenderRoot, SceneSampleId, }; use fparkan_fx::clock::{FxInstanceClock, FxPhaseProvider}; -use fparkan_runtime::{loaded_mission_control_device_tables, Engine}; -use std::collections::HashMap; +use fparkan_runtime::{loaded_mission_control_device_tables, AutoDemoCombatEvent, Engine}; +use std::collections::{HashMap, HashSet}; pub(super) fn owner_control_capacity( engine: &Engine, @@ -108,3 +108,44 @@ pub(super) fn advance_control_effect_instances( ) .collect() } + +pub(super) fn activate_firing_flashes( + samples: &mut HashMap<ControlEffectInstanceKey, ControlEffectFrameSample>, + ambient_slots: &[AmbientEffectGpuSlot], + point_light_slots: &[ControlEffectSlot], + events: &[AutoDemoCombatEvent], +) -> HashSet<ControlEffectInstanceKey> { + events + .iter() + .filter_map(|event| { + let AutoDemoCombatEvent::Shot { + effect_instance: Some(effect), + .. + } = *event + else { + return None; + }; + let key = ControlEffectInstanceKey { + object_index: effect.object_index, + component_index: effect.component_index, + table_index: effect.table_index, + row_index: effect.row_index, + }; + let has_external_flash = ambient_slots + .iter() + .any(|slot| slot.random_instance_key == key && slot.time_mode == 4) + || point_light_slots + .iter() + .any(|slot| slot.random_instance_key == key && slot.time_mode == 4); + if !has_external_flash { + return None; + } + let sample = samples.get_mut(&key)?; + // shortcut: the release occurs at the midpoint of the weapon cycle. + // Keep the flash to this snapshot until the full effect phase is wired. + sample.phase = Some(0.5); + sample.elapsed_seconds = 0.0; + Some(key) + }) + .collect() +} diff --git a/apps/fparkan-game/src/main.rs b/apps/fparkan-game/src/main.rs index 6b337fc8..98a34f6e 100644 --- a/apps/fparkan-game/src/main.rs +++ b/apps/fparkan-game/src/main.rs @@ -8,7 +8,9 @@ mod camera_capture; mod chassis_animation; #[cfg(windows)] mod control_effects; -use control_effects::{advance_control_effect_instances, owner_control_capacity}; +use control_effects::{ + activate_firing_flashes, advance_control_effect_instances, owner_control_capacity, +}; mod mission_hints; mod mission_notices; mod mission_pause; @@ -11414,7 +11416,7 @@ impl StaticVulkanApp { } else { None }; - let control_effect_random_samples = advance_control_effect_instances( + let mut control_effect_random_samples = advance_control_effect_instances( &mut self.control_effect_instance_states, &self.ambient_effect_slots, &self.control_point_light_slots, @@ -11432,6 +11434,18 @@ impl StaticVulkanApp { ) }, ); + let firing_flashes = self + .mission_frame + .as_ref() + .map(|frame| { + activate_firing_flashes( + &mut control_effect_random_samples, + &self.ambient_effect_slots, + &self.control_point_light_slots, + &frame.autodemo_combat_events, + ) + }) + .unwrap_or_default(); let control_point_lights = update_control_point_lights( &mut self.control_point_light_slots, &mut self.op1_jitter, @@ -11628,6 +11642,10 @@ impl StaticVulkanApp { audio.stop_control_sound(id); continue; } + // The same firing event starts its one-shot directly. + if firing_flashes.contains(&slot.random_instance_key) { + continue; + } if slot.owner_component_is_mounted { slot.mount_pose = self .component_mount_poses |
