Exemplo n.º 1
0
        public static RoomBuilder GetRoom(this ThePalaceEntities dbContext, Int16 roomID)
        {
            var room = (RoomBuilder)null;

            if (ServerState.roomsCache.ContainsKey(roomID))
            {
                room = ServerState.roomsCache[roomID];
            }
            else
            {
                room = new RoomBuilder();

                if (room == null)
                {
                    throw new OutOfMemoryException("Unable to initiate RoomBuilder instance.");
                }

                room.ID = roomID;

                room.Read(dbContext);

                if (!room.NotFound)
                {
                    lock (ServerState.roomsCache)
                    {
                        ServerState.roomsCache.TryAdd(room.ID, room);
                    }
                }
            }

            return(room);
        }
Exemplo n.º 2
0
        void Awake()
        {
            renderSystem = GameObject.Find("RenderSystem").GetComponent <RenderSystem>();

            size  = Info.Map.Size;
            width = Info.Map.Width;

            edgesValid = false;

            selectedCell = new int2();

            cells        = Enumerable.Repeat(new Data.Cell(), Info.Map.Area).ToList();
            edges        = new List <int>(Info.Map.Area * Info.Map.Area);
            rooms        = new List <Data.Room>(Info.Map.NumberOfSeedRooms);
            placeholders = new List <RectInt>();

            SetupCells();
            SetupBase();
            SetupPaths();

            RoomBuilder.LayoutRooms(rooms, placeholders);

            SetupRooms();
            SetupColonyBases();

            ConstructMap();
        }
Exemplo n.º 3
0
        public IActionResult Update([FromBody] RoomViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Model is not valid"));
            }

            try
            {
                this.updateRoomCommand.RoomModel = RoomBuilder.BuildFromInfo(viewModel);
                this.updateRoomCommand.Execute();
                return(this.Ok());
            }
            catch (DoorsAreNotInWallsException)
            {
                return(BadRequest("Doors coordinates are invalid"));
            }
            catch (DuplicatedKeyException)
            {
                return(BadRequest("Room with this number already exists"));
            }
            catch (RoomIsIntersectedWithExisting)
            {
                return(BadRequest("Room is interssected with other room on this floor"));
            }
        }
 public void Initialize()
 {
     floorGenerator = new FloorGenerator(environmentParameters);
     roomBuilder    = roomPrefab.GetComponent <RoomBuilder>();
     hasInitialized = true;
     keyController  = FindObjectOfType <KeyController>();
 }
Exemplo n.º 5
0
        public void ReturnTheCorrectRoomIdIfTheNextIdIsSupplied()
        {
            var expected   = Int32.MaxValue.GetRandom();
            var actualRoom = new RoomBuilder().Build(expected);

            Assert.Equal(expected, actualRoom.Id);
        }
Exemplo n.º 6
0
    void Start()
    {
        /*
         * 1. Build the quadrants
         * 2. Build the rooms
         * 3. Build the containers
         * 4. Set the current room
         * 5. Force the rooms to subscribe to events
         * 6. Fire events.
         * */


        // Presets.
        containerActiveLayer = 1 << LayerMask.NameToLayer("ActiveItems");

        // Set the camera.
        cameraScript = mainCamera.GetComponent <PositionCamera> ();

        // Build the rooms.
        RoomBuilder floorBuilderScript = GetComponent <RoomBuilder> ();

        rooms = floorBuilderScript.BuildRooms();

        // Add in containers.
        ContainerBuilder containerBuilder = GetComponent <ContainerBuilder> ();

        containerBuilder.BuildContainers(rooms);

        // Activate the current room.
        SetRoom(floorBuilderScript.currentRoomIndex);

        // Move the camera, and action!
        cameraScript.SnapTo(rooms[currentRoomIndex].transform);
        Subscribe();
    }
Exemplo n.º 7
0
        public async Task Init()
        {
            // mock settings with an in-memory configuration
            var inMemorySettings = new Dictionary <string, string> {
                { "outputRelativePath", "foo" },
                { "grid:width", "1280" },
                { "grid:height", "720" },
                { "tiles:size", "720" },
                { "generator", "TeenyZonesGenerator" },
                { "serialiser", "JsonSerialiser" }
            };

            IConfiguration configuration = new ConfigurationBuilder()
                                           .AddInMemoryCollection(inMemorySettings)
                                           .Build();

            roomService = new RoomService(new Settings(configuration));

            var room1 = await RoomBuilder.Create().WithHeight(10).WithWidth(10).WithStartingPosition(new Position(0, 0))
                        .WithInsideTilesOfType(TileType.Floor).WithOutsideWalls().BuildAsync();

            var room2 = await RoomBuilder.Create().WithHeight(10).WithWidth(10).WithStartingPosition(new Position(5, 5))
                        .WithInsideTilesOfType(TileType.Floor).WithOutsideWalls().BuildAsync();

            var room3 = await RoomBuilder.Create().WithHeight(5).WithWidth(5).WithStartingPosition(new Position(25, 25))
                        .WithInsideTilesOfType(TileType.Floor).WithOutsideWalls().BuildAsync();

            rooms = new List <Room> {
                room1, room2, room3
            };
        }
Exemplo n.º 8
0
    public void generateDungeon(float difficulty)
    {
        Debug.Log(difficulty);
        int floors = DifficultyToFloors(difficulty);

        dungeonFloors.Clear();
        activeFloor = 0;
        float floorDifficulty = (difficulty / floors) * 2;

        Debug.Log(floorDifficulty);

        for (int i = 0; i < floors; i++)
        {
            TileBase[,] floorWallTiles = digger.MakeDungeonFloor(
                DungeonPresets.difficultyToDungeonParams(floorDifficulty));
            List <Rect> floorRoomRects     = digger.rooms.ToList();
            List <Rect> floorCorridorRects = digger.corridors.ToList();
            List <Room> rooms = RoomBuilder.BuildRooms(
                floorDifficulty,
                floorWallTiles,
                floorRoomRects,
                floorCorridorRects);

            DungeonFloor dungeonFloor = new DungeonFloor(
                floorWallTiles,
                floorRoomRects,
                floorCorridorRects,
                rooms);
            dungeonFloors.Add(dungeonFloor);
        }
    }
Exemplo n.º 9
0
    // Use this for initialization
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        else if (Instance != gameObject)
        {
            Destroy(gameObject);
        }

        builtRooms = new List <int>();

        grid = GameObject.Find("Grid");

        currFloorMap = grid.transform.GetChild(0).GetComponent <Tilemap>();

        //Gets the Tilemap we want to use for our walls and adds a TilemapCollider2D
        currWallMap = grid.transform.GetChild(1).GetComponent <Tilemap>();
        currWallMap.gameObject.AddComponent <TilemapCollider2D>();

        //Create a ColliderTilemap for interactable Tiles like doors/chests
        currDoorMap = grid.transform.GetChild(2).GetComponent <Tilemap>();

        currDoorMap.gameObject.AddComponent <TilemapCollider2D>().isTrigger = true;
        currDoorMap.gameObject.AddComponent <Rigidbody2D>();
        currDoorMap.GetComponent <Rigidbody2D>().gravityScale = 0;
        currDoorMap.GetComponent <Rigidbody2D>().isKinematic  = true;
        currDoorMap.gameObject.AddComponent <DoorController>();

        minimap = GameObject.Find("Canvas").transform.GetChild(1).GetComponent <Minimap>();
    }
Exemplo n.º 10
0
    /*
     * [MenuItem("Tools/Room Builder/Save View &q", false, 23)]
     * public static void EnableCam1()
     * {
     *  SceneView view = SceneView.currentDrawingSceneView;
     *  RoomBuilder workbench = FindObjectOfType<RoomBuilder>();
     *
     *  if (view == null)
     *      view = SceneView.sceneViews[0] as SceneView;
     *
     *  var target = new GameObject();
     *  target.transform.position = workbench.transform.position + new Vector3(0, 200, 0);
     *  target.transform.rotation = Quaternion.Euler(90, 0, 0);
     *  view.AlignViewToObject(target.transform);
     *  view.orthographic = true;
     *  SceneView.
     *  GameObject.DestroyImmediate(target);
     * }
     *
     * [MenuItem("Tools/Room Builder/Toggle View &e", false, 23)]
     * public static void EnableCam2()
     * {
     * }
     */

    override public void OnInspectorGUI()
    {
        RoomBuilder workbench = target as RoomBuilder;

        Vector2 roomSize = workbench.roomSize;

        roomSize.x = EditorGUILayout.IntSlider("Room Size", (int)workbench.roomSize.x, 1, workbench.roomUnits.GetLength(0));
        roomSize.y = roomSize.x;

        workbench.roomLevel = EditorGUILayout.IntSlider("Room Level", workbench.roomLevel, 1, RoomBuilder.MAX_LEVEL);

        GUILayout.Space(10);
        GUI.enabled = roomSize.x == 1 && roomSize.y == 1;
        bool isBeaconRoom = EditorGUILayout.Toggle("Start/End Room", workbench.isBeaconRoom);

        workbench.isBeaconRoom = GUI.enabled && isBeaconRoom;

        workbench.isRotatable = EditorGUILayout.Toggle("Is Rotatable", workbench.isRotatable);
        GUI.enabled           = true;

        if (workbench.roomSize != roomSize)
        {
            Undo.RecordObject(workbench, "Changed room size");
            workbench.roomSize = roomSize;
        }
    }
Exemplo n.º 11
0
        public void PlaceDoor_InRectangularTestRooms(StandardTestRoom testRoom)
        {
            var fakeRandomNumbers = new FakeRandomNumberGenerator();

            void SetupStandardRoom()
            {
                fakeRandomNumbers.PopulateRandomForTestRoom(testRoom)
                ;
            }

            void SetupDoorForStandardRoom()
            {
                fakeRandomNumbers
                .AddCoordinates(0, 0)               // Door placement, top left corner, will try again
                .AddCoordinates(9, 0)               // Door placement, btm left corner, will try again
                .AddCoordinates(9, 5)               // Door placement, btm right corner, will try again
                .AddCoordinates(0, 5)               // Door placement, top right corner, will try again
                .AddCoordinates(0, 3)               // Door placement, vertical wall, will try again
                .AddCoordinates(4, 0)               // Door placement, horizontal wall, will try again
                .AddCoordinates(4, 3)               // Door placement, vertical wall to start walk from
                .AddDirection(Compass8Points.North) // direction to walk to find a wall and place a door
                .AddCoordinates(4, 3)               // Door placement, vertical wall to start walk from
                .AddDirection(Compass8Points.East)  // direction to walk to find a wall and place a door
                .AddCoordinates(4, 3)               // Door placement, vertical wall to start walk from
                .AddDirection(Compass8Points.South) // direction to walk to find a wall and place a door
                .AddCoordinates(4, 3)               // Door placement, vertical wall to start walk from
                .AddDirection(Compass8Points.West)  // direction to walk to find a wall and place a door
                ;
            }

            var registry = new DispatchRegistry();

            SetupStandardRoom();
            SetupDoorForStandardRoom();

            var fakeLogger = new FakeLogger(_output);

            var builder = new RoomBuilder(fakeRandomNumbers, fakeLogger, registry);

            var mazeDescriptor = FakeMazeDescriptorBuilder.MazeRoomsWithTwoBlocks();
            var detail         = mazeDescriptor[1];
            var room           = builder.BuildRoom(detail.BlocksPerRoom, detail.TilesPerBlock);

            room = room.AddDoor(1);
            room = room.AddDoor(2);
            room = room.AddDoor(3);
            room = room.AddDoor(4);

            var expected = GetExpectationForTestRoom(testRoom);
            var actual   = room.ToString();

            _output.WriteLine('='.ToPaddedString(10));
            _output.WriteLine(expected);
            _output.WriteLine('='.ToPaddedString(10));
            _output.WriteLine(actual);
            _output.WriteLine('='.ToPaddedString(10));

            Assert.Equal(expected, actual);
        }
Exemplo n.º 12
0
    void DetermineDungeon(List <RoomBuilder> roomBuilders)
    {
        List <RoomBuilder> maxDepth = roomBuilders.Where(o => o.depth == depth).ToList().OrderByDescending(o => o.sizeX * o.sizeY).ToList();

        maxDepth[0].AddRoomFiller(new BossOneFiller(maxDepth[0].position, maxDepth[0].sizeX, maxDepth[0].sizeY, maxDepth[0].room, maxDepth[0].doors));
        //maxDepth[1].AddRoomFiller(new BossOneFiller(maxDepth[1].position, maxDepth[1].sizeX, maxDepth[1].sizeY, maxDepth[1].room, maxDepth[1].doors));

        RoomBuilder      portalRoom        = maxDepth[maxDepth.Count - 1];
        RoomBuilder      portalRoom2       = maxDepth[maxDepth.Count - 2];
        PortalRoomFiller portalRoomFiller1 = new PortalRoomFiller(portalRoom.position, portalRoom.sizeX, portalRoom.sizeY, portalRoom.room, portalRoom.doors);
        PortalRoomFiller portalRoomFiller2 = new PortalRoomFiller(portalRoom2.position, portalRoom2.sizeX, portalRoom2.sizeY, portalRoom2.room, portalRoom2.doors);

        portalRoomFiller1.destinationRoom = portalRoomFiller2;
        portalRoomFiller2.destinationRoom = portalRoomFiller1;
        portalRoom.AddRoomFiller(portalRoomFiller1);
        portalRoom2.AddRoomFiller(portalRoomFiller2);

        List <RoomBuilder> depthSorted = roomBuilders.OrderByDescending(o => o.depth).ToList();
        List <RoomBuilder> sizeSorted  = roomBuilders.OrderBy(o => o.depth).ToList();

        int numStores = Random.Range(1, 4);
        int stores    = 0;

        foreach (RoomBuilder builder in depthSorted)
        {
            if (!builder.hasRoomFiller)
            {
                if (Random.Range(0, 100) > 20)
                {
                    builder.AddRoomFiller(new StoreRoomFiller(builder.position, builder.sizeX, builder.sizeY, builder.room, builder.doors));
                }
                stores++;
                if (stores >= numStores)
                {
                    break;
                }
            }
        }

        foreach (RoomBuilder builder in depthSorted)
        {
            if (!builder.hasRoomFiller)
            {
                if (Random.Range(0, 100) > 10)
                {
                    builder.AddRoomFiller(new GraveYardRoom(builder.position, builder.sizeX, builder.sizeY, builder.room, builder.doors));
                }
                else if (Random.Range(0, 100) > 32)
                {
                    builder.AddRoomFiller(new LakeRoomFiller(builder.position, builder.sizeX, builder.sizeY, builder.room, builder.doors));
                }
                else
                {
                    builder.AddRoomFiller(new GraveYardRoom(builder.position, builder.sizeX, builder.sizeY, builder.room, builder.doors));
                }
            }
            //Debug.Log(builder.depth);
        }
    }
Exemplo n.º 13
0
 public void Setup(TileType tileType, Vector2 positionInMap, RoomBuilder roomBuilder, TileManager tileManager, DebugSettings debugSettings)
 {
     TileType       = tileType;
     _roomBuilder   = roomBuilder;
     PositionInMap  = positionInMap;
     _tileManager   = tileManager;
     _debugSettings = debugSettings;
 }
Exemplo n.º 14
0
        private async Task <FrontDesk.Core.Aggregates.Room> AddRoom(int id)
        {
            var room = new RoomBuilder().Id(id).Build();

            await _repository.AddAsync <FrontDesk.Core.Aggregates.Room, int>(room);

            return(room);
        }
Exemplo n.º 15
0
    void Awake()
    {
        roomBuild    = GameObject.Find("LevelManager").GetComponent <RoomBuilder> ();
        pickupParent = GameObject.Find("PickupParent");

        SpawnPlayer();
//		SpawnPickups ();
    }
Exemplo n.º 16
0
        public void RoomBuilderResizeTest()
        {
            var setHeightRoom = new RoomBuilder(_testChunk)
                                .SetSize(10)
                                .Build() as Room;

            Assert.AreEqual(10, setHeightRoom.TopRightCorner.Y - setHeightRoom.BottomLeftCorner.Y, $"Room height was not as expected.");
        }
Exemplo n.º 17
0
        private async Task <Room> AddRoom(int id)
        {
            var room = new RoomBuilder().Id(id).Build();

            await _repository.AddAsync(room);

            return(room);
        }
Exemplo n.º 18
0
        public void ReturnTheCorrectCapacityIfSupplied()
        {
            var expected   = Int32.MaxValue.GetRandom();
            var actualRoom = new RoomBuilder()
                             .Capacity(expected).Build(Int32.MaxValue.GetRandom());

            Assert.Equal(expected, actualRoom.Capacity);
        }
        private async Task <ClinicManagement.Core.Aggregates.Room> AddRoom(int id)
        {
            var room = new RoomBuilder().Id(id).Build();

            await _repository.AddAsync <ClinicManagement.Core.Aggregates.Room, int>(room);

            return(room);
        }
Exemplo n.º 20
0
        public void AddRooms()
        {
            RoomBuilder builder = new RoomBuilder();

            builder.GenerateRooms(maze, 6);
            maze.Draw();
            Console.WriteLine(string.Format("Filled ratio: {0}", maze.FilledRatio()));
        }
Exemplo n.º 21
0
        public void ReturnATimeslotsUnavailableCollectionWithOneValueIfOneIsSupplied()
        {
            var expected   = Int32.MaxValue.GetRandom();
            var actualRoom = new RoomBuilder()
                             .AddTimeslotUnavailable(expected)
                             .Build(Int32.MaxValue.GetRandom());

            Assert.Single(actualRoom.UnavailableForTimeslots);
        }
Exemplo n.º 22
0
        public void ReturnTheCorrectTimeslotUnavailableValueIfIfOneIsSupplied()
        {
            var expected   = Int32.MaxValue.GetRandom();
            var actualRoom = new RoomBuilder()
                             .AddTimeslotUnavailable(expected)
                             .Build(Int32.MaxValue.GetRandom());

            Assert.Equal(expected, actualRoom.UnavailableForTimeslots.First());
        }
Exemplo n.º 23
0
        public void Should_Update_SituationRoom()
        {
            var newDescriptionExpected = _faker.Random.String(1);
            var room = RoomBuilder.New().Build();

            room.ChangeSituation(newDescriptionExpected);

            Assert.Equal(newDescriptionExpected, room.Situation);
        }
Exemplo n.º 24
0
    public static void SelectWorkbench()
    {
        RoomBuilder workbench = FindObjectOfType <RoomBuilder>() as RoomBuilder;

        if (workbench != null)
        {
            Selection.objects = new Object[] { workbench.gameObject }
        }
        ;
    }
Exemplo n.º 25
0
        private void RandomNameBtn_Click(object sender, EventArgs e)
        {
            string str = "";

            while (str == "")
            {
                str = RoomBuilder.Name();
            }
            this.NameBox.Text = str;
        }
Exemplo n.º 26
0
        private void RandomDescBtn_Click(object sender, EventArgs e)
        {
            string str = "";

            while (str == "")
            {
                str = RoomBuilder.Details();
            }
            this.DetailsBox.Text = str;
        }
Exemplo n.º 27
0
        public async Task ExecuteShouldAddGroupClass()
        {
            //Arrange
            SchoolManagementContext context = new ContextBuilder().BuildClean();
            GroupLevel  groupLevel          = new GroupLevelBuilder(context).With(x => x.Level = 1).With(x => x.Name = "Początkujący").BuildAndSave();
            Room        room                   = new RoomBuilder(context).WithName("Sala biała").BuildAndSave();
            User        anchor                 = new UserBuilder(context).WithEmail("*****@*****.**").BuildAndSave();
            Role        role                   = new RoleBuilder(context).WithName(Roles.Anchor).AddUserToRole(anchor).BuildAndSave();
            List <User> participants           = new List <User>();
            var         participantRoleBuilder = new RoleBuilder(context).WithName(Roles.Participant);

            for (var i = 0; i < 10; i++)
            {
                User user = new UserBuilder(context).WithEmail($"email{i}@gmail.com").BuildAndSave();
                participants.Add(user);
                participantRoleBuilder.AddUserToRole(user);
            }

            participantRoleBuilder.BuildAndSave();

            Command cmd = new Command
            {
                Name    = "Groupa zajęciowa",
                Anchors = new List <string> {
                    anchor.Id
                },
                IsSolo           = true,
                PassPrice        = 200,
                ParticipantLimit = 20,
                GroupLevelId     = groupLevel.Id,
                Participants     = participants.Select(x => new ParticipantDto
                {
                    Id   = x.Id,
                    Role = ParticipantRole.Leader
                }).ToList(),
                DayOfWeeks = new List <ClassDayOfWeekDto>(),
                RoomId     = room.Id
            };
            //Act
            DataResult result = await new Handler(context).Handle(cmd, CancellationToken.None);

            //Assert
            result
            .Should().NotBeNull();
            result.Status.Should().Be(DataResult.ResultStatus.Success, "all parameters are corrected");
            context.GroupClass.Should().NotBeEmpty("we add new group");
            GroupClass groupClass = context.GroupClass.First();

            groupClass.Anchors.Should().NotBeEmpty();
            groupClass.Room.Should().Be(room);
            groupClass.GroupLevel.Should().Be(groupLevel);
            groupClass.PassPrice.Should().Be(cmd.PassPrice);
            groupClass.Participants.Should().NotBeEmpty().And.HaveCount(participants.Count).And
            .Contain(x => participants.Contains(x.User));
        }
Exemplo n.º 28
0
        private void RandomNameBtn_Click(object sender, EventArgs e)
        {
            string name = "";

            while (name == "")
            {
                name = RoomBuilder.Name();
            }

            NameBox.Text = name;
        }
Exemplo n.º 29
0
        private void RandomDescBtn_Click(object sender, EventArgs e)
        {
            string details = "";

            while (details == "")
            {
                details = RoomBuilder.Details();
            }

            DetailsBox.Text = details;
        }
Exemplo n.º 30
0
        internal void Build(int level, bool connectTunnels = true)
        {
            var roomBuilder = new RoomBuilder(_randomNumberGenerator, _logger, _registry);
            var mazeBuilder = new MazeBuilder(_randomNumberGenerator, roomBuilder, _mazeDescriptor, _logger, _registry);

            var maze = connectTunnels ?
                       mazeBuilder.BuildMaze(level) :
                       mazeBuilder.BuildMazeWithRoomsAndDoors(level);

            Compact(maze, level);
        }
Exemplo n.º 31
0
    // Use this for initialization
    void Awake()
    {
        int originalSeed = Random.seed;
        level = GameManager.getInstance().islandLevel;
        if (!GameManager.getInstance().inMaze)
        {
            //set seed
            GameManager.getInstance().seed = Random.seed;
            Debug.Log("Generating first time, seed: " +GameManager.getInstance().seed);
        }
        Random.seed = GameManager.getInstance().seed;
        //Get a component reference to the attached BoardManager script
        roombuilder = GetComponent<RoomBuilder>();

        //Get a list of positions of where to place a room
        InitaliseRoomPos();

        hasMinRooms = 0;

        // place the rooms in the maze
        //random choose starting co ordinate

        int x = Random.Range(0, level + 1);
        int y = Random.Range(0, level + 1);
        PlaceRooms(x, y);
        //spawn player in starting point
        SpawnPlayer(x, y);
        SpawnTreasure(x, y);

        if (GameManager.getInstance().inMaze)
        {
            reload();
            //Reset the seed to random so different encounters

        }
        else
        {
            GameManager.getInstance().inMaze = true;
        }
        Debug.Log("Setting seed to: " + originalSeed);
        Random.seed = originalSeed;

        //create the hallways
        // AddHallways();
    }
Exemplo n.º 32
0
        /// <summary>
        /// Creates a flat, wooden balloon port for the balloon to land on, and Dwarves to sit on.
        /// </summary>
        /// <param name="roomDes">The player's BuildRoom designator (so that we can create a balloon port)</param>
        /// <param name="chunkManager">The terrain handler</param>
        /// <param name="x">The position of the center of the balloon port</param>
        /// <param name="z">The position of the center of the balloon port</param>
        /// <param name="size">The size of the (square) balloon port in voxels on a side</param>
        public void GenerateInitialBalloonPort(RoomBuilder roomDes, ChunkManager chunkManager, float x, float z, int size)
        {
            Vector3 pos = new Vector3(x, ChunkHeight - 1, z);

            // First, compute the maximum height of the terrain in a square window.
            int averageHeight = 0;
            int count = 0;
            for(int dx = -size; dx <= size; dx++)
            {
                for(int dz = -size; dz <= size; dz++)
                {
                    Vector3 worldPos = new Vector3(pos.X + dx, pos.Y, pos.Z + dz);
                    VoxelChunk chunk = chunkManager.ChunkData.GetVoxelChunkAtWorldLocation(worldPos);

                    if(chunk == null)
                    {
                        continue;
                    }

                    Vector3 gridPos = chunk.WorldToGrid(worldPos);
                    int h = chunk.GetFilledHeightOrWaterAt((int) gridPos.X + dx, (int) gridPos.Y, (int) gridPos.Z + dz);

                    if (h > 0)
                    {
                        averageHeight += h;
                        count++;
                    }
                }
            }

            averageHeight = (int) Math.Round(((float) averageHeight/(float) count));

            // Next, create the balloon port by deciding which voxels to fill.
            List<Voxel> designations = new List<Voxel>();
            for(int dx = -size; dx <= size; dx++)
            {
                for(int dz = -size; dz <= size; dz++)
                {
                    Vector3 worldPos = new Vector3(pos.X + dx, pos.Y, pos.Z + dz);
                    VoxelChunk chunk = chunkManager.ChunkData.GetVoxelChunkAtWorldLocation(worldPos);

                    if (chunk == null)
                    {
                        continue;
                    }

                    Vector3 gridPos = chunk.WorldToGrid(worldPos);
                    int h = chunk.GetFilledVoxelGridHeightAt((int) gridPos.X, (int) gridPos.Y, (int) gridPos.Z);

                    if(h == -1)
                    {
                        continue;
                    }

                    for (int y = averageHeight; y < h; y++)
                    {
                        Voxel v = chunk.MakeVoxel((int)gridPos.X, y, (int)gridPos.Z);
                        v.Type = VoxelLibrary.GetVoxelType(0);
                        chunk.Data.Water[v.Index].WaterLevel = 0;
                    }

                    if (averageHeight < h)
                    {
                        h = averageHeight;
                    }

                    // Fill from the top height down to the bottom.
                    for (int y = h - 1; y < averageHeight; y++)
                    {
                        Voxel v = chunk.MakeVoxel((int) gridPos.X, y, (int) gridPos.Z);
                        v.Type = VoxelLibrary.GetVoxelType("Scaffold");
                        chunk.Data.Water[v.Index].WaterLevel = 0;
                        v.Chunk = chunk;
                        v.Chunk.NotifyTotalRebuild(!v.IsInterior);

                        if (y == averageHeight - 1)
                        {
                            designations.Add(v);
                        }
                    }
                }
            }

            // Actually create the BuildRoom.
            BalloonPort toBuild = new BalloonPort(designations, chunkManager);
            BuildRoomOrder buildDes = new BuildRoomOrder(toBuild, roomDes.Faction);
            buildDes.Build();
            roomDes.DesignatedRooms.Add(toBuild);
        }