extends CharacterBody2D

@onready var animatedSprite = $AnimatedSprite2D

## Signal for when the entity dies
signal death
## Signal for when the entity gets damaged
signal damaged
## Signal for when the entity gets healed
signal healed

## The maximal possible amount of Health for the Entity
@export_range(1,100) var maxHealth = 10

## The maximal possible Speed of the Entity
@export_range(10,500) var maxSpeed = 200
## The normal Speed between Min and Max
@export_range(10,500) var normalSpeed = 100
## The lowest possible Speed of the Entity
@export_range(10,500) var minSpeed = 50

## Acceleration of the Entity
@export_range(100,500) var acceleration = 10

@onready var health = maxHealth
@onready var speed = normalSpeed
var invincible = false

func hit(damage : int) -> void:
	health -= damage
	damaged.emit()
	if health <= 0:
		health = 0
		death.emit()
	
func heal(heal : int) -> void:
	health += heal
	healed.emit()
	if health >= maxHealth:
		health = maxHealth

func resetSpeed():
	speed = normalSpeed
	
func resetHealth():
	health = health

func setSpeed(n):
	speed = n
