Skip to content

Commit

Permalink
feat: support MR for catch
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxOhn committed Nov 13, 2024
1 parent baeaeb7 commit f37b917
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
9 changes: 9 additions & 0 deletions src/catch/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
beatmap::{Beatmap, Converted},
hit_object::{HitObject, HitObjectKind, HoldNote, Spinner},
mode::ConvertStatus,
mods::Reflection,
},
util::{float_ext::FloatExt, random::Random},
};
Expand Down Expand Up @@ -50,6 +51,7 @@ pub fn try_convert(map: &mut Beatmap) -> ConvertStatus {
pub fn convert_objects(
converted: &CatchBeatmap<'_>,
count: &mut ObjectCountBuilder,
reflection: Reflection,
hr_offsets: bool,
cs: f32,
) -> Vec<PalpableObject> {
Expand Down Expand Up @@ -82,6 +84,13 @@ pub fn convert_objects(
palpable_objects.extend(new_objects);
}

if let Reflection::Horizontal = reflection {
for h in palpable_objects.iter_mut() {
h.x = PLAYFIELD_WIDTH - h.x;
h.x_offset = -h.x_offset;
}
}

palpable_objects.sort_by(|a, b| a.start_time.total_cmp(&b.start_time));
initialize_hyper_dash(cs, &mut palpable_objects);

Expand Down
11 changes: 9 additions & 2 deletions src/catch/difficulty/gradual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,16 @@ impl CatchGradualDifficulty {
CatchDifficultySetup::new(&difficulty, converted);

let hr_offsets = difficulty.get_hardrock_offsets();
let reflection = difficulty.get_mods().reflection();
let mut count = ObjectCountBuilder::new_gradual();
let palpable_objects =
convert_objects(converted, &mut count, hr_offsets, map_attrs.cs as f32);

let palpable_objects = convert_objects(
converted,
&mut count,
reflection,
hr_offsets,
map_attrs.cs as f32,
);

let diff_objects = DifficultyValues::create_difficulty_objects(
&map_attrs,
Expand Down
10 changes: 8 additions & 2 deletions src/catch/difficulty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,16 @@ impl DifficultyValues {
} = CatchDifficultySetup::new(difficulty, converted);

let hr_offsets = difficulty.get_hardrock_offsets();
let reflection = difficulty.get_mods().reflection();
let mut count = ObjectCountBuilder::new_regular(take);

let palpable_objects =
convert_objects(converted, &mut count, hr_offsets, map_attrs.cs as f32);
let palpable_objects = convert_objects(
converted,
&mut count,
reflection,
hr_offsets,
map_attrs.cs as f32,
);

let diff_objects = Self::create_difficulty_objects(
&map_attrs,
Expand Down
15 changes: 8 additions & 7 deletions src/model/mods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,16 @@ impl GameMods {

mods.iter()
.find_map(|m| match m {
GameMod::MirrorOsu(mirror) => Some(mirror),
GameMod::MirrorOsu(mr) => match mr.reflection.as_deref() {
None => Some(Reflection::Horizontal),
Some("1") => Some(Reflection::Vertical),
Some("2") => Some(Reflection::Both),
Some(_) => Some(Reflection::None),
},
GameMod::MirrorCatch(_) => Some(Reflection::Horizontal),
_ => None,
})
.map_or(Reflection::None, |mr| match mr.reflection.as_deref() {
None => Reflection::Horizontal,
Some("1") => Reflection::Vertical,
Some("2") => Reflection::Both,
Some(_) => Reflection::None,
})
.unwrap_or(Reflection::None)
}
GameModsInner::Intermode(ref mods) => {
if mods.contains(GameModIntermode::HardRock) {
Expand Down

0 comments on commit f37b917

Please sign in to comment.