extends Area2D

onready var anim_player: AnimationPlayer = get_node("AnimationPlayer")
onready var level_state := $"%LevelState"

export var currencyValue: = 1

func _on_body_entered(_body: Node) -> void:
	if $AudioStreamPlayer.playing:
		return
	level_state.set_currency(level_state.get_currency() + currencyValue)
	$CollisionShape2D.disabled = true
	set_deferred("monitoring", false)
	$AudioStreamPlayer.play()
	anim_player.play("fade_out")

func collected() -> void:
	queue_free()
