1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
use std::cmp::Ordering;
use crate::hitsounds::{Additions, SampleInfo, SampleSet};
use crate::math::Point;
use crate::timing::{TimeLocation, TimingPoint};
use crate::spline::Spline;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub enum SliderSplineKind {
Linear,
Bezier,
Catmull,
Perfect,
}
#[derive(Clone, Debug)]
pub struct SliderInfo {
pub kind: SliderSplineKind,
pub control_points: Vec<Point<i32>>,
pub num_repeats: u32,
pub pixel_length: f64,
pub edge_additions: Vec<Additions>,
pub edge_samplesets: Vec<(SampleSet, SampleSet)>,
}
#[derive(Clone, Debug)]
pub struct SpinnerInfo {
pub end_time: TimeLocation,
}
#[derive(Clone, Debug)]
pub enum HitObjectKind {
Circle,
Slider(SliderInfo),
Spinner(SpinnerInfo),
}
impl HitObjectKind {
pub fn is_circle(&self) -> bool {
match self {
HitObjectKind::Circle => true,
_ => false,
}
}
pub fn is_slider(&self) -> bool {
match self {
HitObjectKind::Slider(_) => true,
_ => false,
}
}
pub fn is_spinner(&self) -> bool {
match self {
HitObjectKind::Spinner(_) => true,
_ => false,
}
}
}
#[derive(Clone, Debug)]
pub struct HitObject {
pub pos: Point<i32>,
pub start_time: TimeLocation,
pub kind: HitObjectKind,
pub new_combo: bool,
pub timing_point: Option<TimingPoint>,
pub skip_color: i32,
pub additions: Additions,
pub sample_info: SampleInfo,
}
impl HitObject {
pub fn end_pos(&self) -> Option<Point<f64>> {
match &self.kind {
HitObjectKind::Slider(info) => {
if info.num_repeats % 2 == 0 {
self.pos.to_float()
} else {
let spline = Spline::from_control(
info.kind,
info.control_points.as_ref(),
info.pixel_length,
);
Some(spline.end_point())
}
}
_ => self.pos.to_float(),
}
}
}
impl Ord for HitObject {
fn cmp(&self, other: &Self) -> Ordering {
self.start_time.cmp(&other.start_time)
}
}
impl PartialOrd for HitObject {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Eq for HitObject {}
impl PartialEq for HitObject {
fn eq(&self, other: &Self) -> bool {
self.start_time == other.start_time
}
}