Crate unification (#88)
* move client/server/config into shared * move platforms into shared * move head drops into shared * move tb_entities to shared * reduce server to just a call into shared * get solo play working * fix server opening window * fix fmt * extracted a few more modules from client * near completely migrated client * fixed duplicate CharacterInputEnabled definition * simplify a few things related to builds * more simplifications * fix warnings/check * ci update * address comments * try fixing macos steam build * address comments * address comments * CI tweaks with default client feature --------- Co-authored-by: PROMETHIA-27 <electriccobras@gmail.com>
This commit is contained in:
39
crates/hedz_reloaded/src/utils/sprite_3d_animation.rs
Normal file
39
crates/hedz_reloaded/src/utils/sprite_3d_animation.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy_sprite3d::Sprite3d;
|
||||
|
||||
#[derive(Component, Reflect, Deref, DerefMut)]
|
||||
#[reflect(Component)]
|
||||
pub struct AnimationTimer(Timer);
|
||||
|
||||
impl AnimationTimer {
|
||||
pub fn new(t: Timer) -> Self {
|
||||
Self(t)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.add_systems(Update, animate_sprite);
|
||||
}
|
||||
|
||||
fn animate_sprite(
|
||||
mut commands: Commands,
|
||||
time: Res<Time>,
|
||||
mut query: Query<(Entity, &mut AnimationTimer, &Sprite3d, &mut Sprite)>,
|
||||
) {
|
||||
for (e, mut timer, sprite_3d, mut sprite) in query.iter_mut() {
|
||||
let length = sprite_3d.texture_atlas_keys.len();
|
||||
let atlas = sprite.texture_atlas.as_mut().unwrap();
|
||||
|
||||
if length > 0 {
|
||||
timer.tick(time.delta());
|
||||
}
|
||||
|
||||
if timer.just_finished() {
|
||||
if atlas.index + 1 < length {
|
||||
atlas.index = (atlas.index + 1) % length;
|
||||
} else {
|
||||
commands.entity(e).despawn();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user