Add asset for number of cameras (should be 1 per display state)

bevy0.12
Elijah C. Voigt 2 years ago
parent 3cee6763f5
commit e8e53dcc86

@ -28,9 +28,9 @@ impl Plugin for GamePlugin {
.add_systems(
PreUpdate,
(
asserts::<display2d::Display2d>,
asserts::<display3d::Display3d>,
),
asserts::<display2d::Display2d>.run_if(in_state(DisplayState::Display2d)),
asserts::<display3d::Display3d>.run_if(in_state(DisplayState::Display3d)),
).run_if(in_state(GameState::Play)),
)
.add_systems(
PostUpdate,
@ -489,6 +489,7 @@ fn capture_piece(mut events: Query<&mut Visibility, Added<Captured>>) {
fn asserts<T: Component>(
selected_pieces: Query<Entity, (With<Piece>, With<T>, With<Selected>)>,
selected_tiles: Query<Entity, (With<Tile>, With<T>, With<Selected>)>,
cameras: Query<Entity, (With<Camera>, With<T>)>,
) {
if selected_pieces.iter().len() > 2 {
selected_pieces.iter().for_each(|e| {
@ -505,4 +506,7 @@ fn asserts<T: Component>(
selected_tiles.iter().len()
);
}
}
if cameras.iter().len() != 1 {
panic!("There should be 2 cameras in this state, but there is only {}", cameras.iter().len());
}
}
Loading…
Cancel
Save