use nightshade::prelude::*;
pub fn emit_fire(world: &mut World, position: Vec3) -> Entity {
spawn_emitter(world, ParticleEmitter::fire(position))
}
pub fn emit_smoke(world: &mut World, position: Vec3) -> Entity {
spawn_emitter(world, ParticleEmitter::smoke(position))
}
pub fn emit_burst(world: &mut World, position: Vec3, color: [f32; 4], count: u32) -> Entity {
spawn_emitter(
world,
ParticleEmitter::firework_explosion(
position,
Vec3::new(color[0], color[1], color[2]),
count,
),
)
}
fn spawn_emitter(world: &mut World, emitter: ParticleEmitter) -> Entity {
let entity = spawn_entities(
world,
PARTICLE_EMITTER | LOCAL_TRANSFORM | LOCAL_TRANSFORM_DIRTY | GLOBAL_TRANSFORM | NAME,
1,
)[0];
world.core.set_name(entity, Name("api::effect".to_string()));
assign_local_transform(
world,
entity,
LocalTransform {
translation: emitter.position,
..Default::default()
},
);
world.core.set_particle_emitter(entity, emitter);
entity
}