rosu_map/section/hit_objects/slider/
mod.rs1use crate::util::Pos;
2
3use self::path::{PathControlPoint, SliderPath};
4
5use super::{hit_samples::HitSampleInfo, CurveBuffers};
6
7pub mod curve;
8pub mod event;
9pub mod path;
10pub mod path_type;
11
12#[derive(Clone, Debug, PartialEq)]
16pub struct HitObjectSlider {
17 pub pos: Pos,
18 pub new_combo: bool,
19 pub combo_offset: i32,
20 pub path: SliderPath,
21 pub node_samples: Vec<Vec<HitSampleInfo>>,
22 pub repeat_count: i32,
23 pub velocity: f64,
24}
25
26impl HitObjectSlider {
27 pub const fn span_count(&self) -> i32 {
28 self.repeat_count + 1
29 }
30
31 pub fn duration(&mut self) -> f64 {
41 self.duration_with_bufs(&mut CurveBuffers::default())
42 }
43
44 pub fn duration_with_bufs(&mut self, bufs: &mut CurveBuffers) -> f64 {
49 f64::from(self.span_count()) * self.path.curve_with_bufs(bufs).dist() / self.velocity
50 }
51}