summaryrefslogtreecommitdiff
path: root/src/cell.rs
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2024-01-13 20:19:11 +0100
committerTom Barrett <tom@tombarrett.xyz>2024-01-13 20:19:11 +0100
commit15fe765d380abc70ed371a2af2806dbb2fa95199 (patch)
tree007f30f0a69a1af072e2811e54f4e4ce661452eb /src/cell.rs
parenta0207d6b7a53fd942f9010287d27336692893da4 (diff)
didnt build
Diffstat (limited to 'src/cell.rs')
-rw-r--r--src/cell.rs34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/cell.rs b/src/cell.rs
index 0d9b381..53e9860 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -107,22 +107,16 @@ impl Cell {
}
}
- pub fn set_occupant(
- &mut self,
- occupant: Occupant,
- sprite: &mut TextureAtlasSprite,
- visibility: &mut Visibility,
- ) {
+ pub fn set_occupant(&mut self, occupant: Occupant, sprite: &mut TextureAtlasSprite) {
self.occupant = occupant;
sprite.index = self.occupant.to_index();
- *visibility = Visibility::Inherited;
}
}
-pub fn insert(mut q: Query<(&mut Cell, &mut TextureAtlasSprite, &mut Visibility)>) {
- for (mut cell, mut sprite, mut visibility) in q.iter_mut() {
+pub fn insert(mut q: Query<(&mut Cell, &mut TextureAtlasSprite)>) {
+ for (mut cell, mut sprite) in q.iter_mut() {
if cell.occupant == Occupant::None && cell.y == constants::GRID_SIZE - 1 {
- cell.set_occupant(rand::random(), &mut sprite, &mut visibility);
+ cell.set_occupant(rand::random(), &mut sprite);
}
}
}
@@ -140,9 +134,9 @@ pub fn start_explosion(
}
}
-pub fn check(mut q: Query<(&mut Cell, &mut TextureAtlasSprite, &mut Visibility)>) {
+pub fn check(mut q: Query<(&mut Cell, &mut TextureAtlasSprite)>) {
let mut cells = [[Cell::default(); constants::GRID_SIZE]; constants::GRID_SIZE];
- for (cell, _, _) in q.iter_mut() {
+ for (cell, _) in q.iter_mut() {
cells[cell.x][cell.y] = *cell;
}
@@ -187,39 +181,39 @@ pub fn check(mut q: Query<(&mut Cell, &mut TextureAtlasSprite, &mut Visibility)>
for c in connected.iter() {
for (i, j) in c.iter() {
- for (mut cell, mut sprite, mut visibility) in q.iter_mut() {
+ for (mut cell, mut sprite) in q.iter_mut() {
if &cell.x == i && &cell.y == j && cell.occupant != Occupant::Explosion {
- cell.set_occupant(Occupant::Explosion, &mut sprite, &mut visibility);
+ cell.set_occupant(Occupant::Explosion, &mut sprite);
}
}
}
}
}
-pub fn falling(mut q: Query<(&mut Cell, &mut TextureAtlasSprite, &mut Visibility)>) {
+pub fn falling(mut q: Query<(&mut Cell, &mut TextureAtlasSprite)>) {
let mut have_gems = Vec::new();
- for (cell, _sprite, _visibility) in q.iter_mut() {
+ for (cell, _sprite) in q.iter_mut() {
if cell.occupant != Occupant::None {
have_gems.push(*cell);
}
}
let mut moved_gems = Vec::new();
- for (mut cell, mut sprite, mut visibility) in q.iter_mut() {
+ for (mut cell, mut sprite) in q.iter_mut() {
if cell.occupant == Occupant::None {
if let Some(c) = have_gems
.iter()
.find(|&c| (c.x, c.y) == (cell.x, cell.y + 1))
{
- cell.set_occupant(c.occupant, &mut sprite, &mut visibility);
+ cell.set_occupant(c.occupant, &mut sprite);
moved_gems.push(c);
}
}
}
- for (mut cell, mut sprite, mut visibility) in q.iter_mut() {
+ for (mut cell, mut sprite) in q.iter_mut() {
if moved_gems.iter().any(|c| (c.x, c.y) == (cell.x, cell.y)) {
- cell.set_occupant(Occupant::None, &mut sprite, &mut visibility);
+ cell.set_occupant(Occupant::None, &mut sprite);
}
}
}