Fix GlideWield overriding state changes

This commit is contained in:
Ludvig Böklin 2021-06-22 11:20:40 +02:00
parent 2165fc7d2e
commit eddc967462

View File

@ -32,29 +32,32 @@ impl CharacterBehavior for Data {
handle_dodge_input(data, &mut update); handle_dodge_input(data, &mut update);
handle_wield(data, &mut update); handle_wield(data, &mut update);
let mut glider = self.0; // If still in this state, do the things
glider.ori = glider.ori.slerped_towards( if matches!(update.character, CharacterState::GlideWield(_)) {
Ori::from(data.inputs.look_dir) let mut glider = self.0;
.yawed_towards(data.ori.look_dir()) glider.ori = glider.ori.slerped_towards(
.pitched_up(inline_tweak::tweak!(0.5)), Ori::from(data.inputs.look_dir)
inline_tweak::tweak!(5.0) * data.dt.0, .yawed_towards(data.ori.look_dir())
); .pitched_up(inline_tweak::tweak!(0.5)),
inline_tweak::tweak!(5.0) * data.dt.0,
);
// If not on the ground while wielding glider enter gliding state // If not on the ground while wielding glider enter gliding state
update.character = if !data.physics.on_ground { update.character = if !data.physics.on_ground {
CharacterState::Glide(glide::Data::new(glider)) CharacterState::Glide(glide::Data::new(glider))
} else if data } else if data
.physics .physics
.in_liquid() .in_liquid()
.map(|depth| depth > 0.5) .map(|depth| depth > 0.5)
.unwrap_or(false) .unwrap_or(false)
{ {
CharacterState::Idle CharacterState::Idle
} else if data.inventory.equipped(EquipSlot::Glider).is_none() { } else if data.inventory.equipped(EquipSlot::Glider).is_none() {
CharacterState::Idle CharacterState::Idle
} else { } else {
CharacterState::GlideWield(Self(glider)) CharacterState::GlideWield(Self(glider))
}; };
}
update update
} }