Limited entity spawning to 10

This commit is contained in:
Joshua Barretto 2019-08-04 11:30:05 +01:00
parent ff114a83b5
commit 767ced8fe7

View File

@ -335,9 +335,10 @@ fn handle_spawn(server: &mut Server, entity: EcsEntity, args: String, action: &C
(Some(opt_align), Some(id), opt_amount) => { (Some(opt_align), Some(id), opt_amount) => {
if let Some(agent) = alignment_to_agent(&opt_align, entity) { if let Some(agent) = alignment_to_agent(&opt_align, entity) {
let amount = opt_amount let amount = opt_amount
.map_or(Some(1), |a| a.parse().ok()) .and_then(|a| a.parse().ok())
.and_then(|a| if a > 0 { Some(a) } else { None }) .filter(|x| *x > 0)
.unwrap(); .unwrap_or(1)
.min(10);
match server.state.read_component_cloned::<comp::Pos>(entity) { match server.state.read_component_cloned::<comp::Pos>(entity) {
Some(pos) => { Some(pos) => {