Skip to main content

wowlab_engine_content/hooks/fury_warrior/
handler.rs

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