summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2021-03-21 18:45:36 +0100
committerTom Barrett <tom@tombarrett.xyz>2021-03-21 18:45:36 +0100
commit420d0f36adeed7fa254497b49ef91a7574628082 (patch)
tree0e35934257c8548fe313cfcb59f4b13e07523e3a /src/main.rs
parent4312f3b7eedbf6cdbe012be6eea1d45afd82de12 (diff)
merged animation systems
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
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());