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) => { ClientGeneral::ControlEvent(event) => {
if presence.kind.controlling_char() { if presence.kind.controlling_char() && let Some(controller) = controller {
// Skip respawn if client entity is alive // Skip respawn if client entity is alive
if let ControlEvent::Respawn = event { let skip_respawn = matches!(event, ControlEvent::Respawn)
if healths.get(entity).map_or(true, |h| !h.is_dead) { && healths.get(entity).map_or(true, |h| !h.is_dead);
//Todo: comment why return!
return Ok(()); if !skip_respawn {
}
}
if let Some(controller) = controller {
controller.push_event(event); controller.push_event(event);
} }
} }