Simplify code

This commit is contained in:
timokoesters 2019-08-25 22:40:59 +02:00
parent c4879307af
commit a7747fe965
No known key found for this signature in database
GPG Key ID: CD80BE9AAEE78097

View File

@ -52,8 +52,6 @@ impl<'a> System<'a> for Sys {
for (entity, uid, pos, ori, controller) in
(&entities, &uids, &positions, &orientations, &controllers).join()
{
let mut todo_end = false;
// Go through all other entities
if let Some(Attack { time_left, applied }) =
&mut character_states.get(entity).map(|c| c.action)
@ -108,7 +106,11 @@ impl<'a> System<'a> for Sys {
*applied = true;
if *time_left == Duration::default() {
todo_end = true;
if let Some(character) = &mut character_states.get_mut(entity) {
character.action = Wield {
time_left: Duration::default(),
};
}
} else {
*time_left = time_left
.checked_sub(Duration::from_secs_f32(dt.0))
@ -116,13 +118,6 @@ impl<'a> System<'a> for Sys {
}
}
}
if todo_end {
if let Some(character) = &mut character_states.get_mut(entity) {
character.action = Wield {
time_left: Duration::default(),
};
}
}
if let Some(Wield { time_left }) =
&mut character_states.get_mut(entity).map(|c| &mut c.action)