Skip to content

Commit

Permalink
Fix finished level indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr committed Feb 22, 2025
1 parent a0f1bf3 commit 6614e77
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions src/game_object/behaviors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,30 +126,24 @@ pub fn check_for_explosive(
}
}

#[expect(clippy::type_complexity)]
pub fn check_for_finished_levels(
mut commands: Commands,
mut query: Query<(
Entity,
Option<&Entrance>,
Option<&Openable>,
Option<&Massive>,
&mut Sprite,
)>,
mut entrance_query: Query<(&Entrance, &mut Sprite), Without<Openable>>,
mut openable_query: Query<
(Entity, &Openable, Option<&Massive>, &mut Sprite),
Without<Entrance>,
>,
game_state: Res<GameState>,
) {
if !game_state.is_changed() {
return;
}

for (entity, entrance, openable, massive, mut sprite) in &mut query {
if let Some(entrance) = entrance {
if game_state.finished_levels.contains(&entrance.0) {
if let Some(atlas) = sprite.texture_atlas.as_mut() {
atlas.index = 1;
}
for (entrance, mut sprite) in &mut entrance_query {
if game_state.finished_levels.contains(&entrance.0) {
if let Some(atlas) = sprite.texture_atlas.as_mut() {
atlas.index = 1;
}
} else if let Some(Openable::LevelFinished(level)) = openable {
}
}
for (entity, openable, massive, mut sprite) in &mut openable_query {
if let Openable::LevelFinished(level) = openable {
let opened = game_state.finished_levels.contains(level);
if opened && massive.is_some() {
commands.entity(entity).remove::<Massive>();
Expand Down

0 comments on commit 6614e77

Please sign in to comment.