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