Merge branch 'fix-moving' into 'master'

Fix moving after death (again)

See merge request veloren/veloren!192

Former-commit-id: a8390094833976a009af7a1e044ff6ee9e10c4ff
This commit is contained in:
Joshua Barretto 2019-05-28 19:01:30 +00:00
commit e53cd7a15a
2 changed files with 19 additions and 4 deletions

View File

@ -58,15 +58,21 @@ impl<'a> System<'a> for Sys {
mut force_updates,
): Self::SystemData,
) {
for (entity, pos, control, mut dir, mut vel) in (
for (entity, pos, control, stats, mut dir, mut vel) in (
&entities,
&positions,
&controls,
&stats,
&mut directions,
&mut velocities,
)
.join()
{
// Disable while dead TODO: Replace with client states
if stats.is_dead {
continue;
}
// Handle held-down control
let on_ground = terrain
.get((pos.0 - Vec3::unit_z() * 0.1).map(|e| e.floor() as i32))

View File

@ -1,5 +1,8 @@
use crate::{
comp::phys::{Pos, Vel},
comp::{
phys::{Pos, Vel},
Stats,
},
state::DeltaTime,
terrain::TerrainMap,
vol::{ReadVol, Vox},
@ -16,12 +19,18 @@ impl<'a> System<'a> for Sys {
type SystemData = (
ReadExpect<'a, TerrainMap>,
Read<'a, DeltaTime>,
ReadStorage<'a, Stats>,
WriteStorage<'a, Pos>,
WriteStorage<'a, Vel>,
);
fn run(&mut self, (terrain, dt, mut positions, mut velocities): Self::SystemData) {
for (pos, vel) in (&mut positions, &mut velocities).join() {
fn run(&mut self, (terrain, dt, stats, mut positions, mut velocities): Self::SystemData) {
for (stats, pos, vel) in (&stats, &mut positions, &mut velocities).join() {
// Disable while dead TODO: Replace with client states
if stats.is_dead {
continue;
}
// Gravity
vel.0.z = (vel.0.z - GRAVITY * dt.0).max(-50.0);