extends AbstractFood
class_name FoodMolecular

@onready var collision: Area2D = $Collision
@onready var sprite: AnimatedSprite2D = $"Collision/Sprite"

func _ready() -> void:
	sprite.play()

func _on_body_entered(body: Node2D) -> void:
	eat(body)
		
func eat(consumer: Node2D) -> void:
	print(consumer.name + " ate: ", food_name)
	consumed.emit()
	
	apply_effect(consumer)
	
	queue_free()

func apply_effect(consumer: Node2D) -> void:
	if consumer.has_method("collect_resource"):  # TODO: Define a "consumer" group instead?
		consumer.collect_resource(val)  # val is from parent (default 1), override if required
		# TODO: *Some cool effect here*
