Skip to content

Commit

Permalink
chore(deps)!: require bevy version 0.6 (#15)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the cargo feature `warnings` is removed, as it is no longer possible to add the animation as component by mistake
  • Loading branch information
jcornaz authored Jan 8, 2022
1 parent 9f7f687 commit 99da92b
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 67 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- bevy-main

pull_request:
branches:
Expand Down Expand Up @@ -35,8 +36,6 @@ jobs:
restore-keys: test-${{ env.RUST_VERSION }}-${{ hashFiles('Cargo.lock') }}
- run: cargo test --no-default-features
- run: cargo test --no-default-features -- --ignored
- run: cargo test --no-default-features --features warnings
- run: cargo test --no-default-features --features warnings -- --ignored
- run: cargo test
- run: cargo test -- --ignored
- run: cargo test --all-features
Expand Down
21 changes: 8 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,14 @@ repository = "https://github.com/jcornaz/benimator"
keywords = ["game", "gamedev", "anmiation", "bevy"]
categories = ["game-development"]

[features]
default = ["warnings"]
warnings = ["bevy_log"]

[dependencies]
bevy_core = { version = "^0.5.0", default-features = false }
bevy_ecs = { version = "^0.5.0", default-features = false }
bevy_app = { version = "^0.5.0", default-features = false }
bevy_reflect = { version = "^0.5.0", default-features = false }
bevy_sprite = { version = "^0.5.0", default-features = false }
bevy_asset = { version = "^0.5.0", default-features = false }
bevy_log = { version = "^0.5.0", default-features = false, optional = true }
bevy_core = { version = "0.6.0", default-features = false }
bevy_ecs = { version = "0.6.0", default-features = false }
bevy_app = { version = "0.6.0", default-features = false }
bevy_reflect = { version = "0.6.0", default-features = false }
bevy_sprite = { version = "0.6.0", default-features = false }
bevy_asset = { version = "0.6.0", default-features = false }

[dev-dependencies]
bevy = { version = "^0.5.0", default-features = false, features = ["render", "bevy_wgpu", "x11", "png"] }
rstest = "^0.7.0" # Newer versions are incompatible with bevy 0.5
bevy = { version = "0.6.0", default-features = false, features = ["render", "x11", "png"] }
rstest = "0.11.0"
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ A sprite sheet animation plugin for [bevy](https://bevyengine.org)

```rust
fn main() {
App::build()
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(AnimationPlugin) // <-- Add the plugin
.add_startup_system(spawn.system())
Expand Down Expand Up @@ -84,16 +84,14 @@ benimator = "*"
*Note: I recomend to explicitly define the version number instead of using the wildcard (`*`)*


## Cargo features

* `warnings` (enabled by default). Log warnings in case of incorrect usage detected.

## Bevy Version Compatibility

| bevy | benimator |
|------|------------|
| 0.5 | >= 0.1 |
| bevy | benimator |
|------|-----------|
| 0.6 | 1.0.0 |
| 0.5 | 0.1 - 0.4 |

*Note: Only the latest published version of benimator is supported*

## Contribute / Contact

Expand Down
15 changes: 7 additions & 8 deletions examples/change_animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct Animations {
}

fn main() {
App::build()
App::new()
.init_resource::<Animations>()
.add_plugins(DefaultPlugins)
.add_plugin(AnimationPlugin)
Expand Down Expand Up @@ -66,13 +66,12 @@ fn change_animation(
animations: Res<Animations>,
mut query: Query<(&mut Timer, &mut Handle<SpriteSheetAnimation>)>,
) {
if let Ok((mut timer, mut animation)) = query.single_mut() {
if timer.tick(time.delta()).finished() {
if animation.deref() == &animations.fast {
*animation = animations.slow.clone();
} else {
*animation = animations.fast.clone();
}
let (mut timer, mut animation) = query.single_mut();
if timer.tick(time.delta()).finished() {
if animation.deref() == &animations.fast {
*animation = animations.slow.clone();
} else {
*animation = animations.fast.clone();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/end_of_animation_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bevy::prelude::*;
use benimator::*;

fn main() {
App::build()
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(AnimationPlugin)
.add_startup_system(spawn_animated_coin.system())
Expand Down
2 changes: 1 addition & 1 deletion examples/readme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bevy::prelude::*;
use benimator::*;

fn main() {
App::build()
App::new()
.add_plugins(DefaultPlugins)
.add_plugin(AnimationPlugin) // <-- Add the plugin
.add_startup_system(spawn.system())
Expand Down
6 changes: 3 additions & 3 deletions src/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub enum AnimationMode {
#[derive(Debug, Copy, Clone, Default)]
pub struct Frame {
/// Index in the sprite atlas
pub index: u32,
pub index: usize,
/// How long should the frame be displayed
pub duration: Duration,
}
Expand All @@ -48,7 +48,7 @@ impl SpriteSheetAnimation {
///
/// For more granular configuration, see [`from_frames`](SpriteSheetAnimation::from_frames)
#[must_use]
pub fn from_range(index_range: RangeInclusive<u32>, frame_duration: Duration) -> Self {
pub fn from_range(index_range: RangeInclusive<usize>, frame_duration: Duration) -> Self {
Self::from_frames(
index_range
.map(|index| Frame::new(index, frame_duration))
Expand Down Expand Up @@ -86,7 +86,7 @@ impl Frame {
/// Create a new animation frame
#[inline]
#[must_use]
pub fn new(index: u32, duration: Duration) -> Self {
pub fn new(index: usize, duration: Duration) -> Self {
Self { index, duration }
}
}
12 changes: 3 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! use benimator::*;
//!
//! fn main() {
//! App::build()
//! App::new()
//! .add_plugins(DefaultPlugins)
//! .add_plugin(AnimationPlugin) // <-- Enable sprite-sheet animations
//! .add_startup_system(spawn.system())
Expand Down Expand Up @@ -122,9 +122,6 @@ pub use state::SpriteSheetAnimationState;
mod animation;
mod state;

#[cfg(feature = "warnings")]
mod warnings;

/// Plugin to enable sprite-sheet animation
///
/// See crate level documentation for usage
Expand All @@ -143,17 +140,14 @@ pub enum AnimationPostUpdateSystem {
/// Insert the components to play the animation, and remove it to pause it.
///
/// If the animation mode is [`AnimationMode::Once`] this component is automatically removed at the end of the animation.
#[derive(Debug, Copy, Clone, Default, Reflect)]
#[derive(Debug, Copy, Clone, Default, Reflect, Component)]
#[reflect(Component)]
pub struct Play;

impl Plugin for AnimationPlugin {
fn build(&self, app: &mut AppBuilder) {
fn build(&self, app: &mut App) {
app.add_asset::<SpriteSheetAnimation>()
.add_system_set_to_stage(CoreStage::PreUpdate, state::maintenance_systems())
.add_system_to_stage(CoreStage::Update, state::post_update_system());

#[cfg(feature = "warnings")]
app.add_system_set(warnings::systems());
}
}
10 changes: 6 additions & 4 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) fn post_update_system() -> impl System<In = (), Out = ()> {
/// }
/// }
/// ```
#[derive(Default)]
#[derive(Default, Component)]
pub struct SpriteSheetAnimationState {
current_frame: usize,
elapsed_in_frame: Duration,
Expand Down Expand Up @@ -84,8 +84,9 @@ impl SpriteSheetAnimationState {
}

fn insert(
mut commands: Commands<'_>,
mut commands: Commands<'_, '_>,
query: Query<
'_,
'_,
Entity,
(
Expand All @@ -102,7 +103,7 @@ fn insert(
}

fn remove(
mut commands: Commands<'_>,
mut commands: Commands<'_, '_>,
removed: RemovedComponents<'_, Handle<SpriteSheetAnimation>>,
) {
for entity in removed.iter() {
Expand All @@ -113,10 +114,11 @@ fn remove(
}

fn animate(
mut commands: Commands<'_>,
mut commands: Commands<'_, '_>,
time: Res<'_, Time>,
animation_defs: Res<'_, Assets<SpriteSheetAnimation>>,
mut animations: Query<
'_,
'_,
(
Entity,
Expand Down
14 changes: 0 additions & 14 deletions src/warnings.rs

This file was deleted.

7 changes: 3 additions & 4 deletions tests/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ fn run_once(mut app: App) {

#[fixture]
fn app() -> App {
let mut builder = App::build();
let mut app = App::new();

builder
.add_plugin(CorePlugin)
app.add_plugin(CorePlugin)
.add_plugin(AssetPlugin)
.add_plugin(AnimationPlugin);

builder.app
app
}

0 comments on commit 99da92b

Please sign in to comment.