Basic (frame-dependent!) client-side lerp of wind velocity

This commit is contained in:
Ludvig Böklin 2021-06-03 19:11:06 +02:00
parent ba12d784ed
commit dc491eead5

View File

@ -1984,21 +1984,26 @@ impl Client {
rich.economy = Some(economy); rich.economy = Some(economy);
} }
}, },
ServerGeneral::WindUpdate(vel) => { ServerGeneral::WindUpdate(v) => {
println!("Windupdate {}", vel); println!("Windupdate {}", v);
let player_entity = self.entity(); let player_entity = self.entity();
self.state self.state
.ecs_mut() .ecs_mut()
.write_storage::<PhysicsState>() .write_storage::<PhysicsState>()
.get_mut(player_entity) .get_mut(player_entity)
.map(|physics_state| { .map(|physics_state| {
physics_state.in_fluid = physics_state if let Fluid::Air { vel, elevation } =
.in_fluid physics_state.in_fluid.unwrap_or_default()
.filter(|fluid| matches!(fluid, Fluid::Water { .. })) {
.or(Some(Fluid::Air { physics_state.in_fluid = Some(Fluid::Air {
elevation: 0.0, vel: Vel(Lerp::lerp(
vel: Vel(vel), vel.0,
})); v,
0.2,
)),
elevation,
});
}
}); });
}, },
_ => unreachable!("Not a in_game message"), _ => unreachable!("Not a in_game message"),