extends TileMap

const objects = {
	"Door": preload("res://Actors/Objects/Door/Door.tscn")
}

func _ready():
	for cell in get_used_cells():
		var id = get_cellv(cell)
		var name = tile_set.tile_get_name(id)
		if objects.has(name):
			var obj = objects[name].instance() as Node2D
			add_child(obj)
			obj.transform.origin = map_to_world(cell)
		else:
			print("Placed object tile ", name, " at ", cell, " but has no object associated!")
		set_cellv(cell, -1)
