extends Node2D

export var _name = ""
export var respawn_time = 0
var type = "item"

func _load():
	var _texture = load("res://sprites/items/" + _name + ".png")
	$Sprite.texture = _texture

func on_pick_up():
	if respawn_time == 0: 
		queue_free()
	else:
		var coll = $Area2D/CollisionShape2D
		var timer = $spawn_time
		var anim = $anim
		
		coll.disabled = true
		$Sprite.modulate = Color("00ffffff")
		timer.wait_time = respawn_time
		timer.start()
		yield(timer, "timeout")
		anim.play("appear")
		yield(anim,"animation_finished")
		coll.disabled = false
		
func _ready():
	_load()
