From b5d7ff2d758a7f6ad0dd1b48ef99fb35f727d7f1 Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Wed, 22 Dec 2021 00:49:15 +0000 Subject: [PATCH] Do not panic on failed setting of GameOver state in AlienCakeAddict (#3411) # Objective - Tentatively fixes #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. --- examples/game/alien_cake_addict.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/game/alien_cake_addict.rs b/examples/game/alien_cake_addict.rs index 9a7e0239ef..7f23e6f9dd 100644 --- a/examples/game/alien_cake_addict.rs +++ b/examples/game/alien_cake_addict.rs @@ -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; } }