extends Area2D

export var id = 0

func _ready():
	connect("area_entered",self, '_on_Area2D2_area_entered')
	connect("area_exited",self, '_on_Area2D2_area_exited')
	var sprite = Sprite.new()
	sprite.texture = preload('res://ui/button.png')
	sprite.position = Vector2(32,32)
	add_child(sprite)

func _on_Area2D2_area_entered(area):
	if get_node('../../../..').lock == []:
		print()
		print(str(id) + ' ' + area.get_parent().name + ' ' + get_parent().name)
		get_node('../../../..').buff1 = (area.get_parent().id)
		get_node('../../../..').buff2 = (id)
		modulate = Color(0.5,0.5,0.5)
		area.get_parent().posswitch = false
		area.get_parent().initpos2 = global_position
		get_node('../../../..').lock.append(self)
	pass # Replace with function body.


func _on_Area2D2_area_exited(area):
	modulate = Color(1.0,1.0,1.0)
	area.get_parent().posswitch = true
	area.get_parent().initpos2 = global_position
	get_node('../../../..').lock.erase(self)
	pass # Replace with function body.
