wowlab_engine_content/hooks/arms_warrior/
handler.rs1use 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#[derive(Debug)]
14pub(crate) struct ArmsHandler {
15 inner: CombatHandler,
16 execute_threshold: f64,
17}
18
19impl ArmsHandler {
20 pub(crate) fn try_new(
22 parts: crate::composition::ContentHandlerParts,
23 params: &HandlerParams<'_>,
24 ) -> Result<Self, wowlab_engine_ports::EngineError> {
25 let mut built = parts.into_built();
26 let cfg = register_arms(&mut built, params)?;
27
28 Ok(Self {
29 inner: CombatHandler::from_built(built),
30 execute_threshold: cfg.execute_threshold,
31 })
32 }
33}
34
35crate::hooks::define_spec_handler! {
36impl ArmsHandler(self, inner) {
37 fn on_sim_start(&mut self, ctx: &mut SimContext) {
38 self.inner.on_sim_start(ctx);
39 sync_execute_gate(
40 &mut self.inner,
41 self.execute_threshold,
42 AURA_SUDDEN_DEATH,
43 SPELL_EXECUTE,
44 ctx.state.current_time,
45 );
46 }
47
48 fn on_player_ready(&mut self, ctx: &mut SimContext) -> Option<SpecAction> {
49 sync_execute_gate(
50 &mut self.inner,
51 self.execute_threshold,
52 AURA_SUDDEN_DEATH,
53 SPELL_EXECUTE,
54 ctx.state.current_time,
55 );
56 self.inner.on_player_ready(ctx)
57 }
58
59 fn on_cast_complete(&mut self, event: wowlab_engine_ports::Event, ctx: &mut SimContext) {
60 self.inner.on_cast_complete(event, ctx);
61 sync_execute_gate(
62 &mut self.inner,
63 self.execute_threshold,
64 AURA_SUDDEN_DEATH,
65 SPELL_EXECUTE,
66 ctx.state.current_time,
67 );
68 }
69
70 fn on_spell_impact(&mut self, impact_id: u32, ctx: &mut SimContext) {
71 self.inner.on_spell_impact(impact_id, ctx);
72 }
73
74}
75delegate {
76 fn on_aura_tick(&mut self, event: wowlab_engine_ports::AuraEventRef, ctx: &mut SimContext);
77 fn on_aura_expire(&mut self, event: wowlab_engine_ports::AuraEventRef, ctx: &mut SimContext);
78 fn on_auto_attack(&mut self, source: wowlab_types::sim::ActorId, target: wowlab_types::sim::EnemyIdx, ctx: &mut SimContext);
79 fn on_cooldown_ready(&mut self, cooldown_key: wowlab_types::sim::SpellIdx, ctx: &mut SimContext);
80 fn flush_scheduled(&mut self, push: &mut dyn FnMut(wowlab_engine_ports::Event));
81 fn reset(&mut self);
82 fn total_damage(&self) -> f64;
83 fn cast_time_ms(&self, spell_id: wowlab_types::sim::SpellIdx, empower_rank: u8) -> u32;
84 fn introspect(&self) -> wowlab_types::game::SpecIntrospection;
85 fn paperdoll(&self) -> Option<wowlab_engine_ports::Paperdoll>;
86 fn attach_decision_trace(
87 &mut self,
88 sink: std::sync::Arc<dyn wowlab_engine_ports::DecisionTraceSink>,
89 );
90}
91}