use std::env::set_current_dir;
use crate::Task;
use crate::util::{cargo, workspace_dir};
#[derive(Default)]
pub struct RunServerNative;
impl Task for RunServerNative {
fn name(&self) -> &'static str {
"unified:server"
}
fn help(&self) -> &'static str {
"Run the server (native)"
}
fn run(&self, args: Vec<String>) {
let args = if args.is_empty() {
"-b [::]:5151 -r 60 -c 10".to_string()
} else {
args.join(" ")
};
set_current_dir(workspace_dir().join("crates/unified/")).unwrap();
cargo(format!("run -F platform_native -F target_net_server -F target_server -F dev --package starkingdoms -- server {args}"));
}
}
#[derive(Default)]
pub struct RunClientNative;
impl Task for RunClientNative {
fn name(&self) -> &'static str {
"unified:client"
}
fn help(&self) -> &'static str {
"Run the client (native)"
}
fn run(&self, args: Vec<String>) {
let args = if args.is_empty() {
"-s ws://[::1]:5151".to_string()
} else {
args.join(" ")
};
set_current_dir(workspace_dir().join("crates/unified/")).unwrap();
cargo(format!("run -F platform_native -F target_client -F target_net_client -F dev --package starkingdoms -- client {args}"));
}
}
#[derive(Default)]
pub struct RunListenServerNative;
impl Task for RunListenServerNative {
fn name(&self) -> &'static str {
"unified:listenserver"
}
fn help(&self) -> &'static str {
"Run the server and client (native)"
}
fn run(&self, args: Vec<String>) {
let args = if args.is_empty() {
"-b [::]:5151 -r 60 -c 10 --with-client".to_string()
} else {
args.join(" ")
};
set_current_dir(workspace_dir().join("crates/unified/")).unwrap();
cargo(format!("run -F platform_native -F target_net_server -F target_server -F target_client -F dev --package starkingdoms -- server {args}"));
}
}
#[derive(Default)]
pub struct RunSingleplayerNative;
impl Task for RunSingleplayerNative {
fn name(&self) -> &'static str {
"unified:singleplayer"
}
fn help(&self) -> &'static str {
"Run a singleplayer game with networking disabled (native)"
}
fn run(&self, args: Vec<String>) {
let args = if args.is_empty() {
"-r 60 -c 10 --with-client".to_string()
} else {
args.join(" ")
};
set_current_dir(workspace_dir().join("crates/unified/")).unwrap();
cargo(format!("run -F target_server -F target_client -F dev --package starkingdoms -- server {args}"));
}
}