Skip to main content

wowlab_engine_combat/context/
channel.rs

1use super::HookCtx;
2
3impl HookCtx<'_> {
4    #[cfg(feature = "test-support")]
5    #[doc(hidden)]
6    pub fn set_active_channel_ticks_remaining_for_test(&mut self, ticks: u8) {
7        self.instance.runtime.casting.active_channel_ticks_remaining = ticks;
8    }
9
10    /// Number of scheduled ticks still belonging to the active channel.
11    #[must_use]
12    pub const fn active_channel_ticks_remaining(&self) -> u8 {
13        self.instance.runtime.casting.active_channel_ticks_remaining
14    }
15
16    /// Whether the channel tick being processed is the channel's final one.
17    ///
18    /// The signal is the channel's own remaining-tick count rather than a timestamp comparison.
19    #[must_use]
20    pub const fn is_last_channel_tick(&self) -> bool {
21        self.instance.runtime.casting.active_channel_on_last_tick
22    }
23
24    /// Multiply damage dealt by every tick of the channel currently being started.
25    ///
26    /// Cast hooks can snapshot cast-start mechanics without projecting them into a temporary aura.
27    /// Returns `false` outside an active channel or for an invalid multiplier.
28    pub fn multiply_active_channel_damage(&mut self, multiplier: f64) -> bool {
29        if self
30            .instance
31            .runtime
32            .casting
33            .active_channel_target
34            .is_none()
35            || !multiplier.is_finite()
36            || multiplier < 0.0
37        {
38            return false;
39        }
40
41        self.instance.runtime.casting.active_channel_damage_mult *= multiplier;
42
43        true
44    }
45}