extends CharacterBody2D

signal hit
@export var speed: float = 800
var direction: Vector2 = Vector2.ZERO
var element = "water"

func _process(delta: float) -> void:
	velocity = direction * speed
	move_and_slide()
	if element == "wind":
		$AnimatedSprite2D.frame = 0
		$wind/CollisionShape2D.disabled = false
		$fire/CollisionShape2D.disabled = true
		$water/CollisionShape2D.disabled = true
		print_debug("wind_on")
	if element == "fire":
		$AnimatedSprite2D.frame = 1
		$fire/CollisionShape2D.disabled = false
		$water/CollisionShape2D.disabled = true
		$wind/CollisionShape2D.disabled = true
		print_debug("fire_on")
	if element == "water":
		$AnimatedSprite2D.frame = 2
		$water/CollisionShape2D.disabled = false
		$fire/CollisionShape2D.disabled = true
		$wind/CollisionShape2D.disabled = true
		print_debug("water_on")


func _on_fire_area_entered(area: Area2D) -> void:
	if area.is_in_group("fire_enemy"):
		area.remove_from_group("enemy")
		queue_free()


func _on_water_area_entered(area: Area2D) -> void:
	if area.is_in_group("water_enemy"):
		area.remove_from_group("enemy")
		queue_free()


func _on_wind_area_entered(area: Area2D) -> void:
	if area.is_in_group("wind_enemy"): 
		area.remove_from_group("enemy")
		queue_free()
