Skip to content

Commit

Permalink
update for Bevy 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Jul 10, 2023
1 parent 300aa26 commit 47646bb
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 74 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_easings"
version = "0.10.0"
version = "0.11.0"
authors = ["François Mockers <mockersf@gmail.com>"]
edition = "2021"
description = "Easing plugin for Bevy"
Expand All @@ -17,11 +17,11 @@ categories = ["game-development"]
interpolation = "0.2"

[dependencies.bevy]
version = "0.10"
version = "0.11"
default-features = false

[dev-dependencies.bevy]
version = "0.10"
version = "0.11"
default-features = false
features = ["bevy_render", "bevy_sprite", "bevy_ui"]

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Many [ease functions](https://docs.rs/interpolation/0.2.0/interpolation/enum.Eas
|Bevy|bevy_easings|
|---|---|
|main|main|
|0.11|0.11|
|0.10|0.10|
|0.9|0.9|
|0.8|0.8|
Expand Down
26 changes: 23 additions & 3 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ vulnerability = "deny"
unmaintained = "deny"
yanked = "deny"
notice = "deny"
ignore = ["RUSTSEC-2022-0048"]
ignore = []

[licenses]
unlicensed = "deny"
Expand All @@ -31,9 +31,29 @@ exceptions = [

[bans]
multiple-versions = "deny"
# allowed while working with git deps
# wildcards = "deny"
# Certain crates/versions that will be skipped when doing duplicate detection.
skip = [
{ name = "redox_syscall", version = "0.2.16" }
{ name = "ahash", version = "0.7" },
{ name = "bitflags", version = "1.3" },
{ name = "hashbrown", version = "0.12" },
{ name = "indexmap", version = "1.9" },
{ name = "libloading", version = "0.7" },
{ name = "num_enum", version = "0.5" },
{ name = "num_enum_derive", version = "0.5" },
{ name = "regex-automata", version = "0.1" },
{ name = "regex-syntax", version = "0.6" },
{ name = "syn", version = "1.0" },
{ name = "windows-sys", version = "0.45" },
{ name = "windows-targets", version = "0.42" },
{ name = "windows_aarch64_gnullvm", version = "0.42" },
{ name = "windows_aarch64_msvc", version = "0.42" },
{ name = "windows_i686_gnu", version = "0.42" },
{ name = "windows_i686_msvc", version = "0.42" },
{ name = "windows_x86_64_gnu", version = "0.42" },
{ name = "windows_x86_64_gnullvm", version = "0.42" },
{ name = "windows_x86_64_msvc", version = "0.42" },
]

[sources]
Expand All @@ -42,4 +62,4 @@ unknown-git = "deny"
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
allow-git = [
"https://github.com/bevyengine/bevy",
]
]
4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ impl bevy_easings::Lerp for CustomComponent {
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.add_default_plugins()
.add_plugin(bevy_easings::EasingsPlugin)
.add_startup_system(setup)
.add_plugins(bevy_easings::EasingsPlugin)
.add_systems(Startup, setup)
.add_system(check_value)
.add_system(bevy_easings::custom_ease_system::<CustomComponent>)
.run();
Expand Down
6 changes: 3 additions & 3 deletions examples/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use bevy_easings::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(bevy_easings::EasingsPlugin)
.add_startup_system(setup)
.add_system(add_easing.in_base_set(CoreSet::PostUpdate))
.add_plugins(bevy_easings::EasingsPlugin)
.add_systems(Startup, setup)
.add_systems(PostUpdate, add_easing)
.run();

Ok(())
Expand Down
14 changes: 6 additions & 8 deletions examples/custom_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use bevy_easings::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(bevy_easings::EasingsPlugin)
.add_startup_system(setup)
.add_system(check_value.in_schedule(CoreSchedule::FixedUpdate))
.add_plugins(bevy_easings::EasingsPlugin)
.add_systems(Startup, setup)
.add_systems(FixedUpdate, check_value)
.insert_resource(FixedTime::new_from_secs(0.2))
.add_system(bevy_easings::custom_ease_system::<CustomComponent>)
.add_systems(Update, bevy_easings::custom_ease_system::<CustomComponent>)
.run();

Ok(())
Expand All @@ -31,10 +31,8 @@ fn setup(mut commands: Commands) {
commands.spawn((
ImageBundle {
style: Style {
size: Size {
width: Val::Percent(3.),
height: Val::Percent(3.),
},
width: Val::Percent(3.),
height: Val::Percent(3.),

margin: UiRect {
bottom: Val::Percent(0.),
Expand Down
6 changes: 3 additions & 3 deletions examples/pause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use bevy_easings::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(bevy_easings::EasingsPlugin)
.add_startup_system(setup)
.add_system(pause.in_schedule(CoreSchedule::FixedUpdate))
.add_plugins(bevy_easings::EasingsPlugin)
.add_systems(Startup, setup)
.add_systems(FixedUpdate, pause)
.insert_resource(FixedTime::new_from_secs(0.25))
.run();

Expand Down
6 changes: 3 additions & 3 deletions examples/react_on_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use rand::Rng;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(bevy_easings::EasingsPlugin)
.add_startup_system(setup)
.add_system_to_stage(CoreStage::PostUpdate, add_new_easing)
.add_plugins(bevy_easings::EasingsPlugin)
.add_systems(Startup, setup)
.add_systems(PostUpdate, add_new_easing)
.run();

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions examples/sprite_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use bevy_easings::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(bevy_easings::EasingsPlugin)
.add_startup_system(setup)
.add_plugins(bevy_easings::EasingsPlugin)
.add_systems(Startup, setup)
.run();

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions examples/sprite_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use bevy_easings::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(bevy_easings::EasingsPlugin)
.add_startup_system(setup)
.add_plugins(bevy_easings::EasingsPlugin)
.add_systems(Startup, setup)
.run();

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions examples/transform_rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use bevy_easings::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(bevy_easings::EasingsPlugin)
.add_startup_system(setup)
.add_plugins(bevy_easings::EasingsPlugin)
.add_systems(Startup, setup)
.run();

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions examples/transform_translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use bevy_easings::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(bevy_easings::EasingsPlugin)
.add_startup_system(setup)
.add_plugins(bevy_easings::EasingsPlugin)
.add_systems(Startup, setup)
.run();

Ok(())
Expand Down
10 changes: 4 additions & 6 deletions examples/ui_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use bevy_easings::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(bevy_easings::EasingsPlugin)
.add_startup_system(setup)
.add_plugins(bevy_easings::EasingsPlugin)
.add_systems(Startup, setup)
.run();

Ok(())
Expand Down Expand Up @@ -50,10 +50,8 @@ fn setup(mut commands: Commands) {
commands.spawn((
ImageBundle {
style: Style {
size: Size {
width: Val::Percent(3.),
height: Val::Percent(3.),
},
width: Val::Percent(3.),
height: Val::Percent(3.),

margin: UiRect {
bottom: Val::Percent(0.),
Expand Down
10 changes: 4 additions & 6 deletions examples/ui_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use bevy_easings::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.add_plugins(DefaultPlugins)
.add_plugin(bevy_easings::EasingsPlugin)
.add_startup_system(setup)
.add_plugins(bevy_easings::EasingsPlugin)
.add_systems(Startup, setup)
.run();

Ok(())
Expand Down Expand Up @@ -53,10 +53,8 @@ fn setup(mut commands: Commands) {
..Default::default()
},
Style {
size: Size {
width: Val::Percent(3.),
height: Val::Percent(3.),
},
width: Val::Percent(3.),
height: Val::Percent(3.),

margin: UiRect {
top: Val::Percent(0.),
Expand Down
53 changes: 28 additions & 25 deletions src/implemented.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,17 @@ impl Lerp for EaseValue<Style> {

fn lerp(&self, other: &Self, scalar: &Self::Scalar) -> Self {
EaseValue(Style {
position: EaseValue(self.0.position)
.lerp(&EaseValue(other.0.position), scalar)
left: EaseValue(self.0.left)
.lerp(&EaseValue(other.0.left), scalar)
.0,
right: EaseValue(self.0.right)
.lerp(&EaseValue(other.0.right), scalar)
.0,
top: EaseValue(self.0.top)
.lerp(&EaseValue(other.0.top), scalar)
.0,
bottom: EaseValue(self.0.bottom)
.lerp(&EaseValue(other.0.bottom), scalar)
.0,
margin: EaseValue(self.0.margin)
.lerp(&EaseValue(other.0.margin), scalar)
Expand All @@ -66,16 +75,26 @@ impl Lerp for EaseValue<Style> {
border: EaseValue(self.0.border)
.lerp(&EaseValue(other.0.border), scalar)
.0,
size: EaseValue(self.0.size)
.lerp(&EaseValue(other.0.size), scalar)
width: EaseValue(self.0.width)
.lerp(&EaseValue(other.0.width), scalar)
.0,
height: EaseValue(self.0.height)
.lerp(&EaseValue(other.0.height), scalar)
.0,
min_width: EaseValue(self.0.min_width)
.lerp(&EaseValue(other.0.min_width), scalar)
.0,
min_height: EaseValue(self.0.min_height)
.lerp(&EaseValue(other.0.min_height), scalar)
.0,
min_size: EaseValue(self.0.min_size)
.lerp(&EaseValue(other.0.min_size), scalar)
max_width: EaseValue(self.0.max_width)
.lerp(&EaseValue(other.0.max_width), scalar)
.0,
max_size: EaseValue(self.0.max_size)
.lerp(&EaseValue(other.0.max_size), scalar)
max_height: EaseValue(self.0.max_height)
.lerp(&EaseValue(other.0.max_height), scalar)
.0,
..self.0
grid_template_rows: self.0.grid_template_rows.clone(),
..default()
})
}
}
Expand All @@ -102,22 +121,6 @@ impl Lerp for EaseValue<UiRect> {
}
}

#[cfg(feature = "ui")]
impl Lerp for EaseValue<Size> {
type Scalar = f32;

fn lerp(&self, other: &Self, scalar: &Self::Scalar) -> Self {
EaseValue(Size {
width: EaseValue(self.0.width)
.lerp(&EaseValue(other.0.width), scalar)
.0,
height: EaseValue(self.0.height)
.lerp(&EaseValue(other.0.height), scalar)
.0,
})
}
}

#[cfg(feature = "ui")]
impl Lerp for EaseValue<Val> {
type Scalar = f32;
Expand Down
8 changes: 4 additions & 4 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pub struct EasingsPlugin;

impl Plugin for EasingsPlugin {
fn build(&self, app: &mut App) {
app.add_system(ease_system::<Transform>);
app.add_systems(Update, ease_system::<Transform>);
#[cfg(feature = "sprite")]
app.add_system(ease_system::<Sprite>);
app.add_systems(Update, ease_system::<Sprite>);
#[cfg(feature = "ui")]
app.add_system(ease_system::<Style>);
app.add_systems(Update, ease_system::<Style>);
#[cfg(feature = "ui")]
app.add_system(ease_system::<BackgroundColor>);
app.add_systems(Update, ease_system::<BackgroundColor>);
}
}

Expand Down

0 comments on commit 47646bb

Please sign in to comment.