Skip to content

Updated to Bevy 0.14 #72

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

Merged
merged 11 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.76.0
RUST_VERSION: 1.79.0

jobs:
test:
Expand Down
23 changes: 12 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ categories = ["game-development"]
debug = true

[dependencies]
bevy_app = "0.13"
bevy_asset = "0.13"
bevy_ecs = "0.13"
bevy_hierarchy = "0.13"
bevy_math = "0.13"
bevy_render = "0.13"
bevy_sprite = "0.13"
bevy_time = "0.13"
bevy_transform = "0.13"
bevy_reflect = "0.13"
bevy_app = "0.14"
bevy_asset = "0.14"
bevy_ecs = "0.14"
bevy_hierarchy = "0.14"
bevy_math = "0.14"
bevy_render = "0.14"
bevy_color = "0.14"
bevy_sprite = "0.14"
bevy_time = "0.14"
bevy_transform = "0.14"
bevy_reflect = "0.14"
rand = "0.8"

[dev-dependencies]
bevy = { version = "0.13", default-features=false, features = [
bevy = { version = "0.14", default-features=false, features = [
"bevy_asset",
"bevy_sprite",
"bevy_core_pipeline",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn spawn_particle_system(mut commands: Commands, asset_server: Res<AssetServer>)
lifetime: JitteredValue::jittered(8.0, -2.0..2.0),
color: ColorOverTime::Gradient(Gradient::new(vec![
ColorPoint::new(Color::WHITE, 0.0),
ColorPoint::new(Color::rgba(0.0, 0.0, 1.0, 0.0), 1.0),
ColorPoint::new(Color::srgba(0.0, 0.0, 1.0, 0.0), 1.0),
])),
looping: true,
system_duration_seconds: 10.0,
Expand Down
7 changes: 4 additions & 3 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use bevy::{
window::{PresentMode, WindowPlugin},
DefaultPlugins,
};
use bevy_color::palettes::basic::*;
use bevy_particle_systems::{
ColorOverTime, Curve, CurvePoint, JitteredValue, ParticleBurst, ParticleSystem,
ParticleSystemBundle, ParticleSystemPlugin, Playing, VelocityModifier::*,
Expand Down Expand Up @@ -42,9 +43,9 @@ fn startup_system(mut commands: Commands, asset_server: Res<AssetServer>) {
velocity_modifiers: vec![Drag(0.01.into())],
lifetime: JitteredValue::jittered(8.0, -2.0..2.0),
color: ColorOverTime::Gradient(Curve::new(vec![
CurvePoint::new(Color::PURPLE, 0.0),
CurvePoint::new(Color::RED, 0.5),
CurvePoint::new(Color::rgba(0.0, 0.0, 1.0, 0.0), 1.0),
CurvePoint::new(PURPLE.into(), 0.0),
CurvePoint::new(RED.into(), 0.5),
CurvePoint::new(Color::srgba(0.0, 0.0, 1.0, 0.0), 1.0),
])),
looping: true,
system_duration_seconds: 10.0,
Expand Down
9 changes: 5 additions & 4 deletions examples/local_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use bevy::{
};
use bevy_app::{Startup, Update};
use bevy_asset::AssetServer;
use bevy_color::palettes::basic::*;
use bevy_math::Quat;
use bevy_time::Time;

Expand Down Expand Up @@ -49,8 +50,8 @@ fn startup_system(mut commands: Commands, asset_server: Res<AssetServer>) {
initial_speed: JitteredValue::jittered(25.0, 0.0..5.0),
lifetime: JitteredValue::jittered(3.0, -2.0..2.0),
color: ColorOverTime::Gradient(Curve::new(vec![
CurvePoint::new(Color::RED, 0.0),
CurvePoint::new(Color::rgba(0.0, 0.0, 0.0, 0.0), 1.0),
CurvePoint::new(RED.into(), 0.0),
CurvePoint::new(Color::srgba(0.0, 0.0, 0.0, 0.0), 1.0),
])),
looping: true,
system_duration_seconds: 10.0,
Expand Down Expand Up @@ -80,8 +81,8 @@ fn startup_system(mut commands: Commands, asset_server: Res<AssetServer>) {
initial_speed: JitteredValue::jittered(25.0, 0.0..5.0),
lifetime: JitteredValue::jittered(3.0, -2.0..2.0),
color: ColorOverTime::Gradient(Curve::new(vec![
CurvePoint::new(Color::GREEN, 0.0),
CurvePoint::new(Color::rgba(0.0, 0.0, 0.0, 0.0), 1.0),
CurvePoint::new(GREEN.into(), 0.0),
CurvePoint::new(Color::srgba(0.0, 0.0, 0.0, 0.0), 1.0),
])),
looping: true,
system_duration_seconds: 10.0,
Expand Down
3 changes: 2 additions & 1 deletion examples/oneshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! automatically despawned when finished.

use bevy::{input::common_conditions::input_just_pressed, prelude::*, window::PrimaryWindow};
use bevy_color::palettes::basic::*;
use bevy_particle_systems::{
ParticleBurst, ParticleSystem, ParticleSystemBundle, ParticleSystemPlugin, Playing,
VelocityModifier,
Expand Down Expand Up @@ -48,7 +49,7 @@ fn spawn_particle_systems(
VelocityModifier::Drag(0.001.into()),
VelocityModifier::Vector(Vec3::new(0.0, -400.0, 0.0).into()),
],
color: (Color::BLUE..Color::rgba(1.0, 0.0, 0.0, 0.0)).into(),
color: (BLUE.into()..Color::srgba(1.0, 0.0, 0.0, 0.0)).into(),
bursts: vec![ParticleBurst {
time: 0.0,
count: 1000,
Expand Down
13 changes: 7 additions & 6 deletions examples/shape_emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use bevy::{
};
use bevy_app::PluginGroup;
use bevy_asset::AssetServer;
use bevy_color::palettes::basic::*;

use bevy_particle_systems::{
CircleSegment, ColorOverTime, Curve, CurvePoint, EmitterShape, JitteredValue, ParticleSystem,
Expand Down Expand Up @@ -44,9 +45,9 @@ fn startup_system(mut commands: Commands, asset_server: Res<AssetServer>) {
initial_speed: JitteredValue::jittered(70.0, -3.0..3.0),
lifetime: JitteredValue::jittered(3.0, -2.0..2.0),
color: ColorOverTime::Gradient(Curve::new(vec![
CurvePoint::new(Color::PURPLE, 0.0),
CurvePoint::new(Color::RED, 0.5),
CurvePoint::new(Color::rgba(0.0, 0.0, 1.0, 0.0), 1.0),
CurvePoint::new(PURPLE.into(), 0.0),
CurvePoint::new(RED.into(), 0.5),
CurvePoint::new(Color::srgba(0.0, 0.0, 1.0, 0.0), 1.0),
])),
emitter_shape: EmitterShape::line(200.0, std::f32::consts::FRAC_PI_4),
looping: true,
Expand All @@ -71,9 +72,9 @@ fn startup_system(mut commands: Commands, asset_server: Res<AssetServer>) {
initial_speed: JitteredValue::jittered(70.0, -3.0..3.0),
lifetime: JitteredValue::jittered(3.0, -2.0..2.0),
color: ColorOverTime::Gradient(Curve::new(vec![
CurvePoint::new(Color::PURPLE, 0.0),
CurvePoint::new(Color::RED, 0.5),
CurvePoint::new(Color::rgba(0.0, 0.0, 1.0, 0.0), 1.0),
CurvePoint::new(PURPLE.into(), 0.0),
CurvePoint::new(RED.into(), 0.5),
CurvePoint::new(Color::srgba(0.0, 0.0, 1.0, 0.0), 1.0),
])),
emitter_shape: CircleSegment {
radius: 10.0.into(),
Expand Down
11 changes: 6 additions & 5 deletions examples/texture_atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use bevy::{
};
use bevy_app::{App, PluginGroup, Startup};
use bevy_asset::{AssetServer, Assets};
use bevy_math::Vec2;
use bevy_color::{Gray, Srgba};
use bevy_math::{UVec2, Vec2};
use bevy_particle_systems::{
CircleSegment, ColorOverTime, Curve, CurvePoint, ParticleSystem, ParticleSystemBundle,
ParticleSystemPlugin, ParticleTexture, Playing,
Expand All @@ -33,7 +34,7 @@ fn startup_system(
) {
let projectiles = asset_server.load("gabe-idle-run.png");
let particle_atlas = atlases.add(TextureAtlasLayout::from_grid(
Vec2::new(24.0, 24.0),
UVec2::splat(24),
7,
1,
None,
Expand Down Expand Up @@ -61,10 +62,10 @@ fn startup_system(
initial_speed: (150.0..250.0).into(),
scale: 8.5.into(),
color: ColorOverTime::Gradient(Curve::new(vec![
CurvePoint::new(Color::rgba(1.0, 1.0, 1.0, 0.0), 0.0),
CurvePoint::new(Color::srgba(1.0, 1.0, 1.0, 0.0), 0.0),
CurvePoint::new(Color::WHITE, 0.1),
CurvePoint::new(Color::WHITE, 0.9),
CurvePoint::new(Color::rgba(1.0, 1.0, 1.0, 0.0), 1.0),
CurvePoint::new(Color::srgba(1.0, 1.0, 1.0, 0.0), 1.0),
])),
..Default::default()
},
Expand All @@ -78,7 +79,7 @@ fn startup_system(
fn setup_ground(mut commands: Commands) {
commands.spawn(SpriteBundle {
sprite: Sprite {
color: Color::DARK_GRAY,
color: Srgba::gray(0.25).into(),
custom_size: Some(Vec2 { x: 1000.0, y: 40.0 }),
..Default::default()
},
Expand Down
9 changes: 5 additions & 4 deletions examples/time_scaling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use bevy::{
};
use bevy_app::{Startup, Update};
use bevy_asset::AssetServer;
use bevy_color::palettes::basic::*;
use bevy_particle_systems::{
CircleSegment, ColorOverTime, Curve, CurvePoint, JitteredValue, ParticleSpace, ParticleSystem,
ParticleSystemBundle, ParticleSystemPlugin, Playing,
Expand Down Expand Up @@ -41,8 +42,8 @@ fn startup_system(mut commands: Commands, asset_server: Res<AssetServer>) {
initial_speed: JitteredValue::jittered(25.0, 0.0..5.0),
lifetime: JitteredValue::jittered(3.0, -2.0..2.0),
color: ColorOverTime::Gradient(Curve::new(vec![
CurvePoint::new(Color::RED, 0.0),
CurvePoint::new(Color::rgba(0.0, 0.0, 0.0, 0.0), 1.0),
CurvePoint::new(RED.into(), 0.0),
CurvePoint::new(Color::srgba(0.0, 0.0, 0.0, 0.0), 1.0),
])),
looping: true,
system_duration_seconds: 10.0,
Expand Down Expand Up @@ -72,8 +73,8 @@ fn startup_system(mut commands: Commands, asset_server: Res<AssetServer>) {
initial_speed: JitteredValue::jittered(25.0, 0.0..5.0),
lifetime: JitteredValue::jittered(3.0, -2.0..2.0),
color: ColorOverTime::Gradient(Curve::new(vec![
CurvePoint::new(Color::GREEN, 0.0),
CurvePoint::new(Color::rgba(0.0, 0.0, 0.0, 0.0), 1.0),
CurvePoint::new(GREEN.into(), 0.0),
CurvePoint::new(Color::srgba(0.0, 0.0, 0.0, 0.0), 1.0),
])),
looping: true,
system_duration_seconds: 10.0,
Expand Down
13 changes: 7 additions & 6 deletions examples/velocity_modifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use bevy::{
};
use bevy_app::Startup;
use bevy_asset::AssetServer;
use bevy_color::palettes::basic::*;

use bevy_particle_systems::{
CircleSegment, ColorOverTime, Curve, CurvePoint, JitteredValue, Noise2D, ParticleSystem,
Expand Down Expand Up @@ -53,7 +54,7 @@ fn startup_system(mut commands: Commands, asset_server: Res<AssetServer>) {
Vector(Vec3::new(0.0, 250.0, 0.0).into()),
],
lifetime: JitteredValue::jittered(1.5, -0.2..0.2),
color: ColorOverTime::Constant(Color::RED),
color: ColorOverTime::Constant(RED.into()),
scale: 10.0.into(),
rotation_speed: 2.0.into(),
..ParticleSystem::default()
Expand All @@ -80,7 +81,7 @@ fn startup_system(mut commands: Commands, asset_server: Res<AssetServer>) {
Drag(0.01.into()),
],
lifetime: JitteredValue::jittered(1.5, -0.2..0.2),
color: ColorOverTime::Constant(Color::GREEN),
color: ColorOverTime::Constant(GREEN.into()),
scale: 10.0.into(),
rotation_speed: 2.0.into(),
..ParticleSystem::default()
Expand Down Expand Up @@ -110,7 +111,7 @@ fn startup_system(mut commands: Commands, asset_server: Res<AssetServer>) {
}),
],
lifetime: JitteredValue::jittered(2.5, -0.2..0.2),
color: ColorOverTime::Constant(Color::BLUE),
color: ColorOverTime::Constant(BLUE.into()),
scale: (10.0..0.1).into(),
rotation_speed: 2.0.into(),
..ParticleSystem::default()
Expand Down Expand Up @@ -146,9 +147,9 @@ fn startup_system(mut commands: Commands, asset_server: Res<AssetServer>) {
lifetime: JitteredValue::jittered(1.5, -0.2..0.2),
color: ColorOverTime::Gradient(Curve::new(vec![
CurvePoint::new(Color::WHITE, 0.0),
CurvePoint::new(Color::rgba(0.8, 0.2, 0.0, 1.0), 0.05),
CurvePoint::new(Color::rgba(0.0, 0.0, 0.0, 0.25), 0.5),
CurvePoint::new(Color::rgba(0.0, 0.0, 0.0, 0.0), 1.0),
CurvePoint::new(Color::srgba(0.8, 0.2, 0.0, 1.0), 0.05),
CurvePoint::new(Color::srgba(0.0, 0.0, 0.0, 0.25), 0.5),
CurvePoint::new(Color::srgba(0.0, 0.0, 0.0, 0.0), 1.0),
])),
scale: (8.0..50.0).into(),
rotation_speed: 2.0.into(),
Expand Down
2 changes: 1 addition & 1 deletion src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub struct ParticleSystem {

/// The color of each particle over time.
///
/// Color is used to modify the ``default_sprite``. A constant value of [`bevy_render::prelude::Color::WHITE`] will make the sprite appear with no modifications.
/// Color is used to modify the ``default_sprite``. A constant value of [`bevy_color::prelude::Color::WHITE`] will make the sprite appear with no modifications.
///
/// This can vary over time and be used to modify alpha as well.
pub color: ColorOverTime,
Expand Down
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
clippy::must_use_candidate,
clippy::return_self_not_must_use,
clippy::needless_pass_by_value,
clippy::type_complexity
clippy::type_complexity,
clippy::used_underscore_binding
)]
//! A particle system plugin for [bevy](https://bevyengine.org)
//!
Expand Down Expand Up @@ -46,7 +47,7 @@
//! lifetime: JitteredValue::jittered(8.0, -2.0..2.0),
//! color: ColorOverTime::Gradient(Curve::new(vec![
//! CurvePoint::new(Color::WHITE, 0.0),
//! CurvePoint::new(Color::rgba(0.0, 0.0, 1.0, 0.0), 1.0),
//! CurvePoint::new(Color::srgba(0.0, 0.0, 1.0, 0.0), 1.0),
//! ])),
//! looping: true,
//! system_duration_seconds: 10.0,
Expand All @@ -67,10 +68,10 @@ use bevy_app::{
prelude::{App, Plugin},
Update,
};
use bevy_color::Color;
use bevy_ecs::prelude::IntoSystemConfigs;
use bevy_math::Vec3;
use bevy_reflect::std_traits::ReflectDefault;
use bevy_render::color::Color;
pub use components::*;
pub use systems::ParticleSystemSet;
use systems::{
Expand Down
48 changes: 26 additions & 22 deletions src/systems.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use bevy_ecs::prelude::{Commands, Entity, Query, Res, SystemSet, With};
use bevy_hierarchy::BuildChildren;
use bevy_math::{Quat, Vec2, Vec3};
use bevy_sprite::prelude::{Sprite, SpriteBundle};
use bevy_sprite::{SpriteSheetBundle, TextureAtlas};
use bevy_sprite::prelude::{Sprite, SpriteBundle, TextureAtlas};
use bevy_time::{Real, Time};
use bevy_transform::prelude::{GlobalTransform, Transform};

Expand Down Expand Up @@ -192,20 +191,23 @@ pub fn particle_spawner(
atlas: atlas_handle,
index,
} => {
entity_commands.insert(SpriteSheetBundle {
texture: texture_handle.clone(),
sprite: Sprite {
color: particle_system.color.at_lifetime_pct(0.0),
custom_size: particle_system.rescale_texture,
..Sprite::default()
entity_commands.insert((
SpriteBundle {
texture: texture_handle.clone(),
sprite: Sprite {
color: particle_system.color.at_lifetime_pct(0.0),
custom_size: particle_system.rescale_texture,
..Sprite::default()
},

transform: spawn_point,
..SpriteBundle::default()
},
atlas: TextureAtlas {
TextureAtlas {
layout: atlas_handle.clone(),
index: index.get_value(&mut rng),
},
transform: spawn_point,
..SpriteSheetBundle::default()
});
));

if let AtlasIndex::Animated(animated_index) = index {
entity_commands.insert(animated_index.clone());
Expand Down Expand Up @@ -257,20 +259,22 @@ pub fn particle_spawner(
atlas: atlas_handle,
index,
} => {
entity_commands.insert(SpriteSheetBundle {
texture: texture_handle.clone(),
sprite: Sprite {
color: particle_system.color.at_lifetime_pct(0.0),
custom_size: particle_system.rescale_texture,
..Sprite::default()
entity_commands.insert((
SpriteBundle {
texture: texture_handle.clone(),
sprite: Sprite {
color: particle_system.color.at_lifetime_pct(0.0),
custom_size: particle_system.rescale_texture,
..Sprite::default()
},
transform: spawn_point,
..SpriteBundle::default()
},
atlas: TextureAtlas {
TextureAtlas {
layout: atlas_handle.clone(),
index: index.get_value(&mut rng),
},
transform: spawn_point,
..SpriteSheetBundle::default()
});
));

if let AtlasIndex::Animated(animated_index) = index {
entity_commands.insert(animated_index.clone());
Expand Down
Loading
Loading