aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src
diff options
context:
space:
mode:
Diffstat (limited to 'apps/fparkan-game/src')
-rw-r--r--apps/fparkan-game/src/control_effects.rs45
-rw-r--r--apps/fparkan-game/src/main.rs22
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