~starkingdoms/starkingdoms

ref: f2ba6ebbc002fe708f7d69d4ca2e008b3437cbda starkingdoms/crates/unified/src/particle_editor/mod.rs -rw-r--r-- 1.6 KiB
f2ba6ebb — core fix: make it compile :p 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use bevy::prelude::*;
use bevy_egui::{EguiPlugin, EguiPrimaryContextPass};
use crate::particles::{LifetimeCurve, ParticleEffect, RandF32, RandUsize, RandVec2};

pub fn particle_editor_plugin(app: &mut App) {
    app.add_plugins(DefaultPlugins);
    app.add_plugins(EguiPlugin::default());
    app.add_systems(EguiPrimaryContextPass, editor_ui);
    app.add_systems(Startup, setup_editor_effect);
}

fn setup_editor_effect(mut commands: Commands) {
    commands.spawn((
        ParticleEffect {
            lifetime_seconds: RandF32 {
                value: 2.0,
                randomness: 0.1,
            },
            batch_spawn_delay_seconds: RandF32 { value: 0.1, randomness: 0.05 },
            particles_in_batch: RandUsize {
                value: 1,
                randomness: 1
            },
            initial_linear_velocity: RandVec2 {
                x: RandF32 { value: 0.0, randomness: 0.5 },
                y: RandF32 { value: 10.0, randomness: 1.0 }
            },
            initial_angular_velocity: RandF32 { value: 1.0, randomness: 0.5 },
            scale: LifetimeCurve::new(&[
                (0.0f32, 5.0),
                (2.0, 0.0)
            ]),
            color: LifetimeCurve::new(&[
                (0.0f32, Srgba::new(1.0, 0.0, 0.0, 1.0).into()),
                (0.5, Srgba::new(0.0, 1.0, 0.0, 1.0).into()),
                (1.0, Srgba::new(0.0, 0.0, 1.0, 1.0).into()),
                (1.5, Srgba::new(1.0, 0.0, 1.0, 1.0).into()),
                (2.0, Srgba::new(1.0, 1.0, 1.0, 1.0).into())
            ]),
        }
    ));
}

fn editor_ui() {}