extends Node2D

@export var damage = 5
@export var knockback_strength = 4

func _on_area_entered(area: Area2D) -> void:
	print_debug("Mine triggered by area: %s" % area)
	if self.get_parent().is_in_group("Virus"):
		# Prevent friendly fire
		return
	if area.name != "Hurtbox":
		return
	var area_parent = area.get_parent()
	if (area_parent.is_in_group("Virus")):
		area_parent.take_hit(damage, self.position.direction_to(area.position) * 200, knockback_strength)

func _on_body_entered(body):
	if self.get_parent() == body:
		return
	body.take_hit(damage, self.position.direction_to(body.position) * 200, knockback_strength)


func _on_timer_timeout():
	self.queue_free()
