Skip to content

Commit

Permalink
end action function
Browse files Browse the repository at this point in the history
  • Loading branch information
cdsupina committed Jan 6, 2021
1 parent f2f489a commit 9a94aeb
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions src/components/abilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,6 @@ pub enum AbilityType {

impl AbilityType {
fn execute(&mut self, input: &Read<InputHandler<StringBindings>>) -> bool {
/*
match self {
Self::BarrelRoll {
mut is_active_left,
mut is_active_right,
speed,
steel_barrel,
} => {
let barrel_left = input.action_is_down("barrel_left").unwrap();
let barrel_right = input.action_is_down("barrel_right").unwrap();
if barrel_left {
is_active_left = true;
return true;
} else if barrel_right {
is_active_right = true;
return true;
}
}
Self::Swap => {}
Self::None => {}
};
false
*/
let mut result = false;
*self = match std::mem::replace(self, AbilityType::None) {
Self::BarrelRoll {
Expand Down Expand Up @@ -74,6 +50,23 @@ impl AbilityType {
};
result
}

fn end_action(&mut self) {
*self = match std::mem::replace(self, AbilityType::None) {
Self::BarrelRoll {
is_active_left: _,
is_active_right: _,
speed,
steel_barrel,
} => Self::BarrelRoll {
is_active_left: false,
is_active_right: false,
speed,
steel_barrel,
},
_ => Self::None,
};
}
}

#[derive(Clone, Serialize, Deserialize, Debug)]
Expand Down Expand Up @@ -118,7 +111,7 @@ impl AbilityComponent {

if self.action_timer <= 0.0 {
self.is_active = false;
//self.ability_type.end_action()
self.ability_type.end_action()
}
}

Expand Down

0 comments on commit 9a94aeb

Please sign in to comment.