mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix rolling for the player
This commit is contained in:
parent
d84c07c1cb
commit
77a48c61a1
@ -286,17 +286,22 @@ impl Client {
|
||||
{
|
||||
let ecs = self.state.ecs_mut();
|
||||
for (entity, _) in (&ecs.entities(), &ecs.read_storage::<comp::Body>()).join() {
|
||||
let mut last_character_state =
|
||||
let mut last_character_states =
|
||||
ecs.write_storage::<comp::Last<comp::CharacterState>>();
|
||||
if let Some(client_character_state) =
|
||||
ecs.read_storage::<comp::CharacterState>().get(entity)
|
||||
{
|
||||
if last_character_state
|
||||
if last_character_states
|
||||
.get(entity)
|
||||
.map(|&l| l != *client_character_state)
|
||||
.map(|&l| {
|
||||
std::mem::discriminant(&l.0.movement)
|
||||
!= std::mem::discriminant(&client_character_state.movement)
|
||||
|| std::mem::discriminant(&l.0.action)
|
||||
!= std::mem::discriminant(&client_character_state.action)
|
||||
})
|
||||
.unwrap_or(true)
|
||||
{
|
||||
let _ = last_character_state
|
||||
let _ = last_character_states
|
||||
.insert(entity, comp::Last(*client_character_state));
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,3 @@ pub struct Last<C: Component + PartialEq>(pub C);
|
||||
impl<C: Component + Send + Sync + PartialEq> Component for Last<C> {
|
||||
type Storage = VecStorage<Self>;
|
||||
}
|
||||
|
||||
impl<C: Component + PartialEq> PartialEq<C> for Last<C> {
|
||||
fn eq(&self, other: &C) -> bool {
|
||||
self.0 == *other
|
||||
}
|
||||
}
|
||||
|
@ -1105,7 +1105,7 @@ impl Server {
|
||||
if let Some(client_pos) = ecs.read_storage::<comp::Pos>().get(entity) {
|
||||
if last_pos
|
||||
.get(entity)
|
||||
.map(|&l| l != *client_pos)
|
||||
.map(|&l| l.0 != *client_pos)
|
||||
.unwrap_or(true)
|
||||
{
|
||||
let _ = last_pos.insert(entity, comp::Last(*client_pos));
|
||||
@ -1123,7 +1123,7 @@ impl Server {
|
||||
if let Some(client_vel) = ecs.read_storage::<comp::Vel>().get(entity) {
|
||||
if last_vel
|
||||
.get(entity)
|
||||
.map(|&l| l != *client_vel)
|
||||
.map(|&l| l.0 != *client_vel)
|
||||
.unwrap_or(true)
|
||||
{
|
||||
let _ = last_vel.insert(entity, comp::Last(*client_vel));
|
||||
@ -1141,7 +1141,7 @@ impl Server {
|
||||
if let Some(client_ori) = ecs.read_storage::<comp::Ori>().get(entity) {
|
||||
if last_ori
|
||||
.get(entity)
|
||||
.map(|&l| l != *client_ori)
|
||||
.map(|&l| l.0 != *client_ori)
|
||||
.unwrap_or(true)
|
||||
{
|
||||
let _ = last_ori.insert(entity, comp::Last(*client_ori));
|
||||
@ -1161,7 +1161,13 @@ impl Server {
|
||||
{
|
||||
if last_character_state
|
||||
.get(entity)
|
||||
.map(|&l| l != *client_character_state)
|
||||
.map(|&l| {
|
||||
// Check if enum item is the same without looking at the inner data
|
||||
std::mem::discriminant(&l.0.movement)
|
||||
!= std::mem::discriminant(&client_character_state.movement)
|
||||
|| std::mem::discriminant(&l.0.action)
|
||||
!= std::mem::discriminant(&client_character_state.action)
|
||||
})
|
||||
.unwrap_or(true)
|
||||
{
|
||||
let _ =
|
||||
|
@ -691,10 +691,15 @@ impl FigureMgr {
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
if last_character.0.movement != character.movement {
|
||||
if std::mem::discriminant(&last_character.0.movement)
|
||||
!= std::mem::discriminant(&character.movement)
|
||||
{
|
||||
state.last_movement_change = Instant::now();
|
||||
}
|
||||
if last_character.0.action != character.action {
|
||||
|
||||
if std::mem::discriminant(&last_character.0.action)
|
||||
!= std::mem::discriminant(&character.action)
|
||||
{
|
||||
state.last_action_change = Instant::now();
|
||||
}
|
||||
|
||||
@ -702,7 +707,7 @@ impl FigureMgr {
|
||||
state.last_movement_change.elapsed().as_secs_f64();
|
||||
let time_since_action_change = state.last_action_change.elapsed().as_secs_f64();
|
||||
|
||||
let target_base = match dbg!(&character).movement {
|
||||
let target_base = match &character.movement {
|
||||
Stand => anim::character::StandAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(),
|
||||
time,
|
||||
|
Loading…
Reference in New Issue
Block a user