extends Area2D

var name = "portal"
var transferred_list = [] 

export (NodePath) var linked_portal_path = null
export (int) var frame = 0

var active = true

func _ready():
	get_node("sprite").set_frame(frame)
	pass


func _on_portal_area_enter( area ):
	if !transferred_list.has(area):
		var linked_portal = get_node(linked_portal_path)
		linked_portal.transferred_list.append(area)
		linked_portal.active = false
		area.get_parent().set_global_pos(linked_portal.get_global_pos())
		audio.play_sound("teleporting")

func _on_portal_area_exit( area ):
	if transferred_list.has(area):
		transferred_list.erase(area)
		
