Hwo to check if a player made room is enclosed and detect inside area?

if you feel like it is too much text jump into the text in bold

so i’m making a game where you create your own arena to battle with others, but i wanted to be able to check if the floor is enclosed with walls that are in a vector 3 list, and have it in a way that the player can create holes in the middle of his own field. and then the floor is automatically generated by going from the minZ to the maxZ and trough all the X cords.

so far what i have is a empty game object that moves by the X/Z axis, with the arrows, and on left mouse click one wall is created, and when the player hits the “K” key, it starts the floor creation.

on the floor creation my current approach is to have the empty game object to go to the lowest Z and the highest X outside the total area and then go trough all the blocks inside the area, and if it hits a wall, it will create floor until it its another wall, that way it can find the holes, but my problem is when it goes to the border walls, because the hole detection system interferes with it.

what i want is to make a way to detect the inside tileable spots so i can create floors in that part
and also
i want to discover the border walls, so that i can make the hole system not mess with it.
PRINTS

this print is before the floor creation and after the wall creation (walls are created symmetrically and every new Z layer that is created by player is created also in the border)


this print is after the floor creation, with the hole detection system on the right and the result on the left, (both sides are symmetrical, hole = true means that it will be created a hole, hole = false it means that it will create floorTiles instead)


C# CODE

y is the y that the empty GameObject had in the start of the script

line 54 is the WallCreation
line 116 is the FloorCreation

C# code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class test : MonoBehaviour {



    public float tileSize;
    public float waitTime;

    public GameObject[] pfTiles;
    public GameObject[] pfOres;
    public GameObject[] pfWalls;

    public List<Vector3> Walls;
    public List<Vector3> Tiles;



    private GameObject iWall;
    private GameObject iTile;

    private int tCount;
    private int wCount;
    private int stage;
    private float y;


    public GameObject NextBlockChecker;

    void Start()
    {
        stage = 0;

        wCount = 0;
        tCount = 0;

        y = transform.position.y;
    }

    void Update()
    {

        if (stage == 0)
        {
            int wall = Random.Range(0, pfWalls.Length);

            WallCreation(wall);
        }
    }


    void WallCreation(int wallIndex)
    {
        if (stage == 0)
        {
            if (transform.position.x > 0)
            {
                if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    transform.position = new Vector3(transform.position.x, y, transform.position.z - tileSize);
                }
                if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    transform.position = new Vector3(transform.position.x + tileSize, y, transform.position.z);
                }
                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    transform.position = new Vector3(transform.position.x - tileSize, y, transform.position.z);
                }
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    transform.position = new Vector3(transform.position.x, y, transform.position.z + tileSize);
                }
            }
            else
            {
                while (transform.position.x <= 0)
                {
                    transform.position = new Vector3(transform.position.x + tileSize, transform.position.y, transform.position.z);
                }
            }

            if (Input.GetButtonDown("Fire1") && !Walls.Contains(transform.position))
            {
                iWall = Instantiate(pfWalls[wallIndex], transform.position, transform.rotation);
                wCount++;
                iWall.name = "Wall # " + wCount;
                Walls.Add(iWall.transform.position);

                iWall = Instantiate(pfWalls[wallIndex], new Vector3(-transform.position.x, transform.position.y, transform.position.z), transform.rotation);
                wCount++;
                iWall.name = "Wall # " + wCount;
                Walls.Add(iWall.transform.position);

                iWall = Instantiate(pfWalls[wallIndex], new Vector3(0, y, transform.position.z), transform.rotation);
                wCount++;
                iWall.name = "Wall # " + wCount;
                Walls.Add(iWall.transform.position);
            }
        }

        if (Input.GetKeyDown(KeyCode.K) && stage == 0)
        {
            stage++;

            Debug.Log(stage);


            StartCoroutine(FloorCreation());
        }
    }


    IEnumerator FloorCreation()
    {

        float minZ = 0;
        float minX = 0;
        float maxZ = 0;
        float maxX = 0;

        for (int i = 0; i < Walls.Count; i++)
        {
            if (Walls[i].z < minZ)
            {
                minZ = Walls[i].z; //-10
            }

            if (Walls[i].z > maxZ) //20
            {
                maxZ = Walls[i].z;
            }

            if (Walls[i].x > maxX)
            {
                maxX = Walls[i].x;
            }

            if (Walls[i].x < minX)
            {
                minX = Walls[i].x;
            }
        }

        Debug.Log(maxX + "," + minX);

        Debug.Log(maxZ + "," + minZ);

        float area = ((tileSize + maxX) - (minX - tileSize)) * ((tileSize + maxZ) - (minZ - tileSize));

        Debug.Log("area = " + area);

        transform.position = new Vector3(maxX + tileSize, y, minZ - tileSize);
        bool hole = true;

        for (float f = minZ + tileSize; f < area; f = f + tileSize)
        {
            int tile = Random.Range(0, pfTiles.Length);


            if (transform.position.z > maxZ + tileSize)
            {
                transform.position = new Vector3(transform.position.x - tileSize, y, minZ - tileSize);

                hole = true;
            }

            if (transform.position.z < maxZ + tileSize)
            {
                if (Walls.Contains(transform.position))
                {
                    hole = !hole;
                }

                if (hole == false && !Walls.Contains(transform.position))
                {
                    Debug.Log("instantiating Wall");
                    iTile = Instantiate(pfTiles[tile],transform.position , transform.rotation);
                    tCount++;
                    iTile.name = "Tile #" + tCount;
                    Tiles.Add(transform.position);
                }
            }

            yield return new WaitForSeconds(waitTime);

            transform.position = new Vector3(transform.position.x, y, transform.position.z + tileSize);
        }

        StopCoroutine(FloorCreation());
      
        yield return 0;
    }
}

If you’re looking for all the floor tiles that are enclosed by walls then you could use some kind of fill algorithm.