class_name HealthComponent extends Node signal health_changed(new_value: int, max_value: int) signal died @export var max_health: int = 1 var current_health: int func _ready() -> void: current_health = max_health func take_damage(amount: int) -> void: if current_health <= 0: return current_health = max(current_health - amount, 0) health_changed.emit(current_health, max_health) if current_health == 0: died.emit() func kill() -> void: if current_health <= 0: return current_health = 0 health_changed.emit(current_health, max_health) died.emit() func heal(amount: int) -> void: if current_health <= 0: return current_health = min(current_health + amount, max_health) health_changed.emit(current_health, max_health)