mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix formatting
This commit is contained in:
parent
cca41a3333
commit
f726d755b7
@ -2,8 +2,8 @@ use crate::assets;
|
||||
use lazy_static::lazy_static;
|
||||
use rand::seq::SliceRandom;
|
||||
use serde_json;
|
||||
use std::sync::Arc;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum NpcKind {
|
||||
@ -30,7 +30,7 @@ impl FromStr for NpcKind {
|
||||
"humanoid" => Ok(NpcKind::Humanoid),
|
||||
"wolf" => Ok(NpcKind::Wolf),
|
||||
"pig" => Ok(NpcKind::Pig),
|
||||
_ => Err(())
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +218,9 @@ fn handle_spawn(server: &mut Server, entity: EcsEntity, args: String, action: &C
|
||||
// Make sure the amount is either not provided or a valid value
|
||||
let opt_amount: Option<u32> = if let Some(amount) = opt_amount {
|
||||
amount.parse().ok()
|
||||
} else { Some(1) };
|
||||
} else {
|
||||
Some(1)
|
||||
};
|
||||
|
||||
match (opt_agent, opt_id, opt_amount) {
|
||||
(Some(agent), Some(id), Some(amount)) => {
|
||||
@ -231,23 +233,20 @@ fn handle_spawn(server: &mut Server, entity: EcsEntity, args: String, action: &C
|
||||
let body = kind_to_body(id);
|
||||
for _ in 0..amount {
|
||||
server
|
||||
.create_npc(
|
||||
pos,
|
||||
get_npc_name(id),
|
||||
body,
|
||||
)
|
||||
.create_npc(pos, get_npc_name(id), body)
|
||||
.with(agent)
|
||||
.build();
|
||||
}
|
||||
server
|
||||
.clients
|
||||
.notify(entity, ServerMsg::Chat(format!("Spawned {} entities", amount).to_owned()));
|
||||
server.clients.notify(
|
||||
entity,
|
||||
ServerMsg::Chat(format!("Spawned {} entities", amount).to_owned()),
|
||||
);
|
||||
}
|
||||
None => server
|
||||
.clients
|
||||
.notify(entity, ServerMsg::Chat("You have no position!".to_owned())),
|
||||
}
|
||||
},
|
||||
}
|
||||
_ => server
|
||||
.clients
|
||||
.notify(entity, ServerMsg::Chat(String::from(action.help_string))),
|
||||
@ -265,12 +264,12 @@ fn handle_help(server: &mut Server, entity: EcsEntity, _args: String, _action: &
|
||||
fn alignment_to_agent(alignment: &str, target: EcsEntity) -> Option<comp::Agent> {
|
||||
match alignment {
|
||||
"hostile" => Some(comp::Agent::Enemy { target: None }),
|
||||
"friendly" => Some ( comp::Agent::Pet {
|
||||
target,
|
||||
offset: Vec2::zero() }
|
||||
),
|
||||
"friendly" => Some(comp::Agent::Pet {
|
||||
target,
|
||||
offset: Vec2::zero(),
|
||||
}),
|
||||
// passive?
|
||||
_ => None
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user