game states cleanup
This commit is contained in:
+14
-3
@@ -2,11 +2,15 @@ use bevy::prelude::*;
|
||||
|
||||
use crate::{camera::MainCamera, game_state::GameState, player::Player};
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Debug;
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct DebugCamera;
|
||||
|
||||
fn spawn_debug_camera(mut commands: Commands) {
|
||||
commands.spawn((
|
||||
Debug,
|
||||
DebugCamera,
|
||||
Camera2d,
|
||||
Camera {
|
||||
@@ -63,6 +67,7 @@ fn spawn_debug_frame(mut commands: Commands) {
|
||||
};
|
||||
|
||||
commands.spawn((
|
||||
Debug,
|
||||
FramePart(side),
|
||||
Sprite::from_color(Color::srgb(1.0, 0.0, 0.0), size),
|
||||
Visibility::Hidden,
|
||||
@@ -99,18 +104,24 @@ fn draw_view_frame(
|
||||
*visibility = visible;
|
||||
}
|
||||
}
|
||||
|
||||
fn cleanup_debug(mut commands: Commands, entities: Query<Entity, With<Debug>>) {
|
||||
for entity in entities {
|
||||
commands.entity(entity).despawn();
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DebugPlugin;
|
||||
|
||||
impl Plugin for DebugPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(
|
||||
Startup,
|
||||
OnEnter(GameState::InGame),
|
||||
(
|
||||
spawn_debug_camera,
|
||||
setup_debug_camera.after(spawn_debug_camera),
|
||||
spawn_debug_frame,
|
||||
)
|
||||
.run_if(in_state(GameState::InGame)),
|
||||
),
|
||||
)
|
||||
.add_systems(
|
||||
Update,
|
||||
|
||||
Reference in New Issue
Block a user