void GenerateBuildingRooms(ArrayGrid <MapElement> map, Vector2Int buildingPos, Vector2Int roomSize) { Rect building = new Rect(); Rect smaller = new Rect(); buildingPos.x++; buildingPos.y++; building.position = buildingPos; building.size = roomSize; smaller = building; smaller.min = smaller.min + Vector2Int.one; smaller.max = smaller.max - Vector2Int.one; map.FillArea(building, defaultBuildingWallElement); map.FillArea(smaller, defaultRoomElement); AddRecursiveRooms(map, defaultBuildingWallElement, new Vector2Int(innerBuildingRoomSize, innerBuildingRoomSize), smaller); // add a door leading out (improve to lead to nearest road) if (GameRNG.CoinToss()) { if (GameRNG.CoinToss()) { int x = (int)building.min.x + GameRNG.Rand((int)roomSize.x - 2) + 1; int y = (int)building.min.y; map[x, y] = defaultDoorElement; } else { int x = (int)building.min.x + GameRNG.Rand((int)roomSize.x - 2) + 1; int y = (int)building.max.y - 1; map[x, y] = defaultDoorElement; } } else { if (GameRNG.CoinToss()) { int x = (int)building.min.x; int y = (int)building.min.y + GameRNG.Rand((int)roomSize.y - 2) + 1; map[x, y] = defaultDoorElement; } else { int x = (int)building.max.x - 1; int y = (int)building.min.y + GameRNG.Rand((int)roomSize.y - 2) + 1; map[x, y] = defaultDoorElement; } } }