mirror of
https://github.com/kristoferssolo/maze-ascension.git
synced 2025-10-21 19:20:34 +00:00
refactor: remove MazePluginLoaded resource
This commit is contained in:
parent
101626cf3d
commit
3709bfa58d
@ -1,7 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
floor::components::{CurrentFloor, Floor},
|
floor::components::{CurrentFloor, Floor},
|
||||||
maze::{components::MazeConfig, events::RespawnMaze, GlobalMazeConfig, MazePluginLoaded},
|
maze::{components::MazeConfig, events::RespawnMaze, GlobalMazeConfig},
|
||||||
player::events::RespawnPlayer,
|
player::events::RespawnPlayer,
|
||||||
|
screens::Screen,
|
||||||
};
|
};
|
||||||
use bevy::{prelude::*, window::PrimaryWindow};
|
use bevy::{prelude::*, window::PrimaryWindow};
|
||||||
use bevy_egui::{
|
use bevy_egui::{
|
||||||
@ -13,8 +14,11 @@ use rand::{thread_rng, Rng};
|
|||||||
use std::ops::RangeInclusive;
|
use std::ops::RangeInclusive;
|
||||||
|
|
||||||
pub fn maze_controls_ui(world: &mut World) {
|
pub fn maze_controls_ui(world: &mut World) {
|
||||||
if world.get_resource::<MazePluginLoaded>().is_none() {
|
if let Some(state) = world.get_resource::<State<Screen>>() {
|
||||||
return;
|
// Check if the current state is NOT Gameplay
|
||||||
|
if *state.get() != Screen::Gameplay {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let Ok(egui_context) = world
|
let Ok(egui_context) = world
|
||||||
|
|||||||
@ -2,7 +2,7 @@ mod despawn;
|
|||||||
mod movement;
|
mod movement;
|
||||||
mod spawn;
|
mod spawn;
|
||||||
|
|
||||||
use crate::maze::MazePluginLoaded;
|
use crate::screens::Screen;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use despawn::despawn_floor;
|
use despawn::despawn_floor;
|
||||||
use movement::{handle_floor_transition_events, move_floors};
|
use movement::{handle_floor_transition_events, move_floors};
|
||||||
@ -18,6 +18,6 @@ pub(super) fn plugin(app: &mut App) {
|
|||||||
move_floors,
|
move_floors,
|
||||||
)
|
)
|
||||||
.chain()
|
.chain()
|
||||||
.run_if(resource_exists::<MazePluginLoaded>),
|
.run_if(in_state(Screen::Gameplay)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ pub mod triggers;
|
|||||||
use bevy::{ecs::system::RunSystemOnce, prelude::*};
|
use bevy::{ecs::system::RunSystemOnce, prelude::*};
|
||||||
use components::HexMaze;
|
use components::HexMaze;
|
||||||
use events::{DespawnMaze, RespawnMaze, SpawnMaze};
|
use events::{DespawnMaze, RespawnMaze, SpawnMaze};
|
||||||
pub use resources::{GlobalMazeConfig, MazePluginLoaded};
|
pub use resources::GlobalMazeConfig;
|
||||||
|
|
||||||
pub(super) fn plugin(app: &mut App) {
|
pub(super) fn plugin(app: &mut App) {
|
||||||
app.init_resource::<GlobalMazeConfig>()
|
app.init_resource::<GlobalMazeConfig>()
|
||||||
@ -22,5 +22,4 @@ pub(super) fn plugin(app: &mut App) {
|
|||||||
|
|
||||||
pub fn spawn_level_command(world: &mut World) {
|
pub fn spawn_level_command(world: &mut World) {
|
||||||
let _ = world.run_system_once(systems::setup::setup);
|
let _ = world.run_system_once(systems::setup::setup);
|
||||||
world.insert_resource(MazePluginLoaded);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,5 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
#[derive(Debug, Default, Reflect, Resource)]
|
|
||||||
#[reflect(Resource)]
|
|
||||||
pub struct MazePluginLoaded;
|
|
||||||
|
|
||||||
#[derive(Debug, Reflect, Resource, Clone)]
|
#[derive(Debug, Reflect, Resource, Clone)]
|
||||||
#[reflect(Resource)]
|
#[reflect(Resource)]
|
||||||
pub struct GlobalMazeConfig {
|
pub struct GlobalMazeConfig {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ use crate::{
|
|||||||
events::SpawnMaze,
|
events::SpawnMaze,
|
||||||
resources::GlobalMazeConfig,
|
resources::GlobalMazeConfig,
|
||||||
},
|
},
|
||||||
|
screens::Screen,
|
||||||
theme::palette::rose_pine::RosePineDawn,
|
theme::palette::rose_pine::RosePineDawn,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -53,6 +54,7 @@ pub(crate) fn spawn_maze(
|
|||||||
config.clone(),
|
config.clone(),
|
||||||
Transform::from_translation(Vec3::ZERO.with_y(y_offset)),
|
Transform::from_translation(Vec3::ZERO.with_y(y_offset)),
|
||||||
Visibility::Visible,
|
Visibility::Visible,
|
||||||
|
StateScoped(Screen::Gameplay),
|
||||||
))
|
))
|
||||||
.insert_if(CurrentFloor, || *floor == 1)
|
.insert_if(CurrentFloor, || *floor == 1)
|
||||||
.id();
|
.id();
|
||||||
|
|||||||
@ -3,7 +3,7 @@ mod movement;
|
|||||||
pub mod setup;
|
pub mod setup;
|
||||||
mod vertical_transition;
|
mod vertical_transition;
|
||||||
|
|
||||||
use crate::maze::MazePluginLoaded;
|
use crate::screens::Screen;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use input::player_input;
|
use input::player_input;
|
||||||
use movement::player_movement;
|
use movement::player_movement;
|
||||||
@ -17,6 +17,6 @@ pub(super) fn plugin(app: &mut App) {
|
|||||||
player_movement.after(player_input),
|
player_movement.after(player_input),
|
||||||
handle_floor_transition,
|
handle_floor_transition,
|
||||||
)
|
)
|
||||||
.run_if(resource_exists::<MazePluginLoaded>),
|
.run_if(in_state(Screen::Gameplay)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ use crate::{
|
|||||||
components::{CurrentPosition, Player},
|
components::{CurrentPosition, Player},
|
||||||
events::SpawnPlayer,
|
events::SpawnPlayer,
|
||||||
},
|
},
|
||||||
|
screens::Screen,
|
||||||
};
|
};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
@ -34,5 +35,6 @@ pub(super) fn spawn_player(
|
|||||||
Mesh3d(meshes.add(generate_pill_mesh(player_radius, player_height / 2.))),
|
Mesh3d(meshes.add(generate_pill_mesh(player_radius, player_height / 2.))),
|
||||||
MeshMaterial3d(materials.add(blue_material())),
|
MeshMaterial3d(materials.add(blue_material())),
|
||||||
Transform::from_xyz(start_pos.x, y_offset, start_pos.y),
|
Transform::from_xyz(start_pos.x, y_offset, start_pos.y),
|
||||||
|
StateScoped(Screen::Gameplay),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user