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.

Some documentation for `fx` module.

+28 -15
+28 -15
src/difficulty/lightshow/group/fx.rs
··· 1 1 //! Events that animations unique to each environment. 2 + //! 3 + //! Unlike the other V3 group event types, FX events use a template-like JSON syntax. 4 + //! In order to have standardized structure across all V3 events, custom serialization has been written in [`FxEventContainer`]. 5 + //! Because of this, neither [`FxEventBox`] nor [`FxEventGroup`] implement [`Serialize`] nor [`Deserialize`]. 2 6 3 7 use crate::difficulty::lightshow::DistributionType; 4 8 use crate::difficulty::lightshow::easing::Easing; ··· 8 12 use serde::ser::SerializeStruct; 9 13 use serde::{Deserialize, Deserializer, Serialize, Serializer}; 10 14 15 + /// Contains a list of [`FxEventBox`] as well as the [`Serialize`] and [`Deserialize`] implementations for FX events. 11 16 #[derive(Debug, Clone, PartialEq, Default)] 12 17 #[cfg_attr( 13 18 feature = "bevy_reflect", ··· 140 145 } 141 146 142 147 /// A collection of [`FxEventGroup`]s that share the same group ID and beat. 148 + /// 149 + /// Does not implement [`Serialize`] nor [`Deserialize`]. For more info, see the [module docs](super::fx). 143 150 #[derive(Debug, Clone, PartialEq)] 144 151 #[cfg_attr( 145 152 feature = "bevy_reflect", ··· 154 161 pub groups: Vec<FxEventGroup>, 155 162 } 156 163 164 + /// The raw JSON structure that uses [data IDs](self::data_ids) rather than actual [event data](FxEventData). 157 165 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] 158 - pub struct FxEventBoxRaw { 166 + struct FxEventBoxRaw { 159 167 #[serde(rename = "b")] 160 - pub beat: f32, 168 + beat: f32, 161 169 #[serde(rename = "g")] 162 - pub group_id: i32, 170 + group_id: i32, 163 171 #[serde(rename = "e")] 164 - pub groups: Vec<FxEventGroupRaw>, 172 + groups: Vec<FxEventGroupRaw>, 165 173 } 166 174 167 175 impl Default for FxEventBox { ··· 178 186 impl_event_box!(FxEventBox, FxEventGroup, FxEventData); 179 187 180 188 /// A collection of [`FxEventData`] that share the same [`Filter`] and distribution. 189 + /// 190 + /// Does not implement [`Serialize`] nor [`Deserialize`]. For more info, see the [module docs](super::fx). 181 191 #[derive(Debug, Clone, PartialEq)] 182 192 #[cfg_attr( 183 193 feature = "bevy_reflect", ··· 199 209 /// Whether the first [`FxEventData`] of the group will be effected by brightness distribution. 200 210 pub fx_dist_effect_first: LooseBool, 201 211 pub fx_dist_easing: Option<Easing>, 212 + /// In the actual JSON structure, this is a list of indexes to a separate list of event data. 213 + /// For consistency, this is merged during parsing. 202 214 pub data: Vec<FxEventData>, 203 215 } 204 216 217 + /// The raw JSON structure that uses [data IDs](self::data_ids) rather than actual [event data](FxEventData). 205 218 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] 206 - pub struct FxEventGroupRaw { 219 + struct FxEventGroupRaw { 207 220 #[serde(rename = "f")] 208 - pub filter: Filter, 221 + filter: Filter, 209 222 #[serde(rename = "d")] 210 - pub beat_dist_type: DistributionType, 223 + beat_dist_type: DistributionType, 211 224 #[serde(rename = "w")] 212 - pub beat_dist_value: f32, 225 + beat_dist_value: f32, 213 226 #[serde(rename = "t")] 214 - pub fx_dist_type: DistributionType, 227 + fx_dist_type: DistributionType, 215 228 #[serde(rename = "s")] 216 - pub fx_dist_value: f32, 229 + fx_dist_value: f32, 217 230 #[serde(rename = "b")] 218 - pub fx_dist_effect_first: LooseBool, 231 + fx_dist_effect_first: LooseBool, 219 232 #[serde(rename = "i")] 220 - pub fx_dist_easing: Option<Easing>, 233 + fx_dist_easing: Option<Easing>, 221 234 #[serde(rename = "l")] 222 - pub data_ids: Vec<usize>, 235 + data_ids: Vec<usize>, 223 236 } 224 237 225 238 impl Default for FxEventGroup { ··· 257 270 } 258 271 } 259 272 260 - /// The lowest-level group event type, which determines the color of the event. 273 + /// The lowest-level group event type, which determines the base value of the event. 261 274 #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] 262 275 #[cfg_attr( 263 276 feature = "bevy_reflect", ··· 446 459 447 460 assert_eq!(container, roundtrip, "Round-trip did not match"); 448 461 449 - println!("Round-trip serialization succeeded:\n{}", out_json); 462 + println!("Round-trip serialization succeeded."); 450 463 } 451 464 }