Check that the room is closed

How to check that the room is closed? For example, the player creates his room of prefabs, and when the blocks are closed - creates room.

![alt text]
[1]

I’ve thought about this a lot recently because I need to implement a similar functionality.

My current plan is to create a function that fires a Raycast in 8 directions (up down left right diagonals). If the ray reaches it’s limiting distance and does not collide with a wall return false for the room being closed.

I imagine this function would be iterated on every tile of the room prefab.