Skip to content
Snippets Groups Projects
Verified Commit 29b12830 authored by Louis's avatar Louis :fire:
Browse files

Update to bevy 0.10, temporarily disable tilemap support

parent 646f7205
No related branches found
No related tags found
No related merge requests found
[package] [package]
name = "micro_banimate" name = "micro_banimate"
version = "0.4.0" version = "0.5.0-beta.0"
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
description = "Easily manage complex Bevy 2D sprite animations" description = "Easily manage complex Bevy 2D sprite animations"
...@@ -10,16 +10,18 @@ authors = [ ...@@ -10,16 +10,18 @@ authors = [
repository = "https://lab.lcr.gr/microhacks/micro-banimate" repository = "https://lab.lcr.gr/microhacks/micro-banimate"
[features] [features]
default = ["json_loader", "ecs_tilemap"] default = ["json_loader"]
json_loader = ["serde", "dep:serde_json"] json_loader = ["serde", "dep:serde_json"]
toml_loader = ["serde", "dep:toml"] toml_loader = ["serde", "dep:toml"]
ecs_tilemap = ["dep:bevy_ecs_tilemap"]
serde = ["dep:serde"] serde = ["dep:serde"]
#ecs_tilemap = ["dep:bevy_ecs_tilemap"]
[dependencies] [dependencies]
anyhow = "^1.0.65" anyhow = "^1.0.65"
serde = { version = "^1.0.145", optional = true } serde = { version = "^1.0.145", optional = true }
serde_json = { version = "^1.0.85", optional = true } serde_json = { version = "^1.0.85", optional = true }
toml = { version = "^0.5.9", optional = true } toml = { version = "^0.5.9", optional = true }
bevy = { version = "^0.9.0", default-features = false, features = ["bevy_asset", "render"] } bevy = { version = "^0.10.0", default-features = false, features = ["bevy_asset", "bevy_sprite"] }
bevy_ecs_tilemap = { version = "^0.9.0", optional = true }
#bevy_ecs_tilemap = { version = "^0.9.0", optional = true }
...@@ -120,7 +120,8 @@ frame_time = 100 ...@@ -120,7 +120,8 @@ frame_time = 100
## Compatibility ## Compatibility
| banimate version | bevy version | tilemap version | | banimate version | bevy version | tilemap version |
|------------------|--------------|-----------------| |---------------------|--------------|-----------------|
| 0.2.x | 0.9 | 0.9 | | 0.5.x | 0.10 | -- |
| 0.1.x | 0.8 | 0.8 | | 0.2.x, 0.3.x, 0.4.x | 0.9 | 0.9 |
| 0.1.x | 0.8 | 0.8 |
...@@ -53,7 +53,7 @@ pub struct AnimationQuery<'w, 's> { ...@@ -53,7 +53,7 @@ pub struct AnimationQuery<'w, 's> {
action_animation: Query<'w, 's, &'static mut AnimationOverride>, action_animation: Query<'w, 's, &'static mut AnimationOverride>,
tile_sprite: Query<'w, 's, &'static mut TextureAtlasSprite>, tile_sprite: Query<'w, 's, &'static mut TextureAtlasSprite>,
paused: Query<'w, 's, Entity, With<AnimationPaused>>, paused: Query<'w, 's, Entity, With<AnimationPaused>>,
events: EventWriter<'w, 's, AnimationCompleted>, events: EventWriter<'w, AnimationCompleted>,
} }
impl<'w, 's> Deref for AnimationQuery<'w, 's> { impl<'w, 's> Deref for AnimationQuery<'w, 's> {
......
...@@ -3,7 +3,7 @@ use bevy::prelude::*; ...@@ -3,7 +3,7 @@ use bevy::prelude::*;
use crate::definitions::*; use crate::definitions::*;
use crate::query::AnimationQuery; use crate::query::AnimationQuery;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemLabel)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, SystemSet)]
pub enum AnimationSystems { pub enum AnimationSystems {
TickAnimations, TickAnimations,
SyncAnimations, SyncAnimations,
...@@ -51,55 +51,54 @@ pub fn sync_parent_animations(mut query: AnimationQuery) { ...@@ -51,55 +51,54 @@ pub fn sync_parent_animations(mut query: AnimationQuery) {
query.sync_parent_animations(); query.sync_parent_animations();
} }
#[cfg(feature = "ecs_tilemap")] // #[cfg(feature = "ecs_tilemap")]
pub fn tick_simple_tilemap_animation( // pub fn tick_simple_tilemap_animation(
time: Res<Time>, // time: Res<Time>,
mut query: Query< // mut query: Query<
( // (
&SimpleLoopedAnimation, // &SimpleLoopedAnimation,
&mut SimpleLoopedAnimationStatus, // &mut SimpleLoopedAnimationStatus,
&mut bevy_ecs_tilemap::tiles::TileTextureIndex, // &mut bevy_ecs_tilemap::tiles::TileTextureIndex,
), // ),
With<HasSimpleAnimations>, // With<HasSimpleAnimations>,
>, // >,
) { // ) {
let seconds = time.delta_seconds(); // let seconds = time.delta_seconds();
for (animation, mut state, mut tile) in &mut query { // for (animation, mut state, mut tile) in &mut query {
state.frame_time += seconds; // state.frame_time += seconds;
while state.frame_time >= animation.frame_secs { // while state.frame_time >= animation.frame_secs {
state.frame_time -= animation.frame_secs; // state.frame_time -= animation.frame_secs;
state.active_step += 1; // state.active_step += 1;
if state.active_step >= animation.frames.len() { // if state.active_step >= animation.frames.len() {
state.active_step = 0; // state.active_step = 0;
} // }
} // }
//
*tile = // *tile =
bevy_ecs_tilemap::tiles::TileTextureIndex(animation.frames[state.active_step] as u32); // bevy_ecs_tilemap::tiles::TileTextureIndex(animation.frames[state.active_step] as u32);
} // }
} // }
pub struct AnimationSystemsPlugin; pub struct AnimationSystemsPlugin;
impl Plugin for AnimationSystemsPlugin { impl Plugin for AnimationSystemsPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
let mut tick_systems = SystemSet::new() app.configure_set(
.label(AnimationSystems::TickAnimations) AnimationSystems::SyncAnimations
.with_system(tick_animations) .after(AnimationSystems::TickAnimations)
.with_system(tick_simple_sprite_animations); .in_base_set(CoreSet::PostUpdate),
);
#[cfg(feature = "ecs_tilemap")]
{
tick_systems = tick_systems.with_system(tick_simple_tilemap_animation);
}
app.add_event::<AnimationCompleted>() app.add_event::<AnimationCompleted>()
.add_system_set_to_stage(CoreStage::PostUpdate, tick_systems) .add_systems(
.add_system_to_stage( (tick_animations, tick_simple_sprite_animations)
CoreStage::PostUpdate, .in_set(AnimationSystems::TickAnimations),
sync_parent_animations )
.label(AnimationSystems::SyncAnimations) .add_system(sync_parent_animations.in_set(AnimationSystems::SyncAnimations));
.after(AnimationSystems::TickAnimations),
); // #[cfg(feature = "ecs_tilemap")]
// {
// app.add_system(tick_simple_tilemap_animation.in_set(AnimationSystems::TickAnimations));
// }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment