mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'Spawn_Command_Fix' into 'master'
fix spawn command placement See merge request veloren/veloren!288
This commit is contained in:
commit
78240d64df
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2766,6 +2766,7 @@ version = "0.2.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"rand 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"scan_fmt 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"scan_fmt 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -17,3 +17,4 @@ scan_fmt = "0.1.3"
|
|||||||
ron = "0.5.1"
|
ron = "0.5.1"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
|
rand = "0.5.6"
|
||||||
|
@ -9,6 +9,7 @@ use common::{
|
|||||||
npc::{get_npc_name, NpcKind},
|
npc::{get_npc_name, NpcKind},
|
||||||
state::TimeOfDay,
|
state::TimeOfDay,
|
||||||
};
|
};
|
||||||
|
use rand::Rng;
|
||||||
use specs::{Builder, Entity as EcsEntity, Join};
|
use specs::{Builder, Entity as EcsEntity, Join};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
@ -314,12 +315,18 @@ fn handle_spawn(server: &mut Server, entity: EcsEntity, args: String, action: &C
|
|||||||
match (opt_agent, opt_id, opt_amount) {
|
match (opt_agent, opt_id, opt_amount) {
|
||||||
(Some(agent), Some(id), Some(amount)) => {
|
(Some(agent), Some(id), Some(amount)) => {
|
||||||
match server.state.read_component_cloned::<comp::Pos>(entity) {
|
match server.state.read_component_cloned::<comp::Pos>(entity) {
|
||||||
Some(mut pos) => {
|
Some(pos) => {
|
||||||
pos.0.x += 1.0; // Temp fix TODO: Solve NaN issue with positions of pets
|
|
||||||
for _ in 0..amount {
|
for _ in 0..amount {
|
||||||
|
let vel = Vec3::new(
|
||||||
|
rand::thread_rng().gen_range(-2.0, 3.0),
|
||||||
|
rand::thread_rng().gen_range(-2.0, 3.0),
|
||||||
|
10.0,
|
||||||
|
);
|
||||||
|
|
||||||
let body = kind_to_body(id);
|
let body = kind_to_body(id);
|
||||||
server
|
server
|
||||||
.create_npc(pos, get_npc_name(id), body)
|
.create_npc(pos, get_npc_name(id), body)
|
||||||
|
.with(comp::Vel(vel))
|
||||||
.with(agent)
|
.with(agent)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user