47 lines
1.3 KiB
Rust
Executable File
47 lines
1.3 KiB
Rust
Executable File
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 executing console commands (the functionality layer).
|
|
/// All command handler systems are added to this set
|
|
Commands,
|
|
}
|
|
|
|
/// 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.run_if(have_commands));
|
|
}
|
|
}
|