2024-05-03 17:05:16 -05:00
|
|
|
use shipyard::{IntoWorkload, Workload, WorkloadModificator, World};
|
2024-04-25 05:30:25 -05:00
|
|
|
use std::{thread, time::Duration};
|
|
|
|
|
|
|
|
mod util;
|
|
|
|
mod config;
|
|
|
|
mod server;
|
|
|
|
mod client;
|
|
|
|
mod world;
|
|
|
|
mod auth;
|
|
|
|
|
|
|
|
use config::read_config;
|
|
|
|
use server::{bind_server, update_server, log_server_errors};
|
|
|
|
use client::{init_client_maps, on_client_disconnect, sync_client_positions};
|
|
|
|
use auth::authenticate_players;
|
|
|
|
use world::{update_world, init_world};
|
|
|
|
|
|
|
|
fn initialize() -> Workload {
|
|
|
|
(
|
|
|
|
read_config,
|
|
|
|
bind_server,
|
|
|
|
init_client_maps,
|
2024-05-03 17:05:16 -05:00
|
|
|
init_world.after_all(read_config),
|
2024-04-25 05:30:25 -05:00
|
|
|
).into_workload()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn update() -> Workload {
|
|
|
|
(
|
|
|
|
update_server,
|
|
|
|
(
|
|
|
|
log_server_errors,
|
|
|
|
authenticate_players,
|
|
|
|
update_world,
|
|
|
|
sync_client_positions,
|
|
|
|
on_client_disconnect,
|
|
|
|
).into_workload()
|
|
|
|
).into_sequential_workload()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
kubi_logging::init();
|
|
|
|
let world = World::new();
|
|
|
|
world.add_workload(initialize);
|
|
|
|
world.add_workload(update);
|
|
|
|
world.run_workload(initialize).unwrap();
|
|
|
|
log::info!("The server is now running");
|
|
|
|
loop {
|
|
|
|
world.run_workload(update).unwrap();
|
|
|
|
thread::sleep(Duration::from_millis(16));
|
|
|
|
}
|
|
|
|
}
|