Skip to main content

wowlab_engine_content/hooks/devourer_demon_hunter/
handler.rs

1use wowlab_engine_combat::ResourceOps as _;
2use wowlab_engine_combat::AuraOps as _;
3use wowlab_engine_combat::CombatHandler;
4use wowlab_engine_domain::dbc::ResolvedGameDataEffectExt as _;
5use wowlab_engine_ports::{HandlerParams, SimContext};
6
7
8use crate::generated::specs::devourer_demon_hunter::{
9    AURA_FOCUSED_RAY, AURA_SOUL_FRAGMENTS, AURA_VOID_METAMORPHOSIS_STACK, EFFECT,
10};
11
12use super::config::register_devourer;
13
14const PRECOMBAT_CONSUME_FURY: f64 = 8.0;
15
16/// Devourer Demon Hunter combat handler.
17#[derive(Debug)]
18pub(crate) struct DevourerHandler {
19    inner: CombatHandler,
20}
21
22impl DevourerHandler {
23    /// Finishes the specialization handler from the shared-content composition stage.
24    pub(crate) fn try_new(
25        parts: crate::composition::ContentHandlerParts,
26        params: &HandlerParams<'_>,
27    ) -> Result<Self, wowlab_engine_ports::EngineError> {
28        let mut built = parts.into_built();
29
30        register_devourer(&mut built, params)?;
31
32        Ok(Self {
33            inner: CombatHandler::from_built(built),
34        })
35    }
36}
37
38crate::hooks::define_spec_handler! {
39impl DevourerHandler(self, inner) {
40    fn on_sim_start(&mut self, ctx: &mut SimContext) {
41        self.inner.on_sim_start(ctx);
42
43        let starting_souls = wowlab_types::numeric::f64_to_i32_saturating_trunc(
44            self.inner.state().config.game_data.effect_base_points(EFFECT::ENTROPY_STARTING_SOULS),
45        );
46
47        self.inner.with_hook_ctx(&mut *ctx.telemetry, wowlab_engine_combat::HookCtxRequest::targetless(wowlab_types::sim::SimTime::ZERO), |pre| {
48            pre.apply_aura(AURA_FOCUSED_RAY.raw());
49            pre.apply_aura_n(AURA_VOID_METAMORPHOSIS_STACK.raw(), starting_souls);
50            pre.gain_resource(PRECOMBAT_CONSUME_FURY);
51            pre.apply_aura(AURA_SOUL_FRAGMENTS.raw());
52            pre.apply_aura(AURA_VOID_METAMORPHOSIS_STACK.raw());
53        });
54    }
55
56}
57}