Skip to main content

wowlab_engine_content/hooks/arms_warrior/
handler.rs

1use wowlab_engine_combat::CombatHandler;
2use wowlab_engine_ports::{HandlerParams, SimContext, SpecAction};
3
4
5use crate::{
6    generated::specs::arms_warrior::{AURA_SUDDEN_DEATH, SPELL_EXECUTE},
7    hooks::shared::warrior::sync_execute_gate,
8};
9
10use super::config::register_arms;
11
12/// Arms Warrior combat handler.
13#[derive(Debug)]
14pub(crate) struct ArmsHandler {
15    inner: CombatHandler,
16    execute_threshold: f64,
17}
18
19impl ArmsHandler {
20    /// Finishes the specialization handler from the shared-content composition stage.
21    pub(crate) fn try_new(
22        parts: crate::composition::ContentHandlerParts,
23        params: &HandlerParams<'_>,
24    ) -> Result<Self, wowlab_engine_ports::EngineError> {
25        let mut parts = parts;
26        let built = parts.draft_mut();
27        let cfg = register_arms(built, params)?;
28
29        let built = parts.finalize()?;
30
31        Ok(Self {
32            inner: CombatHandler::from_built(built),
33            execute_threshold: cfg.execute_threshold,
34        })
35    }
36}
37
38crate::hooks::define_spec_handler! {
39impl ArmsHandler(self, inner) {
40    fn on_sim_start(&mut self, ctx: &mut SimContext) {
41        self.inner.on_sim_start(ctx);
42        sync_execute_gate(
43            &mut self.inner,
44            self.execute_threshold,
45            AURA_SUDDEN_DEATH,
46            SPELL_EXECUTE,
47            ctx,
48        );
49    }
50
51    fn on_player_ready(&mut self, ctx: &mut SimContext) -> Option<SpecAction> {
52        sync_execute_gate(
53            &mut self.inner,
54            self.execute_threshold,
55            AURA_SUDDEN_DEATH,
56            SPELL_EXECUTE,
57            ctx,
58        );
59        self.inner.on_player_ready(ctx)
60    }
61
62    fn on_cast_complete(&mut self, event: wowlab_engine_ports::Event, ctx: &mut SimContext) {
63        self.inner.on_cast_complete(event, ctx);
64        sync_execute_gate(
65            &mut self.inner,
66            self.execute_threshold,
67            AURA_SUDDEN_DEATH,
68            SPELL_EXECUTE,
69            ctx,
70        );
71    }
72
73    fn on_spell_impact(&mut self, impact_id: wowlab_engine_ports::PendingImpactBinding, ctx: &mut SimContext) {
74        self.inner.on_spell_impact(impact_id, ctx);
75    }
76
77}
78delegate {
79            fn on_aura_tick(&mut self, event: wowlab_engine_ports::AuraEventRef, ctx: &mut SimContext);
80            fn on_aura_expire(&mut self, event: wowlab_engine_ports::AuraEventRef, ctx: &mut SimContext);
81            fn on_auto_attack(&mut self, source: wowlab_types::sim::ActorId, target: wowlab_types::sim::EnemyIdx, ctx: &mut SimContext);
82            fn on_cooldown_ready(&mut self, spell: wowlab_engine_ports::ScheduledSpellBinding, ctx: &mut SimContext);
83            fn flush_scheduled(&mut self, push: &mut dyn FnMut(wowlab_engine_ports::Event));
84            fn reset(&mut self);
85            fn total_damage(&self) -> f64;
86            fn cast_time_ms(&self, spell: wowlab_engine_ports::ScheduledSpellBinding, empower_rank: u8) -> u32;
87            fn introspect(&self) -> wowlab_types::game::SpecIntrospection;
88            fn paperdoll(&self) -> Option<wowlab_engine_ports::Paperdoll>;
89            fn attach_decision_trace(
90                &mut self,
91                sink: std::sync::Arc<dyn wowlab_engine_ports::DecisionTraceSink>,
92            );
93}
94}