mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-09 17:18:41 -06:00
is_changing_state
This commit is contained in:
parent
8e9eeb1f30
commit
aada43e8dc
|
@ -2,7 +2,7 @@ use shipyard::{UniqueView, UniqueViewMut, Workload, IntoWorkload, WorkloadModifi
|
|||
use glam::{Mat3, vec2};
|
||||
use crate::{
|
||||
world::ChunkStorage,
|
||||
state::{GameState, NextState},
|
||||
state::{GameState, NextState, is_changing_state},
|
||||
transform::Transform2d,
|
||||
gui::{
|
||||
GuiComponent,
|
||||
|
@ -72,13 +72,11 @@ fn switch_to_ingame_if_loaded(
|
|||
fn despawn_loading_screen_if_switching_state(
|
||||
mut storages: AllStoragesViewMut,
|
||||
) {
|
||||
let next = *storages.borrow::<UniqueView<NextState>>().unwrap();
|
||||
if let Some(state) = next.0 {
|
||||
if state != GameState::LoadingWorld {
|
||||
let progress_bar = storages.borrow::<UniqueView<ProgressbarId>>().unwrap().0;
|
||||
storages.delete_entity(progress_bar);
|
||||
storages.remove_unique::<ProgressbarId>().unwrap();
|
||||
}
|
||||
let state = storages.borrow::<UniqueView<NextState>>().unwrap().0.unwrap();
|
||||
if state != GameState::LoadingWorld {
|
||||
let progress_bar = storages.borrow::<UniqueView<ProgressbarId>>().unwrap().0;
|
||||
storages.delete_entity(progress_bar);
|
||||
storages.remove_unique::<ProgressbarId>().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,6 +86,6 @@ pub fn update_loading_screen() -> Workload {
|
|||
resize_progress_bar.into_workload().run_if(if_resized),
|
||||
update_progress_bar_progress,
|
||||
switch_to_ingame_if_loaded,
|
||||
despawn_loading_screen_if_switching_state,
|
||||
despawn_loading_screen_if_switching_state.into_workload().run_if(is_changing_state),
|
||||
).into_workload()
|
||||
}
|
||||
|
|
|
@ -29,6 +29,12 @@ pub fn update_state(
|
|||
*state = take(&mut next.0).unwrap_or(*state);
|
||||
}
|
||||
|
||||
pub fn is_changing_state(
|
||||
state: UniqueView<NextState>
|
||||
) -> bool {
|
||||
state.0.is_some()
|
||||
}
|
||||
|
||||
pub fn is_ingame(
|
||||
state: UniqueView<GameState>
|
||||
) -> bool {
|
||||
|
|
Loading…
Reference in a new issue