Beatsaber Rust Utilities: A Beatsaber V3 parsing library.
beatsaber beatmap
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added event traits.

AlephCubed c50e8e59 62d9ad65

+103 -30
+3 -3
src/difficulty.rs
··· 4 4 5 5 use crate::difficulty::gameplay_event::{BpmEvent, LaneRotationEvent}; 6 6 use crate::difficulty::lightshow::basic::{BasicEvent, ColorBoostEvent, SpecialEvent, Waypoint}; 7 - use crate::difficulty::lightshow::color::ColorEventBox; 8 - use crate::difficulty::lightshow::rotation::RotationEventBox; 9 - use crate::difficulty::lightshow::translation::TranslationEventBox; 10 7 use crate::difficulty::playfield::{Arc, Bomb, Chain, Note, Wall}; 8 + use lightshow::boxes::color::ColorEventBox; 9 + use lightshow::boxes::rotation::RotationEventBox; 10 + use lightshow::boxes::translation::TranslationEventBox; 11 11 use serde::{Deserialize, Serialize}; 12 12 13 13 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
+1 -21
src/difficulty/lightshow.rs
··· 1 1 pub mod basic; 2 - pub mod color; 2 + pub mod boxes; 3 3 pub mod easing; 4 4 pub mod filter; 5 - pub mod rotation; 6 - pub mod translation; 7 5 8 6 use crate::difficulty::lightshow::easing::Easing; 9 7 use crate::difficulty::lightshow::filter::Filter; ··· 62 60 DistributionType::Unknown(_) => 0.0, 63 61 } 64 62 } 65 - } 66 - 67 - #[macro_export] 68 - macro_rules! impl_get_beat_offset { 69 - ($ident:ident) => { 70 - impl $ident { 71 - pub fn get_beat_offset(&self, light_id: i32, group_size: i32) -> f32 { 72 - self.beat_dist_type.compute_offset( 73 - light_id, 74 - group_size, 75 - &self.filter, 76 - self.beat_dist_value, 77 - self.data.last().map(|data| data.beat_offset), 78 - None, 79 - ) 80 - } 81 - } 82 - }; 83 63 } 84 64 85 65 loose_enum! {
+68
src/difficulty/lightshow/boxes.rs
··· 1 + pub mod color; 2 + pub mod rotation; 3 + pub mod translation; 4 + 5 + use crate::difficulty::lightshow::filter::Filter; 6 + use crate::timing_traits::Timed; 7 + 8 + pub trait EventBox: Timed { 9 + type Group: EventGroup<Data = Self::Data>; 10 + type Data: EventData; 11 + 12 + fn get_groups(&self) -> &Vec<Self::Group>; 13 + } 14 + 15 + #[macro_export] 16 + macro_rules! impl_event_box { 17 + ($ident:ident::$group:ident::$data:ident) => { 18 + impl crate::difficulty::lightshow::boxes::EventBox for $ident { 19 + type Group = $group; 20 + type Data = $data; 21 + 22 + fn get_groups(&self) -> &Vec<Self::Group> { 23 + &self.groups 24 + } 25 + } 26 + }; 27 + } 28 + 29 + pub trait EventGroup { 30 + type Data: EventData; 31 + 32 + fn get_filter(&self) -> &Filter; 33 + fn get_data(&self) -> &Vec<Self::Data>; 34 + 35 + fn get_beat_offset(&self, light_id: i32, group_size: i32) -> f32; 36 + } 37 + 38 + #[macro_export] 39 + macro_rules! impl_event_group { 40 + ($ident:ident::$data:ident) => { 41 + impl crate::difficulty::lightshow::boxes::EventGroup for $ident { 42 + type Data = $data; 43 + 44 + fn get_filter(&self) -> &Filter { 45 + &self.filter 46 + } 47 + 48 + fn get_data(&self) -> &Vec<Self::Data> { 49 + &self.data 50 + } 51 + 52 + fn get_beat_offset(&self, light_id: i32, group_size: i32) -> f32 { 53 + self.beat_dist_type.compute_offset( 54 + light_id, 55 + group_size, 56 + &self.filter, 57 + self.beat_dist_value, 58 + self.data.last().map(|data| data.beat_offset), 59 + None, 60 + ) 61 + } 62 + } 63 + }; 64 + } 65 + 66 + pub trait EventData { 67 + fn get_beat_offset(&self) -> f32; 68 + }
+11 -2
src/difficulty/lightshow/color.rs src/difficulty/lightshow/boxes/color.rs
··· 1 1 use crate::difficulty::lightshow::DistributionType; 2 + use crate::difficulty::lightshow::boxes::EventData; 2 3 use crate::difficulty::lightshow::easing::Easing; 3 4 use crate::difficulty::lightshow::filter::Filter; 4 5 use crate::utils::LooseBool; 5 - use crate::{impl_get_beat_offset, impl_timed, loose_enum}; 6 + use crate::{impl_event_box, impl_event_group, impl_timed, loose_enum}; 6 7 use serde::{Deserialize, Serialize}; 7 8 8 9 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] ··· 21 22 } 22 23 23 24 impl_timed!(ColorEventBox::beat); 25 + impl_event_box!(ColorEventBox::ColorEventGroup::ColorEventData); 24 26 25 27 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 26 28 #[cfg_attr( ··· 48 50 pub data: Vec<ColorEventData>, 49 51 } 50 52 51 - impl_get_beat_offset!(ColorEventGroup); 53 + impl_event_group!(ColorEventGroup::ColorEventData); 52 54 53 55 impl ColorEventGroup { 54 56 pub fn get_brightness_offset(&self, light_id: i32, group_size: i32) -> f32 { ··· 82 84 pub strobe_frequency: i32, 83 85 } 84 86 87 + impl EventData for ColorEventData { 88 + fn get_beat_offset(&self) -> f32 { 89 + self.beat_offset 90 + } 91 + } 92 + 85 93 loose_enum! { 86 94 #[derive(Default, Copy)] 87 95 ColorTransitionType: i32 { ··· 106 114 #[cfg(test)] 107 115 mod tests { 108 116 use super::*; 117 + use crate::difficulty::lightshow::boxes::EventGroup; 109 118 use crate::difficulty::lightshow::filter::FilterType; 110 119 111 120 #[test]
+10 -2
src/difficulty/lightshow/rotation.rs src/difficulty/lightshow/boxes/rotation.rs
··· 1 + use crate::difficulty::lightshow::boxes::EventData; 1 2 use crate::difficulty::lightshow::easing::Easing; 2 3 use crate::difficulty::lightshow::filter::Filter; 3 4 use crate::difficulty::lightshow::{DistributionType, EventAxis, TransitionType}; 4 5 use crate::utils::LooseBool; 5 - use crate::{impl_get_beat_offset, impl_timed, loose_enum}; 6 + use crate::{impl_event_box, impl_event_group, impl_timed, loose_enum}; 6 7 use serde::{Deserialize, Serialize}; 7 8 8 9 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] ··· 21 22 } 22 23 23 24 impl_timed!(RotationEventBox::beat); 25 + impl_event_box!(RotationEventBox::RotationEventGroup::RotationEventData); 24 26 25 27 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 26 28 #[cfg_attr( ··· 52 54 pub data: Vec<RotationEventData>, 53 55 } 54 56 55 - impl_get_beat_offset!(RotationEventGroup); 57 + impl_event_group!(RotationEventGroup::RotationEventData); 56 58 57 59 impl RotationEventGroup { 58 60 pub fn get_rotation_offset(&self, light_id: i32, group_size: i32) -> f32 { ··· 86 88 pub direction: RotationDirection, 87 89 #[serde(rename = "l")] 88 90 pub loops: i32, 91 + } 92 + 93 + impl EventData for RotationEventData { 94 + fn get_beat_offset(&self) -> f32 { 95 + self.beat_offset 96 + } 89 97 } 90 98 91 99 loose_enum! {
+10 -2
src/difficulty/lightshow/translation.rs src/difficulty/lightshow/boxes/translation.rs
··· 1 + use crate::difficulty::lightshow::boxes::EventData; 1 2 use crate::difficulty::lightshow::easing::Easing; 2 3 use crate::difficulty::lightshow::filter::Filter; 3 4 use crate::difficulty::lightshow::{DistributionType, EventAxis, TransitionType}; 4 5 use crate::utils::LooseBool; 5 - use crate::{impl_get_beat_offset, impl_timed}; 6 + use crate::{impl_event_box, impl_event_group, impl_timed}; 6 7 use serde::{Deserialize, Serialize}; 7 8 8 9 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] ··· 21 22 } 22 23 23 24 impl_timed!(TranslationEventBox::beat); 25 + impl_event_box!(TranslationEventBox::TranslationEventGroup::TranslationEventData); 24 26 25 27 #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] 26 28 #[cfg_attr( ··· 51 53 pub data: Vec<TranslationEventData>, 52 54 } 53 55 54 - impl_get_beat_offset!(TranslationEventGroup); 56 + impl_event_group!(TranslationEventGroup::TranslationEventData); 55 57 56 58 impl TranslationEventGroup { 57 59 pub fn get_translation_offset(&self, light_id: i32, group_size: i32) -> f32 { ··· 82 84 #[serde(rename = "t")] 83 85 pub value: f32, 84 86 } 87 + 88 + impl EventData for TranslationEventData { 89 + fn get_beat_offset(&self) -> f32 { 90 + self.beat_offset 91 + } 92 + }