initial rewrite

This commit is contained in:
MaxOhn
2024-02-09 17:54:14 +01:00
parent ecf1b2c7f4
commit a8bf9601b6
190 changed files with 10892 additions and 18142 deletions
+8
View File
@@ -0,0 +1,8 @@
pub use rosu_map::section::timing_points::DifficultyPoint;
pub fn difficulty_point_at(points: &[DifficultyPoint], time: f64) -> Option<&DifficultyPoint> {
points
.binary_search_by(|probe| probe.time.total_cmp(&time))
.map_or_else(|i| i.checked_sub(1), Some)
.map(|i| &points[i])
}
+34
View File
@@ -0,0 +1,34 @@
/// Effect-related info about this control point.
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct EffectPoint {
pub time: f64,
pub kiai: bool,
}
impl EffectPoint {
pub const DEFAULT_KIAI: bool = rosu_map::section::timing_points::EffectPoint::DEFAULT_KIAI;
pub const fn new(time: f64, kiai: bool) -> Self {
Self { time, kiai }
}
pub const fn is_redundant(&self, existing: &Self) -> bool {
self.kiai == existing.kiai
}
}
impl Default for EffectPoint {
fn default() -> Self {
Self {
time: 0.0,
kiai: Self::DEFAULT_KIAI,
}
}
}
pub fn effect_point_at(points: &[EffectPoint], time: f64) -> Option<&EffectPoint> {
points
.binary_search_by(|probe| probe.time.total_cmp(&time))
.map_or_else(|i| i.checked_sub(1), Some)
.map(|i| &points[i])
}
+9
View File
@@ -0,0 +1,9 @@
pub use self::{difficulty::DifficultyPoint, effect::EffectPoint, timing::TimingPoint};
pub(crate) use self::{
difficulty::difficulty_point_at, effect::effect_point_at, timing::timing_point_at,
};
mod difficulty;
mod effect;
mod timing;
+35
View File
@@ -0,0 +1,35 @@
/// Timing-related info about this control point.
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct TimingPoint {
pub time: f64,
pub beat_len: f64,
}
impl TimingPoint {
pub const DEFAULT_BEAT_LEN: f64 =
rosu_map::section::timing_points::TimingPoint::DEFAULT_BEAT_LEN;
pub fn new(time: f64, beat_len: f64) -> Self {
Self {
time,
beat_len: beat_len.clamp(6.0, 60_000.0),
}
}
}
impl Default for TimingPoint {
fn default() -> Self {
Self {
time: 0.0,
beat_len: Self::DEFAULT_BEAT_LEN,
}
}
}
pub fn timing_point_at(points: &[TimingPoint], time: f64) -> Option<&TimingPoint> {
let i = points
.binary_search_by(|probe| probe.time.total_cmp(&time))
.unwrap_or_else(|i| i.saturating_sub(1));
points.get(i)
}