Don't remove player using combat system

This commit is contained in:
Daniel Lynn 2021-07-08 22:54:44 -05:00
parent bcb66b8983
commit 8b763db714

View File

@ -12,6 +12,12 @@ pub fn combat(ecs: &mut SubWorld, commands: &mut CommandBuffer) {
.collect();
victims.iter().for_each(|(message, victim)| {
let is_player = ecs
.entry_ref(*victim)
.unwrap()
.get_component::<Player>()
.is_ok();
if let Ok(mut health) = ecs
.entry_mut(*victim)
.unwrap()
@ -19,7 +25,7 @@ pub fn combat(ecs: &mut SubWorld, commands: &mut CommandBuffer) {
{
println!("Health before attack: {}", health.current);
health.current -= 1;
if health.current < 1 {
if health.current < 1 && !is_player {
commands.remove(*victim);
}
println!("Health after attack: {}", health.current);