Better item throwing

This commit is contained in:
Joshua Barretto
2019-07-29 18:23:26 +01:00
parent 39fc1d6b71
commit 2d0569c3d9

View File

@ -23,6 +23,7 @@ use common::{
vol::Vox, vol::Vox,
}; };
use log::debug; use log::debug;
use rand::Rng;
use specs::{join::Join, world::EntityBuilder as EcsEntityBuilder, Builder, Entity as EcsEntity}; use specs::{join::Join, world::EntityBuilder as EcsEntityBuilder, Builder, Entity as EcsEntity};
use std::{ use std::{
collections::HashSet, collections::HashSet,
@ -726,10 +727,13 @@ impl Server {
} }
for (pos, ori, item) in dropped_items { for (pos, ori, item) in dropped_items {
let vel = ori.0.normalized() * 5.0
+ Vec3::unit_z() * 10.0
+ Vec3::<f32>::zero().map(|_| rand::thread_rng().gen::<f32>() - 0.5) * 4.0;
self.create_object(Default::default(), comp::object::Body::Pouch) self.create_object(Default::default(), comp::object::Body::Pouch)
.with(comp::Pos(pos.0 + Vec3::unit_z() * 1.0)) .with(comp::Pos(pos.0 + Vec3::unit_z() * 0.25))
.with(item) .with(item)
.with(comp::Vel(ori.0.normalized() * 2.0 + Vec3::unit_z() * 2.0)) .with(comp::Vel(vel))
.build(); .build();
} }