Simplify binary states

main
Elijah Voigt 2 days ago
parent 2376e05109
commit 86436575e2

@ -12,7 +12,7 @@ impl Plugin for BlocksPlugin {
fn build(&self, app: &mut App) {
app.init_asset::<ShapeAsset>()
.init_asset_loader::<ShapeAssetLoader>()
.add_systems(OnEnter(Loading::Active), load_assets.run_if(run_once))
.add_systems(OnEnter(Loading(true)), load_assets.run_if(run_once))
.add_systems(OnEnter(GameState::Setup), (setup_camera, setup_blocks))
.add_observer(add_shape);
}

@ -65,7 +65,6 @@ fn setup_ui(
column_gap: px(8),
..default()
},
TabGroup::default(),
children![
(Text::new("debugger:"), ThemedText),
(toggle_switch((),), observe(checkbox_self_update), observe(debug_toggle)),

@ -47,12 +47,18 @@ fn main() {
}
/// Reports if the game is loading assets
#[derive(States, Default, Clone, Eq, Debug, PartialEq, Hash, Component)]
#[derive(States, Clone, Eq, Debug, PartialEq, Hash, Component)]
struct Loading(bool);
impl Default for Loading {
fn default() -> Self {
Loading(true)
}
}
impl fmt::Display for Loading {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
rite!(f, "Loading {}", self.0)
write!(f, "Loading {}", self.0)
}
}
@ -97,7 +103,7 @@ impl SetupChecklist {
fn loading_check(mut next: ResMut<NextState<Loading>>, all_assets: Res<AllAssets>) {
debug_assert!(all_assets.is_changed());
next.set(Loading::Active);
next.set(Loading(true));
}
/// Waits in Loading::Active until all assets are loaded then move to Loading(false)

Loading…
Cancel
Save