pretty_text_effects/
lib.rs1#![allow(clippy::type_complexity)]
13#![warn(missing_debug_implementations, missing_docs, clippy::doc_markdown)]
14
15use bevy::prelude::*;
16use bevy_pretty_text::glyph::{Glyph, GlyphSpanEntity};
17
18mod glitch;
19mod scramble;
20mod shake;
21mod wave;
22mod wobble;
23
24pub use glitch::Glitch;
25pub use scramble::{Scramble, ScrambleLifetime, ScrambleSpeed};
26pub use shake::Shake;
27pub use wave::Wave;
28pub use wobble::Wobble;
29
30extern crate pretty_text as bevy_pretty_text;
31
32#[derive(Debug)]
36pub struct EffectsPlugin;
37
38impl Plugin for EffectsPlugin {
39 fn build(&self, app: &mut App) {
40 glitch::plugin(app);
41 scramble::plugin(app);
42 shake::plugin(app);
43 wave::plugin(app);
44 wobble::plugin(app);
45 }
46}
47
48pub fn apply_effect_on_glyphs<Effect: Component, Marker: Default + Component>(
52 trigger: Trigger<OnAdd, Glyph>,
53 mut commands: Commands,
54 spans: Query<&GlyphSpanEntity>,
55 effects: Query<&Effect>,
56) -> Result {
57 let span_entity = spans.get(trigger.target())?;
58 if effects.get(span_entity.0).is_ok() {
59 commands.entity(trigger.target()).insert(Marker::default());
60 }
61 Ok(())
62}