diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 21 | 
1 files changed, 16 insertions, 5 deletions
| diff --git a/src/main.rs b/src/main.rs index 97592eb..164ffe3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@  use bevy::math::Vec3;  use bevy::prelude::*; -use gems::cell::{self, Cell}; +use gems::cell::{self, Cell, Occupant};  use gems::constants;  use rand::{thread_rng, Rng}; @@ -113,9 +113,14 @@ pub fn setup(  fn animation_system(      commands: &mut Commands,      time: Res<Time>, -    mut cell_query: Query<(Entity, &mut Timer, &mut TextureAtlasSprite), Without<Cell>>, +    mut cell_query: Query<( +        Entity, +        Option<&mut Cell>, +        &mut Timer, +        &mut TextureAtlasSprite, +    )>,  ) { -    for (entity, mut timer, mut sprite) in cell_query.iter_mut() { +    for (entity, cell, mut timer, mut sprite) in cell_query.iter_mut() {          timer.tick(time.delta_seconds());          if timer.finished() {              let index = match sprite.index { @@ -135,7 +140,13 @@ fn animation_system(              };              sprite.index = index;              if index == constants::TILESHEET_NONE2 { -                commands.despawn(entity); +                if let Some(mut cell) = cell { +                    cell.occupant = Occupant::None; +                    sprite.index = cell.occupant.to_index(); +                    commands.remove_one::<Timer>(entity); +                } else { +                    commands.despawn(entity); +                }              }          }      } @@ -250,7 +261,7 @@ impl Plugin for GemsPlugin {          app.add_system(cell::insert.system());          app.add_system(cell::falling.system());          app.add_system(cell::check.system()); -        app.add_system(cell::explosion_animation.system()); +        app.add_system(cell::start_explosion.system());          app.add_system(mouse_system.system());          app.add_system(cosmonaut_detect_system.system());          app.add_system(animation_system.system()); | 
