Don't remove player using combat system
This commit is contained in:
parent
bcb66b8983
commit
8b763db714
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user