mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added surface traction factor
This commit is contained in:
parent
6e97e3179d
commit
17e7879777
@ -307,7 +307,7 @@ fn basic_move(data: &JoinData<'_>, update: &mut StateUpdate, efficiency: f32) {
|
||||
|
||||
let accel = if let Some(block) = data.physics.on_ground {
|
||||
// FRIC_GROUND temporarily used to normalize things around expected values
|
||||
data.body.base_accel() * block.get_friction() / FRIC_GROUND
|
||||
data.body.base_accel() * block.get_traction() * block.get_friction() / FRIC_GROUND
|
||||
} else {
|
||||
data.body.air_accel()
|
||||
} * efficiency;
|
||||
@ -354,7 +354,7 @@ pub fn handle_forced_movement(
|
||||
let strength = strength * data.stats.move_speed_modifier * data.stats.friction_modifier;
|
||||
if let Some(accel) = data.physics.on_ground.map(|block| {
|
||||
// FRIC_GROUND temporarily used to normalize things around expected values
|
||||
data.body.base_accel() * block.get_friction() / FRIC_GROUND
|
||||
data.body.base_accel() * block.get_traction() * block.get_friction() / FRIC_GROUND
|
||||
}) {
|
||||
update.vel.0 += Vec2::broadcast(data.dt.0)
|
||||
* accel
|
||||
|
@ -312,7 +312,8 @@ impl Block {
|
||||
.unwrap_or(1.0)
|
||||
}
|
||||
|
||||
// Used to calculate surface friction when walking. Currently has no units.
|
||||
/// Get the friction constant used to calculate surface friction when
|
||||
/// walking/climbing. Currently has no units.
|
||||
#[inline]
|
||||
pub fn get_friction(&self) -> f32 {
|
||||
match self.kind() {
|
||||
@ -321,6 +322,19 @@ impl Block {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the traction permitted by this block as a proportion of the friction
|
||||
/// applied.
|
||||
///
|
||||
/// 1.0 = default, 0.0 = completely inhibits movement, > 1.0 = potential for
|
||||
/// infinite acceleration (in a vacuum).
|
||||
#[inline]
|
||||
pub fn get_traction(&self) -> f32 {
|
||||
match self.kind() {
|
||||
BlockKind::Snow => 0.8,
|
||||
_ => 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn kind(&self) -> BlockKind { self.kind }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user