Set dash direction based on look_dir

This commit is contained in:
timokoesters 2020-03-19 18:33:10 +01:00
parent e16bb66fb3
commit 83be1226ef
2 changed files with 10 additions and 2 deletions

View File

@ -51,8 +51,7 @@ impl CharacterAbility {
.is_ok()
},
CharacterAbility::DashMelee { .. } => {
data.physics.on_ground
&& !data.physics.in_fluid
!data.physics.in_fluid
&& update
.energy
.try_change_by(-300, EnergySource::Ability)
@ -122,6 +121,7 @@ impl From<&CharacterAbility> for CharacterState {
recover_duration,
base_damage,
} => CharacterState::DashMelee(dash_melee::Data {
initialize: true,
exhausted: false,
buildup_duration: *buildup_duration,
recover_duration: *recover_duration,

View File

@ -18,6 +18,7 @@ pub struct Data {
pub base_damage: u32,
/// Whether the attack can deal more damage
pub exhausted: bool,
pub initialize: bool,
}
impl CharacterBehavior for Data {
@ -32,6 +33,10 @@ impl CharacterBehavior for Data {
server_events: VecDeque::new(),
};
if self.initialize {
update.vel.0 = data.inputs.look_dir * 20.0;
}
if self.buildup_duration != Duration::default() && data.physics.touch_entity.is_none() {
// Build up (this will move you forward)
update.vel.0 = Vec3::new(0.0, 0.0, update.vel.0.z)
@ -49,6 +54,7 @@ impl CharacterBehavior for Data {
recover_duration: self.recover_duration,
base_damage: self.base_damage,
exhausted: false,
initialize: false,
});
} else if !self.exhausted {
// Hit attempt
@ -64,6 +70,7 @@ impl CharacterBehavior for Data {
recover_duration: self.recover_duration,
base_damage: self.base_damage,
exhausted: true,
initialize: false,
});
} else if self.recover_duration != Duration::default() {
// Recovery
@ -75,6 +82,7 @@ impl CharacterBehavior for Data {
.unwrap_or_default(),
base_damage: self.base_damage,
exhausted: true,
initialize: false,
});
} else {
// Done