Initial Commit
This commit is contained in:
62
crates/guardian_commands/src/lib.rs
Normal file
62
crates/guardian_commands/src/lib.rs
Normal file
@@ -0,0 +1,62 @@
|
||||
pub mod call;
|
||||
|
||||
use bevy::prelude::*;
|
||||
// pub use bevy_console_derive::ConsoleCommand;
|
||||
// use bevy_egui::EguiPlugin;
|
||||
|
||||
// use crate::commands::clear::{clear_command, ClearCommand};
|
||||
// use crate::commands::exit::{exit_command, ExitCommand};
|
||||
// use crate::commands::help::{help_command, HelpCommand};
|
||||
pub use crate::console::{
|
||||
AddConsoleCommand, Command, ConsoleCommand, ConsoleCommandEntered, ConsoleConfiguration,
|
||||
NamedCommand, PrintConsoleLine,
|
||||
};
|
||||
// pub use color::{Style, StyledStr};
|
||||
|
||||
// use crate::console::ConsoleState;
|
||||
|
||||
// mod color;
|
||||
// mod commands;
|
||||
mod console;
|
||||
mod parser;
|
||||
// mod macros;
|
||||
|
||||
/// Console plugin.
|
||||
pub struct CommandsPlugin;
|
||||
|
||||
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
|
||||
/// The SystemSet for console/command related systems
|
||||
pub enum ConsoleSet {
|
||||
/// Systems operating the console UI (the input layer)
|
||||
ConsoleIO,
|
||||
|
||||
/// Systems executing console commands (the functionality layer).
|
||||
/// All command handler systems are added to this set
|
||||
Commands,
|
||||
|
||||
/// Systems running after command systems, which depend on the fact commands have executed beforehand (the output layer).
|
||||
/// For example a system which makes use of [`PrintConsoleLine`] events should be placed in this set to be able to receive
|
||||
/// New lines to print in the same frame
|
||||
PostCommands,
|
||||
}
|
||||
|
||||
/// Run condition which does not run any command systems if no command was entered
|
||||
fn have_commands(commands: EventReader<ConsoleCommandEntered>) -> bool {
|
||||
!commands.is_empty()
|
||||
}
|
||||
|
||||
impl Plugin for CommandsPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<ConsoleConfiguration>()
|
||||
.add_event::<ConsoleCommandEntered>()
|
||||
.configure_sets(
|
||||
Update,
|
||||
(
|
||||
ConsoleSet::Commands
|
||||
.after(ConsoleSet::ConsoleIO)
|
||||
.run_if(have_commands),
|
||||
ConsoleSet::PostCommands.after(ConsoleSet::Commands),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user