extends Node

@export var max_health: int = 10
@export var invulnerable_time = 1
var invulnerable = false

signal no_health

@onready var health: int = max_health



func hurt() -> void:
	if invulnerable or health <= 0:
		return
	invulnerable = true
	health -= 1
	print ("health: " + str(health))
	if health == 0:
		emit_signal("no_health")
	await get_tree().create_timer(invulnerable_time).timeout
	invulnerable = false
	
func kill() -> void:
	if health <= 0:
		return
	health = 0
	emit_signal("no_health")
