aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/control_effects.rs
diff options
context:
space:
mode:
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()
+}