private DungeonRoom CreateRandomExit(PlanetData data, DungeonRoom room, bool locked,
                                         int lockID, bool bossRoom, bool treasure,
                                         PlanetDifficultyModifiers difficultyModifiers)
    {
        if (room.ExitCount == 4)
        {
            return(room);
        }

        List <Direction> directions = new List <Direction>
        {
            Direction.Up, Direction.Right, Direction.Down, Direction.Left
        };

        //remove any directions that are not available
        for (int j = directions.Count - 1; j >= 0; j--)
        {
            IntPair roomPos = AddDirection(room.position, directions[j]);
            if (data.GetRoomAtPosition(roomPos) != null)
            {
                directions.RemoveAt(j);
            }
        }

        //if no available directions then we're in a dead end
        if (directions.Count == 0)
        {
            return(room);
        }

        Direction randomDirection = directions[Random.Range(0, directions.Count)];
        IntPair   pos             = AddDirection(room.position, randomDirection);

        DungeonRoom newRoom;

        if (bossRoom)
        {
            newRoom = new BossRoom(pos, room, difficultyModifiers.enemyRoomDifficulty);
        }
        else if (treasure)
        {
            newRoom = new TreasureRoom(pos, room);
        }
        else
        {
            newRoom = PickRandomRoom(pos, room, difficultyModifiers);
        }
        data.AddRoom(newRoom);

        if (locked)
        {
            ConnectWithLock(room, newRoom, randomDirection, lockID);
        }
        else
        {
            Connect(room, newRoom, randomDirection);
        }

        return(newRoom);
    }
 private DungeonRoom GetRoomAtPosition(PlanetData data, IntPair position) => data.GetRoomAtPosition(position);