mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix characterstate in movement.rs, not phys.rs
This commit is contained in:
parent
808467c616
commit
799c73d43a
@ -26,7 +26,7 @@ pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {
|
||||
dispatch_builder.add(phys::Sys, PHYS_SYS, &[CONTROLLER_SYS]);
|
||||
dispatch_builder.add(movement::Sys, MOVEMENT_SYS, &[PHYS_SYS]);
|
||||
dispatch_builder.add(combat::Sys, COMBAT_SYS, &[CONTROLLER_SYS]);
|
||||
dispatch_builder.add(animation::Sys, ANIMATION_SYS, &[CONTROLLER_SYS]);
|
||||
dispatch_builder.add(animation::Sys, ANIMATION_SYS, &[MOVEMENT_SYS]);
|
||||
dispatch_builder.add(stats::Sys, STATS_SYS, &[COMBAT_SYS]);
|
||||
dispatch_builder.add(cleanup::Sys, CLEANUP_SYS, &[STATS_SYS, ANIMATION_SYS]);
|
||||
}
|
||||
|
@ -131,6 +131,14 @@ impl<'a> System<'a> for Sys {
|
||||
.unwrap_or_default();
|
||||
}
|
||||
}
|
||||
|
||||
if physics.on_ground && (character.movement == Jump || character.movement == Glide) {
|
||||
character.movement = Stand;
|
||||
}
|
||||
|
||||
if !physics.on_ground && (character.movement == Stand || character.movement == Run) {
|
||||
character.movement = Jump;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use {
|
||||
crate::{
|
||||
comp::{Body, CharacterState, MovementState::*, Ori, PhysicsState, Pos, Scale, Stats, Vel},
|
||||
comp::{Body, MovementState::*, Ori, PhysicsState, Pos, Scale, Stats, Vel},
|
||||
event::{Event, EventBus},
|
||||
state::DeltaTime,
|
||||
terrain::TerrainMap,
|
||||
@ -37,7 +37,6 @@ impl<'a> System<'a> for Sys {
|
||||
Read<'a, EventBus>,
|
||||
ReadStorage<'a, Scale>,
|
||||
ReadStorage<'a, Body>,
|
||||
WriteStorage<'a, CharacterState>,
|
||||
WriteStorage<'a, PhysicsState>,
|
||||
WriteStorage<'a, Pos>,
|
||||
WriteStorage<'a, Vel>,
|
||||
@ -53,7 +52,6 @@ impl<'a> System<'a> for Sys {
|
||||
event_bus,
|
||||
scales,
|
||||
bodies,
|
||||
mut character_states,
|
||||
mut physics_states,
|
||||
mut positions,
|
||||
mut velocities,
|
||||
@ -73,7 +71,6 @@ impl<'a> System<'a> for Sys {
|
||||
)
|
||||
.join()
|
||||
{
|
||||
let mut character_state = character_states.get(entity).cloned().unwrap_or_default();
|
||||
let mut physics_state = physics_states.get(entity).cloned().unwrap_or_default();
|
||||
let scale = scale.map(|s| s.0).unwrap_or(1.0);
|
||||
|
||||
@ -215,7 +212,6 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
if !was_on_ground {
|
||||
event_emitter.emit(Event::LandOnGround { entity, vel: vel.0 });
|
||||
character_state.movement = Stand;
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,10 +259,6 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
if on_ground {
|
||||
physics_state.on_ground = true;
|
||||
|
||||
if !was_on_ground {
|
||||
character_state.movement = Stand;
|
||||
}
|
||||
// If the space below us is free, then "snap" to the ground
|
||||
} else if collision_with(pos.0 - Vec3::unit_z() * 1.05, near_iter.clone())
|
||||
&& vel.0.z < 0.0
|
||||
@ -275,11 +267,8 @@ impl<'a> System<'a> for Sys {
|
||||
{
|
||||
pos.0.z = (pos.0.z - 0.05).floor();
|
||||
physics_state.on_ground = true;
|
||||
} else if was_on_ground {
|
||||
character_state.movement = Jump;
|
||||
}
|
||||
|
||||
let _ = character_states.insert(entity, character_state);
|
||||
let _ = physics_states.insert(entity, physics_state);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user