Skip to main content

wowlab_engine_domain/rotation/buffer/
unit.rs

1wowlab_engine_macros::define_slot! {
2    #[slot(domain = "unit", kind = keyed, key_domain = "role")]
3    pub struct UnitSlot {
4        #[expr("health", Float, Direct)]
5        #[expr("health_pct", Float, UnitHealthPct)]
6        #[expr("health_deficit", Float, UnitHealthDeficit)]
7        pub health: f64,
8
9        #[expr("health_max", Float, Direct)]
10        pub max_health: f64,
11
12        #[expr("is_boss", Bool, Direct)]
13        pub is_boss: i32,
14
15        _padding_after_is_boss: i32,
16
17        #[expr("time_to_die", Float, Direct)]
18        pub time_to_die: f64,
19
20        #[expr("is_casting", Bool, Direct)]
21        pub is_casting: i32,
22
23        _padding_after_is_casting: i32,
24
25        #[expr("cast_remaining", Float, TimestampRemaining)]
26        pub cast_end: f64,
27
28        #[expr("is_moving", Bool, Direct)]
29        pub is_moving: i32,
30
31        #[expr("is_add", Bool, Direct)]
32        pub is_add: i32,
33
34        #[expr("distance", Float, Direct)]
35        pub distance: f64,
36    }
37
38    impl {
39        #[must_use]
40        pub fn health_pct(&self) -> f64 {
41            crate::rotation::lower::ops::eval_unit_health_pct(
42                &mut crate::rotation::lower::ops::ScalarEvalOps,
43                self.health,
44                self.max_health,
45            )
46        }
47
48        #[must_use]
49        pub fn health_deficit(&self) -> f64 {
50            crate::rotation::lower::ops::eval_unit_health_deficit(
51                &mut crate::rotation::lower::ops::ScalarEvalOps,
52                self.health,
53                self.max_health,
54            )
55        }
56    }
57}