mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-26 00:38:44 -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 glam::{Mat3, vec2};
|
||||||
use crate::{
|
use crate::{
|
||||||
world::ChunkStorage,
|
world::ChunkStorage,
|
||||||
state::{GameState, NextState},
|
state::{GameState, NextState, is_changing_state},
|
||||||
transform::Transform2d,
|
transform::Transform2d,
|
||||||
gui::{
|
gui::{
|
||||||
GuiComponent,
|
GuiComponent,
|
||||||
|
@ -72,14 +72,12 @@ fn switch_to_ingame_if_loaded(
|
||||||
fn despawn_loading_screen_if_switching_state(
|
fn despawn_loading_screen_if_switching_state(
|
||||||
mut storages: AllStoragesViewMut,
|
mut storages: AllStoragesViewMut,
|
||||||
) {
|
) {
|
||||||
let next = *storages.borrow::<UniqueView<NextState>>().unwrap();
|
let state = storages.borrow::<UniqueView<NextState>>().unwrap().0.unwrap();
|
||||||
if let Some(state) = next.0 {
|
|
||||||
if state != GameState::LoadingWorld {
|
if state != GameState::LoadingWorld {
|
||||||
let progress_bar = storages.borrow::<UniqueView<ProgressbarId>>().unwrap().0;
|
let progress_bar = storages.borrow::<UniqueView<ProgressbarId>>().unwrap().0;
|
||||||
storages.delete_entity(progress_bar);
|
storages.delete_entity(progress_bar);
|
||||||
storages.remove_unique::<ProgressbarId>().unwrap();
|
storages.remove_unique::<ProgressbarId>().unwrap();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_loading_screen() -> Workload {
|
pub fn update_loading_screen() -> Workload {
|
||||||
|
@ -88,6 +86,6 @@ pub fn update_loading_screen() -> Workload {
|
||||||
resize_progress_bar.into_workload().run_if(if_resized),
|
resize_progress_bar.into_workload().run_if(if_resized),
|
||||||
update_progress_bar_progress,
|
update_progress_bar_progress,
|
||||||
switch_to_ingame_if_loaded,
|
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()
|
).into_workload()
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,12 @@ pub fn update_state(
|
||||||
*state = take(&mut next.0).unwrap_or(*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(
|
pub fn is_ingame(
|
||||||
state: UniqueView<GameState>
|
state: UniqueView<GameState>
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
|
Loading…
Reference in a new issue