@tool
extends Sprite2D
@export_group("Travel settings")
@export_file("*.tscn") var NextScene:String
@export_enum("LEFT","RIGHT","UP","DOWN") var Travel :int
@export var Spawn_Position:Vector2 = Vector2(0,0) #TODO: Extrapoler la position suivante en fonction de l'enum Travel
var NextSceneLoaded:Resource

func _on_area_2d_area_entered(area):
	if(area):
		if(MapManager and MapManager.player == area.get_parent() and (MapManager.player.Traveling == false) ):
			MapManager.player.Traveling = true
			print("enter door",area)
			if not NextScene.is_empty():
				NextSceneLoaded = load(NextScene)
				if (NextSceneLoaded != null):
					MapManager.transition_to_scene(NextSceneLoaded,Spawn_Position,Travel)
				else:
					printerr("error loading ",NextScene)
			

			
			

func _ready():
	if not NextScene.is_empty():
		NextSceneLoaded = load(NextScene)
		print(NextSceneLoaded)
