aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-assets/src/control_weapon_sound.rs
blob: 1d8a6bd1e8abe32dadf362592223530086534898 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use crate::{PreparedComponentControl, PreparedControlEffectRow, PreparedControlEffectSection};

impl PreparedComponentControl {
    /// Initial node-attached sound rows driven by a weapon's timeline.
    pub fn weapon_node_sound_rows(&self) -> impl Iterator<Item = &PreparedControlEffectRow> {
        let rows = match &self.effect_section {
            PreparedControlEffectSection::Parsed(rows) => rows.as_slice(),
            _ => &[],
        };
        rows.iter().filter(|row| {
            row.opcode == 3
                && self.initial_effect_group == Some(row.table_index)
                && row.raw_condition[0] & 0xf000_0000 == 0
                && !self.typed_records.iter().any(|record| {
                    self.weapon_windup_sound_rows(record)
                        .any(|windup| windup.row_index == row.row_index)
                })
                && self.typed_records.iter().any(|record| {
                    record.tag == 2
                        && record.values.iter().any(|&index| {
                            self.timeline_rows
                                .get(index as usize)
                                .is_some_and(|timeline| {
                                    timeline.flags & 0x44 == 0
                                        && timeline.node_index == row.point_offsets[0] as usize
                                })
                        })
                })
        })
    }
}