aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/control_effects.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-26 05:52:25 +0300
committerValentin Popov <valentin@popov.link>2026-11-26 05:52:25 +0300
commit3dd13b710e1e559ef3f5cf15f3c6b50e8377d161 (patch)
treee025018284116f03f10a1fa09b5546a58aaa2ff6 /apps/fparkan-game/src/control_effects.rs
parent5a2aa6ff6b6f4ab2480eed5be90957377d00c9e2 (diff)
downloadfparkan-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/src/control_effects.rs')
-rw-r--r--apps/fparkan-game/src/control_effects.rs45
1 files changed, 43 insertions, 2 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()
+}