Skip to main content

wowlab_engine_domain/rotation/lower/ops/
resource.rs

1use super::super::super::backend::RotationBackend;
2use crate::rotation::buffer::ResourceSlot;
3
4const MAX_OFFSET: usize = ResourceSlot::OFF_MAX - ResourceSlot::OFF_CURRENT;
5const REGEN_OFFSET: usize = ResourceSlot::OFF_REGEN_PER_SEC - ResourceSlot::OFF_CURRENT;
6
7pub(crate) fn resource_pct<B>(b: &mut B, offset: usize) -> B::Float
8where
9    B: RotationBackend,
10{
11    let current = b.load_f64(offset);
12    let max = b.load_f64(offset + MAX_OFFSET);
13
14    super::eval_resource_pct(b, current, max)
15}
16
17pub(crate) fn resource_deficit<B>(b: &mut B, offset: usize) -> B::Float
18where
19    B: RotationBackend,
20{
21    let current = b.load_f64(offset);
22    let max = b.load_f64(offset + MAX_OFFSET);
23
24    super::eval_resource_deficit(b, current, max)
25}
26
27pub(crate) fn resource_deficit_pct<B>(b: &mut B, offset: usize) -> B::Float
28where
29    B: RotationBackend,
30{
31    let current = b.load_f64(offset);
32    let max = b.load_f64(offset + MAX_OFFSET);
33
34    super::eval_resource_deficit_pct(b, current, max)
35}
36
37pub(crate) fn resource_time_to_max<B>(b: &mut B, offset: usize) -> B::Float
38where
39    B: RotationBackend,
40{
41    let current = b.load_f64(offset);
42    let max = b.load_f64(offset + MAX_OFFSET);
43    let regen = b.load_f64(offset + REGEN_OFFSET);
44
45    super::eval_resource_time_to_max(b, current, max, regen)
46}