def _die(self): """Character death sequence. Stop all the character's tasks, play death animation and plan the character object clearing. """ if self._team.hold_together: self.health = 1 return False if not Shooter._die(self): return False Unit._die(self) if base.common_ctrl.chosen_char == self: # noqa: F821 base.common_ctrl.deselect(clear_resting=False) # noqa: F821 self._health_bar.hide_health() self._stop_tasks( "_reduce_energy", "_get_well", "_infect", "_stop_stimul", "_gain_energy" ) base.char_gui.destroy_char_button(self.id) # noqa: F821 self._team.delete_relations(self.id) LerpAnimInterval(self.model, 0.3, "stand_and_aim", "die").start() LerpAnimInterval(self.model, 0.3, self._current_anim, "die").start() self.model.hprInterval(1, (self.current_part.angle, 0, 0)).start() self.model.play("die") self._die_snd.play() taskMgr.doMethodLater(3, self._hide, self.id + "_hide") # noqa: F821
def _die(self): """Make this enemy unit die. Play death sequence of movements and sounds, stop all the tasks for this enemy, plan clearing. Returns: bool: True, if the unit dies for the first time. """ if not Unit._die(self): return False self.model.setColorScale(1, 1, 1, 1) self._stop_tasks("_float_move") self._move_int.pause() self.model.play("die") if self.id in base.world.enemy.active_units: # noqa: F821 base.world.enemy.active_units.pop(self.id) # noqa: F821 if self.current_part: self.current_part.enemies.remove(self) self._explode() self.transport_snd.stop() self._y_positions.append(self._y_pos) base.add_head(self.class_data["class"].__name__) # noqa: F821 return True