use bevy::prelude::*;
use crate::{
animation::Animation, animator::Animator,
components::spritesheet_animation::SpritesheetAnimation, events::AnimationEvent,
systems::spritesheet_animation,
};
#[cfg(feature = "3d")]
use crate::components::sprite3d::Sprite3d;
#[cfg(feature = "3d")]
use crate::systems::sprite3d;
#[derive(Debug, PartialEq, Eq, Clone, Hash, SystemSet)]
pub struct AnimationSystemSet;
#[cfg(feature = "3d")]
#[derive(Debug, PartialEq, Eq, Clone, Hash, SystemSet)]
pub struct Sprite3dSystemSet;
#[derive(Default)]
pub struct SpritesheetAnimationPlugin;
impl Plugin for SpritesheetAnimationPlugin {
fn build(&self, app: &mut App) {
app
.init_asset::<Animation>()
.register_type::<Animation>()
.register_type::<SpritesheetAnimation>()
.init_resource::<Animator>()
.register_type::<Animator>()
.add_systems(
PostUpdate,
spritesheet_animation::play_animations.in_set(AnimationSystemSet),
)
.add_message::<AnimationEvent>();
#[cfg(feature = "3d")]
app
.init_resource::<sprite3d::Cache>()
.register_type::<sprite3d::Cache>()
.register_type::<Sprite3d>()
.add_systems(
PostUpdate,
(
sprite3d::setup_rendering,
sprite3d::sync_when_sprites_change,
sprite3d::sync_when_atlases_change,
)
.in_set(Sprite3dSystemSet)
.after(AnimationSystemSet),
);
}
}