Skip to main content

wowlab_engine_combat/handler/spec_handler/
introspect.rs

1use super::{CombatHandler, build_introspection};
2
3impl CombatHandler {
4    pub(super) fn introspect_impl(&self) -> wowlab_types::game::SpecIntrospection {
5        build_introspection(&self.state, &self.names)
6    }
7
8    pub(super) fn attach_decision_trace_impl(
9        &mut self,
10        sink: std::sync::Arc<dyn wowlab_engine_ports::DecisionTraceSink>,
11    ) {
12        self.engine
13            .set_decision_trace(wowlab_engine_ports::DecisionTraceTarget::new(sink));
14    }
15
16    pub(super) fn paperdoll_impl(&self) -> wowlab_engine_ports::Paperdoll {
17        use wowlab_engine_ports::{Paperdoll, PaperdollLoadout};
18
19        let introspection = build_introspection(&self.state, &self.names);
20
21        // #t(block: rust_unchecked_indexing) local_idx set at build time, always in bounds
22        let precombat_aura_ids: Vec<u32> = self
23            .state
24            .defs
25            .precombat_auras
26            .iter()
27            .map(|&local_idx| self.state.defs.auras[local_idx.as_usize()].aura_id)
28            .collect();
29
30        // #t(block: rust_unchecked_indexing) local_idx set at build time, always in bounds
31        let talent_ranks = self
32            .state
33            .defs
34            .talent_aura_stacks
35            .iter()
36            .map(|&(local_idx, rank)| (self.state.defs.auras[local_idx.as_usize()].aura_id, rank))
37            .collect();
38
39        Paperdoll::new(
40            self.state.config.base_stats.stats.clone(),
41            introspection,
42            PaperdollLoadout {
43                precombat_aura_ids,
44                talent_ranks,
45                item_use_spells: self.state.defs.item_use_spells.clone(),
46                weapon_main: self.state.config.game_data.main_hand(),
47                weapon_off: self.state.config.game_data.off_hand(),
48            },
49        )
50    }
51}