Is it even possible? Random generation with premade rooms

code so far and extends player:

extends Node2D

@onready var tile_map = $"../TileMap"

var astar_grid: AStarGrid2D
var current_id_path: Array[Vector2i]
var target_position: Vector2
var is_moving: bool

func _ready():
   
   # grid based movement
   astar_grid = AStarGrid2D.new()
   astar_grid.region = tile_map.get_used_rect()
   astar_grid.cell_size = Vector2(24,24)
   astar_grid.update()
   
   #walls and walkable area
   for x in tile_map.get_used_rect().size.x:
   	for y in tile_map.get_used_rect().size.y:
   		var tile_position = Vector2i(
   			x + tile_map.get_used_rect().position.x,
   			y + tile_map.get_used_rect().position.y
   		)
   		
   		var tile_data = tile_map.get_cell_tile_data(0, tile_position)
   		
   		if tile_data == null or tile_data.get_custom_data("walkable") == false:
   			astar_grid.set_point_solid(tile_position)

func _input(event):
   
   # camera zoom
   if event.is_pressed():
   	if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
   		if $playercamera.zoom > Vector2(1,1):
   			$playercamera.zoom= $playercamera.zoom - Vector2(1,1)
   	
   	elif event.button_index == MOUSE_BUTTON_WHEEL_UP:
   		if  $playercamera .zoom < Vector2(3,3):
   			$playercamera.zoom= $playercamera.zoom + Vector2(1,1)

   
   # movement
   if event.is_action_pressed("left click") == false:
   	return
   
   var id_path
   
   if is_moving:
   	id_path = astar_grid.get_id_path(
   		tile_map.local_to_map(target_position),
   		tile_map.local_to_map(get_global_mouse_position())
   	)
   else:
   	id_path = astar_grid.get_id_path(
   		tile_map.local_to_map(global_position),
   		tile_map.local_to_map(get_global_mouse_position())
   	).slice(1)
   
   if id_path.is_empty() == false:
   	current_id_path = id_path
   


func _physics_process(_delta):
   
   #Movement physics
   if current_id_path.is_empty():
   	return
   if is_moving == false:
   	target_position = tile_map.map_to_local(current_id_path.front())
   	is_moving = true
   	
   global_position = global_position.move_toward(target_position, 4)
   
   if global_position == target_position:
   	current_id_path.pop_front()
   	
   	if current_id_path.is_empty() == false:
   		target_position = tile_map.map_to_local(current_id_path.front())
   	else:
   		is_moving = false

Question

Super novice coder here. And everything I look up I can’t figure it out.

Game: turn-based, dungeon crawler, Astargrid2d, navigation movement. random generation.

What I would like to do. Is have the game randomly generate rooms I premade and saved as individual scenes. door and start of hallway already in place. So basically, the game goes this room(scene) here this one there till it fills in the specified area. The hallways will have to use pathfinding to get the nearest route to the next room.

I would like to add complexity to it as well eventually having a certain amount of puzzle rooms and treasure rooms generate. That 4 large special areas always generate (and they are random in which one I made, e.g. maze that I made in 10 different ways. and chooses from that pool when it is generated).

the problem that I am running into now is:

  1. can’t figure out how to have astargrid2d become its own class and where/and how to have that called in what I need it called in
  2. how am I supposed to have navigation click and move movement grab all the randomly generated maps that are in a container node on the main scene.
  3. is this kind of generation even possible?