extends CharacterBody2D

@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
@onready var time_to_finish_hit: Timer = $TimeToFinishHit
@onready var hitbox: Area2D = $Hitbox

func _ready() -> void:
	hitbox.monitoring = false

func play_anim_run():
	animated_sprite.play("idle")

func play_anim_idle():
	animated_sprite.play("idle")
	
func hit():
	animated_sprite.play("hit")
	time_to_finish_hit.start()
	hitbox.monitoring = true

func _on_trigger_hit_body_entered(body: Node2D) -> void:
	if body.name == "Player":
		hit()

func _on_time_to_finish_hit_timeout() -> void:
	play_anim_idle()
	hitbox.monitoring = false
