Beatsaber Rust Utilities: A Beatsaber V3 parsing library.
beatsaber
beatmap
1//! The non-group events that were inherited from difficulty file V2.
2
3use crate::difficulty::playfield::CutDirection;
4use crate::impl_timed;
5use serde::{Deserialize, Serialize};
6
7/// The basic V2 event type, which is still used for some elements of V3 environments (for example, the player platform).
8#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
9#[cfg_attr(
10 feature = "bevy_reflect",
11 derive(bevy_reflect::Reflect),
12 reflect(Debug, Clone, PartialEq)
13)]
14pub struct BasicEvent {
15 /// The time the event takes place.
16 #[serde(rename = "b")]
17 pub beat: f32,
18 /// Determines the behaviour of the event. The exact behaviour differs depending on the environment.
19 ///
20 /// More info [here](https://bsmg.wiki/mapping/map-format/lightshow.html#basic-events-type).
21 #[serde(rename = "et")]
22 pub event_type: i32,
23 /// Determines which effect the event will produce, based on its [type](Self::event_type).
24 #[serde(rename = "i")]
25 pub value: i32,
26 /// Modifies the effect.
27 #[serde(rename = "f")]
28 pub float: f32,
29}
30
31impl_timed!(BasicEvent::beat);
32
33/// Controls the TinyTAN figures on the [BTS environment](crate::info::Environment::BTS).
34///
35/// More info [here](https://bsmg.wiki/mapping/map-format/lightshow.html#waypoints).
36#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
37#[cfg_attr(
38 feature = "bevy_reflect",
39 derive(bevy_reflect::Reflect),
40 reflect(Debug, Clone, PartialEq)
41)]
42pub struct Waypoint {
43 /// The time the event takes place.
44 #[serde(rename = "b")]
45 pub beat: f32,
46 /// A value representing the vertical position of the event.
47 /// In the range 0..2 inclusive, with zero being the bottom and two being the top row.
48 #[serde(rename = "y")]
49 pub row: u8,
50 /// A value representing the horizontal position of the event.
51 /// In the range 0..3 inclusive, with zero being the far left and three being the far right column.
52 #[serde(rename = "x")]
53 pub col: u8,
54 #[serde(rename = "d")]
55 pub direction: CutDirection,
56}
57
58impl_timed!(Waypoint::beat);
59
60/// Controls which lighting colors are used, based on a map or environment's [color scheme](crate::info::color_scheme::ColorScheme).
61#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
62#[cfg_attr(
63 feature = "bevy_reflect",
64 derive(bevy_reflect::Reflect),
65 reflect(Debug, Clone, PartialEq)
66)]
67pub struct ColorBoostEvent {
68 /// The time the event takes place.
69 #[serde(rename = "b")]
70 pub beat: f32,
71 /// Whether to enable or disable boost colors.
72 #[serde(rename = "o")]
73 pub boost: bool,
74}
75
76impl_timed!(ColorBoostEvent::beat);
77
78/// An event containing an array of Special Event Keywords.
79///
80/// More info [here](https://bsmg.wiki/mapping/map-format/lightshow.html#special-event-keywords).
81#[doc(alias = "KeywordEvent")]
82#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
83#[cfg_attr(
84 feature = "bevy_reflect",
85 derive(bevy_reflect::Reflect),
86 reflect(Debug, Clone, PartialEq)
87)]
88pub struct SpecialEvent {
89 #[serde(rename = "d")]
90 pub keywords: Option<Vec<Keyword>>,
91}
92
93/// Allows basic event lanes to be overridden with environment-specific behaviour, using secret keys.
94///
95/// More info [here](https://bsmg.wiki/mapping/map-format/lightshow.html#special-event-keywords).
96#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
97#[cfg_attr(
98 feature = "bevy_reflect",
99 derive(bevy_reflect::Reflect),
100 reflect(Debug, Clone, PartialEq)
101)]
102pub struct Keyword {
103 /// The secret key of the effect.
104 #[serde(rename = "k")]
105 pub keyword: String,
106 /// A list of [event types](BasicEvent::event_type) to effect with the keyword.
107 #[serde(rename = "e")]
108 pub event_types: Vec<i32>,
109}