Avoid using return for skipping respawn events

This commit is contained in:
Imbris 2023-06-02 20:30:43 -04:00
parent 62abed1eec
commit 996f58ebd2

View File

@ -102,15 +102,12 @@ impl Sys {
}
},
ClientGeneral::ControlEvent(event) => {
if presence.kind.controlling_char() {
if presence.kind.controlling_char() && let Some(controller) = controller {
// Skip respawn if client entity is alive
if let ControlEvent::Respawn = event {
if healths.get(entity).map_or(true, |h| !h.is_dead) {
//Todo: comment why return!
return Ok(());
}
}
if let Some(controller) = controller {
let skip_respawn = matches!(event, ControlEvent::Respawn)
&& healths.get(entity).map_or(true, |h| !h.is_dead);
if !skip_respawn {
controller.push_event(event);
}
}