diff options
author | Tom Barrett <tom@tombarrett.xyz> | 2021-03-21 18:45:36 +0100 |
---|---|---|
committer | Tom Barrett <tom@tombarrett.xyz> | 2021-03-21 18:45:36 +0100 |
commit | 420d0f36adeed7fa254497b49ef91a7574628082 (patch) | |
tree | 0e35934257c8548fe313cfcb59f4b13e07523e3a /src/cell.rs | |
parent | 4312f3b7eedbf6cdbe012be6eea1d45afd82de12 (diff) |
merged animation systems
Diffstat (limited to 'src/cell.rs')
-rw-r--r-- | src/cell.rs | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/src/cell.rs b/src/cell.rs index 1659289..d5d19e2 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -76,32 +76,13 @@ pub fn insert(mut cell_query: Query<(&mut Cell, &mut TextureAtlasSprite)>) { } } -pub fn explosion_animation( - time: Res<Time>, +pub fn start_explosion( commands: &mut Commands, - mut cell_query: Query<( - Entity, - &mut Cell, - &mut TextureAtlasSprite, - Option<&mut Timer>, - )>, + mut cell_query: Query<(Entity, &Cell), Without<Timer>>, ) { - for (entity, mut cell, mut sprite, timer) in cell_query.iter_mut() { + for (entity, cell) in cell_query.iter_mut() { if cell.occupant == Occupant::Explosion { - if let Some(mut timer) = timer { - timer.tick(time.delta_seconds()); - if timer.finished() { - if sprite.index < 7 && sprite.index >= 4 { - sprite.index += 1; - } else { - cell.occupant = Occupant::None; - sprite.index = cell.occupant.to_index(); - commands.remove_one::<Timer>(entity); - } - } - } else { - commands.insert(entity, (Timer::from_seconds(0.1, true),)); - } + commands.insert(entity, (Timer::from_seconds(0.1, true),)); } } } |