Skip to main content

wowlab_engine_domain/rotation/buffer/dense/
aura_ops.rs

1use super::{BoundDenseBuffer, DenseBuffer};
2use crate::rotation::buffer::{AuraSlot, AuraSlotHandle, AuraTransferState};
3
4impl DenseBuffer {
5    #[inline]
6    pub(crate) fn aura_at(&self, handle: AuraSlotHandle) -> &AuraSlot {
7        self.slot_ref::<AuraSlot>(handle.offset())
8    }
9
10    /// Replace an aura slot with a fresh semantic activation.
11    #[inline]
12    pub(crate) fn activate_aura_at(
13        &mut self,
14        handle: AuraSlotHandle,
15        expires_at: f64,
16        base_duration: f64,
17        stacks: i32,
18        max_stacks: i32,
19    ) {
20        let slot = self.slot_mut::<AuraSlot>(handle.offset());
21
22        *slot = AuraSlot::default();
23        slot.expires_at = expires_at;
24        slot.base_duration = base_duration;
25        slot.stacks = stacks;
26        slot.max_stacks = max_stacks;
27    }
28
29    /// Refresh the expiry and stacks of an occupied aura slot.
30    #[inline]
31    pub(crate) fn refresh_aura_at(
32        &mut self,
33        handle: AuraSlotHandle,
34        expires_at: Option<f64>,
35        stacks: i32,
36    ) {
37        let slot = self.slot_mut::<AuraSlot>(handle.offset());
38
39        if !slot.is_occupied() {
40            return;
41        }
42
43        if let Some(expires_at) = expires_at {
44            slot.expires_at = expires_at;
45        }
46
47        slot.stacks = stacks;
48    }
49
50    /// Clear one aura slot for semantic expiry or reset.
51    #[inline]
52    pub(crate) fn expire_aura_at(&mut self, handle: AuraSlotHandle) {
53        self.slot_mut::<AuraSlot>(handle.offset()).remove();
54    }
55
56    /// Replace stacks on an occupied aura slot.
57    #[inline]
58    pub(crate) fn set_aura_stacks_at(&mut self, handle: AuraSlotHandle, stacks: i32) {
59        let slot = self.slot_mut::<AuraSlot>(handle.offset());
60
61        if slot.is_occupied() {
62            slot.stacks = stacks;
63        }
64    }
65
66    /// Replace expiry metadata on an occupied aura slot.
67    #[inline]
68    pub(crate) fn set_aura_expiry_at(&mut self, handle: AuraSlotHandle, expires_at: f64) {
69        let slot = self.slot_mut::<AuraSlot>(handle.offset());
70
71        if slot.is_occupied() {
72            slot.expires_at = expires_at;
73        }
74    }
75
76    /// Replace periodic scheduling metadata on an occupied aura slot.
77    #[inline]
78    pub(crate) fn set_aura_schedule_at(
79        &mut self,
80        handle: AuraSlotHandle,
81        next_tick: f64,
82        tick_interval: f64,
83        base_tick_interval: f64,
84        time_rate_multiplier: f64,
85        remaining_ticks: i32,
86    ) {
87        let slot = self.slot_mut::<AuraSlot>(handle.offset());
88
89        if !slot.is_occupied() {
90            return;
91        }
92
93        slot.next_tick = next_tick;
94        slot.tick_interval = tick_interval;
95        slot.base_tick_interval = base_tick_interval;
96        slot.time_rate_multiplier = time_rate_multiplier;
97        slot.remaining_ticks = remaining_ticks;
98    }
99
100    /// Replace only the next periodic deadline on an occupied aura slot.
101    #[inline]
102    pub(crate) fn set_aura_next_tick_at(&mut self, handle: AuraSlotHandle, next_tick: f64) {
103        let slot = self.slot_mut::<AuraSlot>(handle.offset());
104
105        if slot.is_occupied() {
106            slot.next_tick = next_tick;
107        }
108    }
109
110    /// Replace only the aura time-rate multiplier on an occupied aura slot.
111    #[inline]
112    pub(crate) fn set_aura_time_rate_at(&mut self, handle: AuraSlotHandle, multiplier: f64) {
113        let slot = self.slot_mut::<AuraSlot>(handle.offset());
114
115        if slot.is_occupied() {
116            slot.time_rate_multiplier = multiplier;
117        }
118    }
119
120    /// Replace snapshot metadata on an occupied aura slot.
121    #[inline]
122    #[expect(
123        clippy::too_many_arguments,
124        reason = "the fixed aura snapshot is one atomic flat metadata record"
125    )]
126    // #t(fn: rust_large_fn_params) the fixed aura snapshot is one atomic metadata record.
127    pub(crate) fn set_aura_snapshot_at(
128        &mut self,
129        handle: AuraSlotHandle,
130        has_snapshot: i32,
131        attack_power: f64,
132        spell_power: f64,
133        critical_chance: f64,
134        versatility: f64,
135        mastery_multiplier: f64,
136        damage_multiplier: f64,
137    ) {
138        let slot = self.slot_mut::<AuraSlot>(handle.offset());
139
140        if !slot.is_occupied() {
141            return;
142        }
143
144        slot.snapshot_has = has_snapshot;
145        slot.snapshot_ap = attack_power;
146        slot.snapshot_sp = spell_power;
147        slot.snapshot_crit = critical_chance;
148        slot.snapshot_vers = versatility;
149        slot.snapshot_mastery_mult = mastery_multiplier;
150        slot.snapshot_damage_mult = damage_multiplier;
151    }
152
153    /// Install an opaque aura transfer into its destination slot.
154    #[inline]
155    pub(crate) fn transfer_aura_at(&mut self, handle: AuraSlotHandle, transfer: AuraTransferState) {
156        *self.slot_mut::<AuraSlot>(handle.offset()) = transfer.slot();
157    }
158}
159
160impl BoundDenseBuffer {
161    #[inline]
162    #[must_use]
163    pub fn aura_at(&self, handle: AuraSlotHandle) -> &AuraSlot {
164        self.inner.aura_at(handle)
165    }
166
167    #[inline]
168    pub fn activate_aura_at(
169        &mut self,
170        handle: AuraSlotHandle,
171        expires_at: f64,
172        base_duration: f64,
173        stacks: i32,
174        max_stacks: i32,
175    ) {
176        self.inner
177            .activate_aura_at(handle, expires_at, base_duration, stacks, max_stacks);
178    }
179
180    #[inline]
181    pub fn refresh_aura_at(
182        &mut self,
183        handle: AuraSlotHandle,
184        expires_at: Option<f64>,
185        stacks: i32,
186    ) {
187        self.inner.refresh_aura_at(handle, expires_at, stacks);
188    }
189
190    #[inline]
191    pub fn expire_aura_at(&mut self, handle: AuraSlotHandle) {
192        self.inner.expire_aura_at(handle);
193    }
194
195    #[inline]
196    pub fn set_aura_stacks_at(&mut self, handle: AuraSlotHandle, stacks: i32) {
197        self.inner.set_aura_stacks_at(handle, stacks);
198    }
199
200    #[inline]
201    pub fn set_aura_expiry_at(&mut self, handle: AuraSlotHandle, expires_at: f64) {
202        self.inner.set_aura_expiry_at(handle, expires_at);
203    }
204
205    #[inline]
206    pub fn set_aura_schedule_at(
207        &mut self,
208        handle: AuraSlotHandle,
209        next_tick: f64,
210        tick_interval: f64,
211        base_tick_interval: f64,
212        time_rate_multiplier: f64,
213        remaining_ticks: i32,
214    ) {
215        self.inner.set_aura_schedule_at(
216            handle,
217            next_tick,
218            tick_interval,
219            base_tick_interval,
220            time_rate_multiplier,
221            remaining_ticks,
222        );
223    }
224
225    #[inline]
226    pub fn set_aura_next_tick_at(&mut self, handle: AuraSlotHandle, next_tick: f64) {
227        self.inner.set_aura_next_tick_at(handle, next_tick);
228    }
229
230    #[inline]
231    pub fn set_aura_time_rate_at(&mut self, handle: AuraSlotHandle, multiplier: f64) {
232        self.inner.set_aura_time_rate_at(handle, multiplier);
233    }
234
235    #[inline]
236    #[expect(
237        clippy::too_many_arguments,
238        reason = "the fixed aura snapshot is one atomic flat metadata record"
239    )]
240    // #t(fn: rust_large_fn_params) the fixed aura snapshot is one atomic metadata record.
241    pub fn set_aura_snapshot_at(
242        &mut self,
243        handle: AuraSlotHandle,
244        has_snapshot: i32,
245        attack_power: f64,
246        spell_power: f64,
247        critical_chance: f64,
248        versatility: f64,
249        mastery_multiplier: f64,
250        damage_multiplier: f64,
251    ) {
252        self.inner.set_aura_snapshot_at(
253            handle,
254            has_snapshot,
255            attack_power,
256            spell_power,
257            critical_chance,
258            versatility,
259            mastery_multiplier,
260            damage_multiplier,
261        );
262    }
263
264    #[inline]
265    pub fn transfer_aura_at(&mut self, handle: AuraSlotHandle, transfer: AuraTransferState) {
266        self.inner.transfer_aura_at(handle, transfer);
267    }
268}