Skip to content

Commit

Permalink
Do not panic on failed setting of GameOver state in AlienCakeAddict (b…
Browse files Browse the repository at this point in the history
…evyengine#3411)

# Objective

- Tentatively fixes bevyengine#2525.

## Solution

- The panic seems to occur when the game-over state occurs nearly instantly.
- Discard the `Result`, rather than panicking. We could probably handle this better, but I want to see if this works first. Ping @qarmin.
  • Loading branch information
alice-i-cecile committed Dec 22, 2021
1 parent 004bbe9 commit b5d7ff2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/game/alien_cake_addict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ fn spawn_bonus(
commands.entity(entity).despawn_recursive();
game.bonus.entity = None;
if game.score <= -5 {
state.set(GameState::GameOver).unwrap();
// We don't particularly care if this operation fails
let _ = state.overwrite_set(GameState::GameOver);
return;
}
}
Expand Down

0 comments on commit b5d7ff2

Please sign in to comment.