mirror of
https://github.com/kristoferssolo/maze-ascension.git
synced 2025-10-21 19:20:34 +00:00
refactor: use private plugins
This commit is contained in:
parent
80bc027477
commit
c694281e88
789
Cargo.lock
generated
789
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,32 @@
|
|||||||
mod plugin;
|
|
||||||
mod ui;
|
mod ui;
|
||||||
|
|
||||||
pub use plugin::DevToolsPlugin;
|
use crate::screens::Screen;
|
||||||
|
use bevy::{
|
||||||
|
dev_tools::{
|
||||||
|
states::log_transitions,
|
||||||
|
ui_debug_overlay::{DebugUiPlugin, UiDebugOptions},
|
||||||
|
},
|
||||||
|
input::common_conditions::input_just_pressed,
|
||||||
|
prelude::*,
|
||||||
|
};
|
||||||
|
use bevy_egui::EguiPlugin;
|
||||||
|
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
||||||
|
use ui::maze_controls_ui;
|
||||||
|
|
||||||
|
pub(super) fn plugin(app: &mut App) {
|
||||||
|
app.add_systems(Update, log_transitions::<Screen>)
|
||||||
|
.add_plugins(EguiPlugin)
|
||||||
|
.add_plugins(WorldInspectorPlugin::new())
|
||||||
|
.add_plugins(DebugUiPlugin)
|
||||||
|
.add_systems(Update, maze_controls_ui)
|
||||||
|
.add_systems(
|
||||||
|
Update,
|
||||||
|
toggle_debug_ui.run_if(input_just_pressed(TOGGLE_KEY)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TOGGLE_KEY: KeyCode = KeyCode::Backquote;
|
||||||
|
|
||||||
|
fn toggle_debug_ui(mut options: ResMut<UiDebugOptions>) {
|
||||||
|
options.toggle();
|
||||||
|
}
|
||||||
|
|||||||
@ -1,36 +0,0 @@
|
|||||||
use crate::screens::Screen;
|
|
||||||
use bevy::{
|
|
||||||
dev_tools::{
|
|
||||||
states::log_transitions,
|
|
||||||
ui_debug_overlay::{DebugUiPlugin, UiDebugOptions},
|
|
||||||
},
|
|
||||||
input::common_conditions::input_just_pressed,
|
|
||||||
prelude::*,
|
|
||||||
};
|
|
||||||
use bevy_egui::EguiPlugin;
|
|
||||||
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
|
||||||
|
|
||||||
use super::ui::maze_controls_ui;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct DevToolsPlugin;
|
|
||||||
|
|
||||||
impl Plugin for DevToolsPlugin {
|
|
||||||
fn build(&self, app: &mut App) {
|
|
||||||
app.add_systems(Update, log_transitions::<Screen>)
|
|
||||||
.add_plugins(EguiPlugin)
|
|
||||||
.add_plugins(WorldInspectorPlugin::new())
|
|
||||||
.add_plugins(DebugUiPlugin)
|
|
||||||
.add_systems(Update, maze_controls_ui)
|
|
||||||
.add_systems(
|
|
||||||
Update,
|
|
||||||
toggle_debug_ui.run_if(input_just_pressed(TOGGLE_KEY)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const TOGGLE_KEY: KeyCode = KeyCode::Backquote;
|
|
||||||
|
|
||||||
fn toggle_debug_ui(mut options: ResMut<UiDebugOptions>) {
|
|
||||||
options.toggle();
|
|
||||||
}
|
|
||||||
@ -3,6 +3,7 @@ pub mod audio;
|
|||||||
#[cfg(feature = "dev")]
|
#[cfg(feature = "dev")]
|
||||||
mod dev_tools;
|
mod dev_tools;
|
||||||
mod maze;
|
mod maze;
|
||||||
|
mod player;
|
||||||
mod screens;
|
mod screens;
|
||||||
mod theme;
|
mod theme;
|
||||||
|
|
||||||
@ -57,14 +58,15 @@ impl Plugin for AppPlugin {
|
|||||||
// Add other plugins.
|
// Add other plugins.
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
asset_tracking::plugin,
|
asset_tracking::plugin,
|
||||||
maze::plugin::MazePlugin,
|
|
||||||
screens::plugin,
|
screens::plugin,
|
||||||
theme::plugin,
|
theme::plugin,
|
||||||
|
maze::plugin,
|
||||||
|
player::plugin,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Enable dev tools for dev builds.
|
// Enable dev tools for dev builds.
|
||||||
#[cfg(feature = "dev")]
|
#[cfg(feature = "dev")]
|
||||||
app.add_plugins(dev_tools::DevToolsPlugin);
|
app.add_plugins(dev_tools::plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,21 @@
|
|||||||
use bevy::{ecs::world::Command, prelude::*};
|
use bevy::{ecs::system::RunSystemOnce, prelude::*};
|
||||||
use plugin::MazePlugin;
|
use events::RecreateMazeEvent;
|
||||||
mod assets;
|
mod assets;
|
||||||
mod components;
|
mod components;
|
||||||
pub mod events;
|
pub mod events;
|
||||||
pub mod plugin;
|
|
||||||
mod resources;
|
mod resources;
|
||||||
mod systems;
|
mod systems;
|
||||||
|
|
||||||
pub use resources::{MazeConfig, MazePluginLoaded};
|
pub use resources::{MazeConfig, MazePluginLoaded};
|
||||||
|
use systems::recreation::handle_maze_recreation_event;
|
||||||
|
|
||||||
|
pub(super) fn plugin(app: &mut App) {
|
||||||
|
app.init_resource::<MazeConfig>()
|
||||||
|
.add_event::<RecreateMazeEvent>()
|
||||||
|
.add_systems(Update, handle_maze_recreation_event);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn spawn_maze(world: &mut World) {
|
pub fn spawn_maze(world: &mut World) {
|
||||||
MazePlugin.apply(world);
|
world.insert_resource(MazePluginLoaded);
|
||||||
|
world.run_system_once(systems::setup::setup);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
use std::num::TryFromIntError;
|
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use hexx::{Hex, HexLayout, HexOrientation};
|
use hexx::{Hex, HexLayout, HexOrientation};
|
||||||
use rand::{rngs::StdRng, thread_rng, Rng, SeedableRng};
|
use rand::{rngs::StdRng, thread_rng, Rng, SeedableRng};
|
||||||
|
use std::num::TryFromIntError;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Debug, Default, Reflect, Resource)]
|
#[derive(Debug, Default, Reflect, Resource)]
|
||||||
|
|||||||
5
src/player/components.rs
Normal file
5
src/player/components.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Component, Debug, Clone, Copy, PartialEq, Eq, Default, Reflect)]
|
||||||
|
#[reflect(Component)]
|
||||||
|
pub struct Player;
|
||||||
9
src/player/mod.rs
Normal file
9
src/player/mod.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
mod components;
|
||||||
|
mod systems;
|
||||||
|
|
||||||
|
use bevy::prelude::*;
|
||||||
|
use components::Player;
|
||||||
|
|
||||||
|
pub(super) fn plugin(app: &mut App) {
|
||||||
|
app.register_type::<Player>().add_plugins(());
|
||||||
|
}
|
||||||
21
src/player/systems.rs
Normal file
21
src/player/systems.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
use super::components::Player;
|
||||||
|
use crate::maze::{events::RecreateMazeEvent, MazeConfig};
|
||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
pub fn spawn_player(
|
||||||
|
mut commands: Commands,
|
||||||
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
|
maze_config: Res<MazeConfig>,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn respawn_player(
|
||||||
|
mut commands: Commands,
|
||||||
|
player_query: Query<Entity, With<Player>>,
|
||||||
|
mut recreation_events: EventReader<RecreateMazeEvent>,
|
||||||
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
|
maze_config: Res<MazeConfig>,
|
||||||
|
) {
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user