Skip to main content

wowlab_engine_content/hooks/destruction_warlock/
handler.rs

1use wowlab_engine_combat::GuardianOps as _;
2use wowlab_engine_combat::{CombatHandler, GuardianAbility, GuardianSpec};
3use wowlab_engine_ports::HandlerParams;
4use wowlab_types::constants::MS_PER_SECOND;
5
6use crate::generated::specs::destruction_warlock::REPORTED_SPELL;
7
8use super::hooks::{SAYAAD_ACTION_MS, sayaad_action};
9
10#[derive(Debug)]
11// #t(rust_similar_structs) specialization handlers own independent hook behavior despite matching runtime state fields
12pub(crate) struct DestructionHandler {
13    inner: CombatHandler,
14    fight_duration_ms: u32,
15}
16
17impl DestructionHandler {
18    /// Finishes the specialization handler from the shared-content composition stage.
19    pub(crate) fn new(
20        parts: crate::composition::ContentHandlerParts,
21        params: &HandlerParams<'_>,
22    ) -> Self {
23        let built = parts.into_built();
24
25        Self {
26            inner: CombatHandler::from_built(built),
27            fight_duration_ms: wowlab_types::numeric::f64_to_u32_saturating_trunc(
28                params.fight_duration_secs * MS_PER_SECOND,
29            ),
30        }
31    }
32}
33
34crate::hooks::define_spec_handler! {
35impl DestructionHandler(self, inner) {
36    fn on_sim_start(&mut self, ctx: &mut wowlab_engine_ports::SimContext) {
37        self.inner.on_sim_start(ctx);
38        self.inner
39            .with_hook_ctx(&mut *ctx.telemetry, wowlab_engine_combat::HookCtxRequest::targetless(wowlab_types::sim::SimTime::ZERO), |precombat| {
40                let _ = precombat.summon_guardian(
41                    GuardianSpec::new_inheriting_owner(
42                        REPORTED_SPELL::LASH_OF_PAIN,
43                        self.fight_duration_ms.saturating_add(1),
44                    )
45                    .ability(
46                        GuardianAbility::new(SAYAAD_ACTION_MS, sayaad_action)
47                            .first_action_delay(SAYAAD_ACTION_MS),
48                    ),
49                );
50            });
51    }
52
53}
54}