mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added body kind argument to /airship and /ship
This commit is contained in:
@ -352,7 +352,17 @@ impl ServerChatCommand {
|
|||||||
Some(Admin),
|
Some(Admin),
|
||||||
),
|
),
|
||||||
ServerChatCommand::Airship => cmd(
|
ServerChatCommand::Airship => cmd(
|
||||||
vec![Float("destination_degrees_ccw_of_east", 90.0, Optional)],
|
vec![
|
||||||
|
Enum(
|
||||||
|
"kind",
|
||||||
|
comp::ship::ALL_AIRSHIPS
|
||||||
|
.iter()
|
||||||
|
.map(|b| format!("{b:?}"))
|
||||||
|
.collect(),
|
||||||
|
Optional,
|
||||||
|
),
|
||||||
|
Float("destination_degrees_ccw_of_east", 90.0, Optional),
|
||||||
|
],
|
||||||
"Spawns an airship",
|
"Spawns an airship",
|
||||||
Some(Admin),
|
Some(Admin),
|
||||||
),
|
),
|
||||||
@ -649,7 +659,17 @@ impl ServerChatCommand {
|
|||||||
Some(Admin),
|
Some(Admin),
|
||||||
),
|
),
|
||||||
ServerChatCommand::Ship => cmd(
|
ServerChatCommand::Ship => cmd(
|
||||||
vec![Float("destination_degrees_ccw_of_east", 90.0, Optional)],
|
vec![
|
||||||
|
Enum(
|
||||||
|
"kind",
|
||||||
|
comp::ship::ALL_SHIPS
|
||||||
|
.iter()
|
||||||
|
.map(|b| format!("{b:?}"))
|
||||||
|
.collect(),
|
||||||
|
Optional,
|
||||||
|
),
|
||||||
|
Float("destination_degrees_ccw_of_east", 90.0, Optional),
|
||||||
|
],
|
||||||
"Spawns a ship",
|
"Spawns a ship",
|
||||||
Some(Admin),
|
Some(Admin),
|
||||||
),
|
),
|
||||||
|
@ -1639,15 +1639,21 @@ fn handle_spawn_airship(
|
|||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
_action: &ServerChatCommand,
|
_action: &ServerChatCommand,
|
||||||
) -> CmdResult<()> {
|
) -> CmdResult<()> {
|
||||||
let angle = parse_cmd_args!(args, f32);
|
let (body_name, angle) = parse_cmd_args!(args, String, f32);
|
||||||
let mut pos = position(server, target, "target")?;
|
let mut pos = position(server, target, "target")?;
|
||||||
pos.0.z += 50.0;
|
pos.0.z += 50.0;
|
||||||
const DESTINATION_RADIUS: f32 = 2000.0;
|
const DESTINATION_RADIUS: f32 = 2000.0;
|
||||||
let angle = angle.map(|a| a * std::f32::consts::PI / 180.0);
|
let angle = angle.map(|a| a * std::f32::consts::PI / 180.0);
|
||||||
let dir = angle.map(|a| Vec3::new(a.cos(), a.sin(), 0.0));
|
let dir = angle.map(|a| Vec3::new(a.cos(), a.sin(), 0.0));
|
||||||
let destination = dir.map(|dir| pos.0 + dir * DESTINATION_RADIUS + Vec3::new(0.0, 0.0, 200.0));
|
let destination = dir.map(|dir| pos.0 + dir * DESTINATION_RADIUS + Vec3::new(0.0, 0.0, 200.0));
|
||||||
let mut rng = thread_rng();
|
let ship = if let Some(body_name) = body_name {
|
||||||
let ship = comp::ship::Body::random_airship_with(&mut rng);
|
*comp::ship::ALL_AIRSHIPS
|
||||||
|
.iter()
|
||||||
|
.find(|body| format!("{body:?}") == body_name)
|
||||||
|
.ok_or_else(|| format!("No such airship '{body_name}'."))?
|
||||||
|
} else {
|
||||||
|
comp::ship::Body::random_airship_with(&mut thread_rng())
|
||||||
|
};
|
||||||
let ori = comp::Ori::from(common::util::Dir::new(dir.unwrap_or(Vec3::unit_y())));
|
let ori = comp::Ori::from(common::util::Dir::new(dir.unwrap_or(Vec3::unit_y())));
|
||||||
let mut builder = server
|
let mut builder = server
|
||||||
.state
|
.state
|
||||||
@ -1677,15 +1683,21 @@ fn handle_spawn_ship(
|
|||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
_action: &ServerChatCommand,
|
_action: &ServerChatCommand,
|
||||||
) -> CmdResult<()> {
|
) -> CmdResult<()> {
|
||||||
let angle = parse_cmd_args!(args, f32);
|
let (body_name, angle) = parse_cmd_args!(args, String, f32);
|
||||||
let mut pos = position(server, target, "target")?;
|
let mut pos = position(server, target, "target")?;
|
||||||
pos.0.z += 2.0;
|
pos.0.z += 2.0;
|
||||||
const DESTINATION_RADIUS: f32 = 2000.0;
|
const DESTINATION_RADIUS: f32 = 2000.0;
|
||||||
let angle = angle.map(|a| a * std::f32::consts::PI / 180.0);
|
let angle = angle.map(|a| a * std::f32::consts::PI / 180.0);
|
||||||
let dir = angle.map(|a| Vec3::new(a.cos(), a.sin(), 0.0));
|
let dir = angle.map(|a| Vec3::new(a.cos(), a.sin(), 0.0));
|
||||||
let destination = dir.map(|dir| pos.0 + dir * DESTINATION_RADIUS + Vec3::new(0.0, 0.0, 200.0));
|
let destination = dir.map(|dir| pos.0 + dir * DESTINATION_RADIUS + Vec3::new(0.0, 0.0, 200.0));
|
||||||
let mut rng = thread_rng();
|
let ship = if let Some(body_name) = body_name {
|
||||||
let ship = comp::ship::Body::random_ship_with(&mut rng);
|
*comp::ship::ALL_SHIPS
|
||||||
|
.iter()
|
||||||
|
.find(|body| format!("{body:?}") == body_name)
|
||||||
|
.ok_or_else(|| format!("No such airship '{body_name}'."))?
|
||||||
|
} else {
|
||||||
|
comp::ship::Body::random_airship_with(&mut thread_rng())
|
||||||
|
};
|
||||||
let ori = comp::Ori::from(common::util::Dir::new(dir.unwrap_or(Vec3::unit_y())));
|
let ori = comp::Ori::from(common::util::Dir::new(dir.unwrap_or(Vec3::unit_y())));
|
||||||
let mut builder = server
|
let mut builder = server
|
||||||
.state
|
.state
|
||||||
|
Reference in New Issue
Block a user