You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.2 KiB
50 lines
1.2 KiB
mod chat;
|
|
mod commands;
|
|
mod config;
|
|
mod db;
|
|
mod game;
|
|
mod player;
|
|
mod world;
|
|
|
|
use config::CONFIG;
|
|
use once_cell::sync::Lazy;
|
|
use valence::bevy_ecs;
|
|
use valence::prelude::*;
|
|
|
|
#[derive(States, Default, Debug, Hash, PartialEq, Eq, Clone)]
|
|
pub enum GameState {
|
|
Started,
|
|
#[default]
|
|
Stopped,
|
|
}
|
|
|
|
fn main() {
|
|
Lazy::force(&CONFIG);
|
|
|
|
tracing_subscriber::fmt::init();
|
|
|
|
App::new()
|
|
.add_state::<GameState>()
|
|
.add_plugin(ServerPlugin::new(()))
|
|
.add_startup_systems((world::setup, db::setup))
|
|
.add_system(player::init_clients)
|
|
.add_systems(
|
|
(
|
|
default_event_handler,
|
|
player::break_block,
|
|
commands::command_executor,
|
|
chat::handle_messages,
|
|
)
|
|
.in_schedule(EventLoopSchedule),
|
|
)
|
|
.add_systems((
|
|
despawn_disconnected_clients,
|
|
player::death,
|
|
game::auto_stop.run_if(|| !CONFIG.no_auto_stop.unwrap_or(false)),
|
|
))
|
|
.add_system(game::start_game.in_schedule(OnEnter(GameState::Started)))
|
|
.add_system(game::stop_game.in_schedule(OnExit(GameState::Started)))
|
|
.add_systems(PlayerList::default_systems())
|
|
.run();
|
|
}
|