Skip to content

Commit

Permalink
Fix WinterLicht#9 bug with ownerless projectiles \n Remove remaining …
Browse files Browse the repository at this point in the history
…projectiles when their owner is removed form the game.
  • Loading branch information
JoniHintz committed Dec 26, 2018
1 parent 3fffb78 commit 6e9d95d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/combatsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ def check_projectile_collision(self):
stun_ev = events.EntityStunned(collider_ID, attack.stun)
self.event_manager.post(stun_ev)
else:
#Enemy dies
#Remove all projectiles of enemy
for attack in self.world.attacks[collider_ID]:
for projectile in attack.particles:
projectile.life = -1
ev_die = events.EntityDies(projectile.entity_ID)
self.event_manager.post(ev_die)
#Enemy dies
ev_die = events.EntityDies(collider_ID)
self.event_manager.post(ev_die)
if not collider_ID == attacks_ID:
Expand All @@ -135,6 +135,13 @@ def check_projectile_collision(self):

def remove_dead_entities(self):
for entity_ID in self.world.to_remove:
#make sure no ownerless projectile stays on the screen
if entity_ID in self.world.attacks:
for attack in self.world.attacks[entity_ID]:
for projectile in attack.particles:
projectile.life = -1
ev_die = events.EntityDies(projectile.entity_ID)
self.event_manager.post(ev_die)
self.world.destroy_entity(entity_ID)
if entity_ID == self.world.player:
self.reset_the_world = True
Expand Down Expand Up @@ -204,4 +211,4 @@ def execute_attack(self, entity_ID, attack_Nr, spawn_attack_pos=None, attack_dir
self.world.appearance[effect_ID].play_animation = True

# def handle_collision(self, collider_ID, collidee_ID):
# pass
# pass

0 comments on commit 6e9d95d

Please sign in to comment.