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 stub for FX events.

+143
+3
src/difficulty/lightshow/group.rs
··· 1 1 //! The advanced group lighting system events. 2 2 3 3 pub mod color; 4 + pub mod fx; 4 5 pub mod rotation; 5 6 pub mod translation; 6 7 7 8 #[doc(hidden)] 8 9 pub use color::*; 10 + #[doc(hidden)] 11 + pub use fx::*; 9 12 #[doc(hidden)] 10 13 pub use rotation::*; 11 14 #[doc(hidden)]
+140
src/difficulty/lightshow/group/fx.rs
··· 1 + //! Events that animations unique to each environment. 2 + 3 + use crate::difficulty::lightshow::DistributionType; 4 + use crate::difficulty::lightshow::easing::Easing; 5 + use crate::difficulty::lightshow::filter::Filter; 6 + use crate::utils::LooseBool; 7 + use crate::{TransitionType, impl_event_box, impl_event_data, impl_event_group, impl_timed}; 8 + use serde::{Deserialize, Serialize}; 9 + 10 + /// A collection of [`FxEventGroup`]s that share the same group ID and beat. 11 + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] 12 + #[cfg_attr( 13 + feature = "bevy_reflect", 14 + derive(bevy_reflect::Reflect), 15 + reflect(Debug, Clone, PartialEq) 16 + )] 17 + pub struct FxEventBox { 18 + /// The time the event takes place. 19 + #[serde(rename = "b")] 20 + pub beat: f32, 21 + /// The ID of the collection of objects that this event effects. 22 + #[serde(rename = "g")] 23 + pub group_id: i32, 24 + #[serde(rename = "e")] 25 + pub groups: Vec<FxEventGroup>, 26 + } 27 + 28 + impl Default for FxEventBox { 29 + fn default() -> Self { 30 + Self { 31 + beat: 0.0, 32 + group_id: 0, 33 + groups: vec![FxEventGroup::default()], 34 + } 35 + } 36 + } 37 + 38 + impl_timed!(FxEventBox::beat); 39 + impl_event_box!(FxEventBox, FxEventGroup, FxEventData); 40 + 41 + /// A collection of [`FxEventData`] that share the same [`Filter`] and distribution. 42 + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] 43 + #[cfg_attr( 44 + feature = "bevy_reflect", 45 + derive(bevy_reflect::Reflect), 46 + reflect(Debug, Clone, PartialEq) 47 + )] 48 + pub struct FxEventGroup { 49 + #[serde(rename = "f")] 50 + pub filter: Filter, 51 + #[serde(rename = "d")] 52 + pub beat_dist_type: DistributionType, 53 + /// The strength of the beat distribution. Dependent on the [distribution type](Self::beat_dist_type). 54 + /// 55 + /// A value of zero will have no effect. 56 + #[serde(rename = "w")] 57 + pub beat_dist_value: f32, 58 + /// The strength of the brightness distribution. Dependent on the [distribution type](Self::bright_dist_type). 59 + /// 60 + /// A value of zero will have no effect. 61 + #[serde(rename = "t")] 62 + pub fx_dist_type: DistributionType, 63 + #[serde(rename = "r")] 64 + pub fx_dist_value: f32, 65 + /// Whether the first [`FxEventData`] of the group will be effected by brightness distribution. 66 + #[serde(rename = "b")] 67 + pub fx_dist_effect_first: LooseBool, 68 + #[serde(rename = "i")] 69 + pub fx_dist_easing: Option<Easing>, 70 + #[serde(rename = "e")] 71 + pub data: Vec<FxEventData>, 72 + } 73 + 74 + impl Default for FxEventGroup { 75 + fn default() -> Self { 76 + Self { 77 + filter: Default::default(), 78 + beat_dist_type: Default::default(), 79 + beat_dist_value: 0.0, 80 + fx_dist_type: Default::default(), 81 + fx_dist_value: 0.0, 82 + fx_dist_effect_first: Default::default(), 83 + fx_dist_easing: Some(Easing::Linear), 84 + data: vec![FxEventData::default()], 85 + } 86 + } 87 + } 88 + 89 + impl_event_group!(FxEventGroup::get_fx_offset, FxEventData); 90 + 91 + impl FxEventGroup { 92 + /// Returns the FX value that the event will be offset for a given light ID. 93 + /// # Panics 94 + /// Will panic if the light ID is greater than or equal to the group size. 95 + #[deprecated(note = "Experimental. Does not consider random in filter calculations.")] 96 + #[allow(deprecated)] 97 + pub fn get_fx_offset(&self, light_id: i32, group_size: i32) -> f32 { 98 + self.fx_dist_type.compute_value_offset( 99 + light_id, 100 + group_size, 101 + &self.filter, 102 + self.fx_dist_value, 103 + self.data.last().map(|data| data.beat_offset), 104 + self.fx_dist_easing, 105 + ) 106 + } 107 + } 108 + 109 + /// The lowest-level group event type, which determines the color of the event. 110 + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] 111 + #[cfg_attr( 112 + feature = "bevy_reflect", 113 + derive(bevy_reflect::Reflect), 114 + reflect(Debug, Clone, PartialEq) 115 + )] 116 + pub struct FxEventData { 117 + /// The number of beats the event will be offset from the [`FxEventBox`]'s beat. 118 + #[serde(rename = "b")] 119 + pub beat_offset: f32, 120 + #[serde(rename = "p")] 121 + pub transition_type: TransitionType, 122 + #[serde(rename = "i")] 123 + pub easing: Easing, 124 + /// The base value of the effect. 125 + #[serde(rename = "v")] 126 + pub value: f32, 127 + } 128 + 129 + impl Default for FxEventData { 130 + fn default() -> Self { 131 + Self { 132 + beat_offset: 0.0, 133 + transition_type: Default::default(), 134 + easing: Easing::default(), 135 + value: 1.0, 136 + } 137 + } 138 + } 139 + 140 + impl_event_data!(FxEventData);