Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add system labels #26

Merged
merged 9 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ pub struct Playing;
pub struct RunningState {
/// Tracks the current amount of time since the start of the system.
///
/// This is reset when the running time surpases the ``system_duration_seconds``.
/// This is reset when the running time surpasses the ``system_duration_seconds``.
pub running_time: f32,

/// The truncated current second.
Expand Down
19 changes: 13 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ mod systems;
pub mod values;

use bevy_app::prelude::{App, Plugin};
use bevy_ecs::prelude::{IntoSystemDescriptor, SystemSet};
pub use components::*;
pub use systems::ParticleSystemLabel;
use systems::{
particle_cleanup, particle_color, particle_lifetime, particle_spawner, particle_transform,
};
Expand Down Expand Up @@ -91,12 +93,17 @@ pub struct ParticleSystemPlugin;

impl Plugin for ParticleSystemPlugin {
fn build(&self, app: &mut App) {
app.add_system(particle_spawner)
.add_system(particle_lifetime)
.add_system(particle_color)
.add_system(particle_transform)
.add_system(particle_cleanup)
.register_type::<ParticleSystem>()
app.add_system(particle_spawner.label(ParticleSystemLabel::ParticleSpawn));
app.add_system_set(
SystemSet::new()
.label(ParticleSystemLabel::ParticleUpdate)
.after(ParticleSystemLabel::ParticleSpawn)
abnormalbrain marked this conversation as resolved.
Show resolved Hide resolved
.with_system(particle_lifetime)
.with_system(particle_color)
.with_system(particle_transform),
);
app.add_system(particle_cleanup.label(ParticleSystemLabel::ParticleCleanup));
app.register_type::<ParticleSystem>()
.register_type::<ParticleCount>()
.register_type::<RunningState>()
.register_type::<BurstIndex>();
Expand Down
12 changes: 12 additions & 0 deletions src/systems.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bevy_ecs::prelude::{Commands, Entity, Query, Res, With};
use bevy_ecs::schedule::SystemLabel;
use bevy_hierarchy::BuildChildren;
use bevy_math::Vec3;
use bevy_sprite::prelude::{Sprite, SpriteBundle};
Expand All @@ -16,6 +17,17 @@ use crate::{
DistanceTraveled, ParticleTexture,
};

/// Label enum for the systems relating to transform propagation
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemLabel)]
pub enum ParticleSystemLabel {
/// Spawn particles
ParticleSpawn,
/// Update particles
ParticleUpdate,
/// Cleanup particles
ParticleCleanup,
}

#[allow(
clippy::cast_sign_loss,
clippy::cast_precision_loss,
Expand Down