rosu_map/section/timing_points/control_points/
effect.rs

1use std::cmp::Ordering;
2
3#[derive(Clone, Debug, PartialEq)]
4/// Effect-related info about this control point.
5pub struct EffectPoint {
6    pub time: f64,
7    pub kiai: bool,
8    pub scroll_speed: f64,
9}
10
11impl EffectPoint {
12    pub const DEFAULT_KIAI: bool = false;
13    pub const DEFAULT_SCROLL_SPEED: f64 = 1.0;
14
15    pub const fn new(time: f64, kiai: bool) -> Self {
16        Self {
17            time,
18            kiai,
19            scroll_speed: Self::DEFAULT_SCROLL_SPEED,
20        }
21    }
22
23    pub fn is_redundant(&self, existing: &Self) -> bool {
24        self.kiai == existing.kiai
25            && (self.scroll_speed - existing.scroll_speed).abs() < f64::EPSILON
26    }
27}
28
29impl Default for EffectPoint {
30    fn default() -> Self {
31        Self {
32            time: 0.0,
33            kiai: Self::DEFAULT_KIAI,
34            scroll_speed: Self::DEFAULT_SCROLL_SPEED,
35        }
36    }
37}
38
39impl PartialOrd for EffectPoint {
40    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
41        self.time.partial_cmp(&other.time)
42    }
43}