From 8eb98b5baa4e465827d9dc88a8ae8563513cdcd8 Mon Sep 17 00:00:00 2001 From: Llywelwyn Date: Wed, 30 Aug 2023 05:58:08 +0100 Subject: [PATCH] player turn awaits empty particle queue --- src/main.rs | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6f6dc79..3532829 100644 --- a/src/main.rs +++ b/src/main.rs @@ -246,26 +246,28 @@ impl GameState for State { new_runstate = RunState::AwaitingInput; } RunState::AwaitingInput => { - // We refresh the index, and run anything that might - // still be in the queue, just to make 100% sure that - // there are no lingering effects from the last tick. - self.refresh_indexes(); - effects::run_effects_queue(&mut self.ecs); - // Sanity-checking that the player actually *should* - // be taking a turn before giving them one. If they - // don't have a turn component, go back to ticking. - let mut can_act = false; - { - let player_entity = self.ecs.fetch::(); - let turns = self.ecs.read_storage::(); - if let Some(_) = turns.get(*player_entity) { - can_act = true; + while particle_system::check_queue(&self.ecs) { + // We refresh the index, and run anything that might + // still be in the queue, just to make 100% sure that + // there are no lingering effects from the last tick. + self.refresh_indexes(); + effects::run_effects_queue(&mut self.ecs); + // Sanity-checking that the player actually *should* + // be taking a turn before giving them one. If they + // don't have a turn component, go back to ticking. + let mut can_act = false; + { + let player_entity = self.ecs.fetch::(); + let turns = self.ecs.read_storage::(); + if let Some(_) = turns.get(*player_entity) { + can_act = true; + } + } + if can_act { + new_runstate = player_input(self, ctx); + } else { + new_runstate = RunState::Ticking; } - } - if can_act { - new_runstate = player_input(self, ctx); - } else { - new_runstate = RunState::Ticking; } } RunState::Ticking => {