~starkingdoms/starkingdoms

ref: 6516d7c756f9f5aaeaaae2e871a7e53c65174cc3 starkingdoms/crates/unified/src/particle_editor/hooks.rs -rw-r--r-- 588 bytes
6516d7c7ghostly_zsh fix: orbit indicator is continuous 17 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use crate::prelude::*;

use crate::{particle_editor::ecs::SpawnDelayTimer, particles::ParticleEffect};

pub fn hooks_plugin(app: &mut App) {
    app.add_systems(Update, init_particle_effect);
}

fn init_particle_effect(
    mut commands: Commands,
    particle_effect: Query<(Entity, &ParticleEffect), Added<ParticleEffect>>,
) {
    for (entity, effect) in particle_effect {
        commands
            .get_entity(entity)
            .unwrap()
            .insert(SpawnDelayTimer::new(
                effect.batch_spawn_delay_seconds.sample(&mut rand::rng()),
            ));
    }
}