···11//! The advanced group lighting system events.
2233pub mod color;
44+pub mod fx;
45pub mod rotation;
56pub mod translation;
6778#[doc(hidden)]
89pub use color::*;
1010+#[doc(hidden)]
1111+pub use fx::*;
912#[doc(hidden)]
1013pub use rotation::*;
1114#[doc(hidden)]
+140
src/difficulty/lightshow/group/fx.rs
···11+//! Events that animations unique to each environment.
22+33+use crate::difficulty::lightshow::DistributionType;
44+use crate::difficulty::lightshow::easing::Easing;
55+use crate::difficulty::lightshow::filter::Filter;
66+use crate::utils::LooseBool;
77+use crate::{TransitionType, impl_event_box, impl_event_data, impl_event_group, impl_timed};
88+use serde::{Deserialize, Serialize};
99+1010+/// A collection of [`FxEventGroup`]s that share the same group ID and beat.
1111+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1212+#[cfg_attr(
1313+ feature = "bevy_reflect",
1414+ derive(bevy_reflect::Reflect),
1515+ reflect(Debug, Clone, PartialEq)
1616+)]
1717+pub struct FxEventBox {
1818+ /// The time the event takes place.
1919+ #[serde(rename = "b")]
2020+ pub beat: f32,
2121+ /// The ID of the collection of objects that this event effects.
2222+ #[serde(rename = "g")]
2323+ pub group_id: i32,
2424+ #[serde(rename = "e")]
2525+ pub groups: Vec<FxEventGroup>,
2626+}
2727+2828+impl Default for FxEventBox {
2929+ fn default() -> Self {
3030+ Self {
3131+ beat: 0.0,
3232+ group_id: 0,
3333+ groups: vec![FxEventGroup::default()],
3434+ }
3535+ }
3636+}
3737+3838+impl_timed!(FxEventBox::beat);
3939+impl_event_box!(FxEventBox, FxEventGroup, FxEventData);
4040+4141+/// A collection of [`FxEventData`] that share the same [`Filter`] and distribution.
4242+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4343+#[cfg_attr(
4444+ feature = "bevy_reflect",
4545+ derive(bevy_reflect::Reflect),
4646+ reflect(Debug, Clone, PartialEq)
4747+)]
4848+pub struct FxEventGroup {
4949+ #[serde(rename = "f")]
5050+ pub filter: Filter,
5151+ #[serde(rename = "d")]
5252+ pub beat_dist_type: DistributionType,
5353+ /// The strength of the beat distribution. Dependent on the [distribution type](Self::beat_dist_type).
5454+ ///
5555+ /// A value of zero will have no effect.
5656+ #[serde(rename = "w")]
5757+ pub beat_dist_value: f32,
5858+ /// The strength of the brightness distribution. Dependent on the [distribution type](Self::bright_dist_type).
5959+ ///
6060+ /// A value of zero will have no effect.
6161+ #[serde(rename = "t")]
6262+ pub fx_dist_type: DistributionType,
6363+ #[serde(rename = "r")]
6464+ pub fx_dist_value: f32,
6565+ /// Whether the first [`FxEventData`] of the group will be effected by brightness distribution.
6666+ #[serde(rename = "b")]
6767+ pub fx_dist_effect_first: LooseBool,
6868+ #[serde(rename = "i")]
6969+ pub fx_dist_easing: Option<Easing>,
7070+ #[serde(rename = "e")]
7171+ pub data: Vec<FxEventData>,
7272+}
7373+7474+impl Default for FxEventGroup {
7575+ fn default() -> Self {
7676+ Self {
7777+ filter: Default::default(),
7878+ beat_dist_type: Default::default(),
7979+ beat_dist_value: 0.0,
8080+ fx_dist_type: Default::default(),
8181+ fx_dist_value: 0.0,
8282+ fx_dist_effect_first: Default::default(),
8383+ fx_dist_easing: Some(Easing::Linear),
8484+ data: vec![FxEventData::default()],
8585+ }
8686+ }
8787+}
8888+8989+impl_event_group!(FxEventGroup::get_fx_offset, FxEventData);
9090+9191+impl FxEventGroup {
9292+ /// Returns the FX value that the event will be offset for a given light ID.
9393+ /// # Panics
9494+ /// Will panic if the light ID is greater than or equal to the group size.
9595+ #[deprecated(note = "Experimental. Does not consider random in filter calculations.")]
9696+ #[allow(deprecated)]
9797+ pub fn get_fx_offset(&self, light_id: i32, group_size: i32) -> f32 {
9898+ self.fx_dist_type.compute_value_offset(
9999+ light_id,
100100+ group_size,
101101+ &self.filter,
102102+ self.fx_dist_value,
103103+ self.data.last().map(|data| data.beat_offset),
104104+ self.fx_dist_easing,
105105+ )
106106+ }
107107+}
108108+109109+/// The lowest-level group event type, which determines the color of the event.
110110+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
111111+#[cfg_attr(
112112+ feature = "bevy_reflect",
113113+ derive(bevy_reflect::Reflect),
114114+ reflect(Debug, Clone, PartialEq)
115115+)]
116116+pub struct FxEventData {
117117+ /// The number of beats the event will be offset from the [`FxEventBox`]'s beat.
118118+ #[serde(rename = "b")]
119119+ pub beat_offset: f32,
120120+ #[serde(rename = "p")]
121121+ pub transition_type: TransitionType,
122122+ #[serde(rename = "i")]
123123+ pub easing: Easing,
124124+ /// The base value of the effect.
125125+ #[serde(rename = "v")]
126126+ pub value: f32,
127127+}
128128+129129+impl Default for FxEventData {
130130+ fn default() -> Self {
131131+ Self {
132132+ beat_offset: 0.0,
133133+ transition_type: Default::default(),
134134+ easing: Easing::default(),
135135+ value: 1.0,
136136+ }
137137+ }
138138+}
139139+140140+impl_event_data!(FxEventData);