extends Actor



func _on_attack_state_exited():
	$Hitbox_Component.set_hitbox(false)


func _on_attack_frame_reached(state_name, animation_name, frame_number):
	if frame_number == 2 and animation_name == 'attack':
		print("I quit attacking.")
		$Hitbox_Component.set_hitbox(true)
	if frame_number == 0 and animation_name == 'attack':
		print("I attack now!")
		$Hitbox_Component.set_hitbox(false)

func enemyHit(damage):
	print("oh! You got me for ", damage)
	#$Hurtbox_Component.set_hurtbox(false)
	$Health_Component.take_damage(damage)
	if $Health_Component.health > 0:
		movement_state_machine.change_state($movement_state_machine/hurt)
	#yield( get_tree().create_timer(2 + $movement_state_machine/hurt.timeout_seconds), "timeout")
	#$Hurtbox_Component.set_hurtbox(true)



func _on_Health_Component_health_depleted():
	movement_state_machine.change_state($movement_state_machine/die)
	yield( get_tree().create_timer(movement_state_machine.current_state.timeout_seconds), "timeout")
	queue_free()
