Exemplo n.º 1
0
        public IEnumerator TopFaceOfBlockIsVisibleWhenAtTopEdgeOfIsland()
        {
            Island        testCandidate = new Island(64);
            BlockPosition blockPosition = new BlockPosition(0, 255, 0);

            Block testBlock = GrassyEarthBlock.GetInstance();

            testCandidate.PlaceBlockAt(testBlock, blockPosition);

            bool result = testCandidate.BlockFaceAtPositionIsHidden(BlockFaceDirections.TOP, blockPosition);

            yield return(null);

            Assert.That(result, Is.EqualTo(false));
        }
Exemplo n.º 2
0
        public IEnumerator LeftBlockFaceIsVisibleWhenOnLeftIslandEdge()
        {
            Island        testCandidate = new Island(64);
            BlockPosition blockPosition = new BlockPosition(63, 0, 0);

            Block testBlock = RockBlock.GetInstance();

            testCandidate.PlaceBlockAt(testBlock, blockPosition);

            bool result = testCandidate.BlockFaceAtPositionIsHidden(BlockFaceDirections.LEFT, blockPosition);

            yield return(null);

            Assert.That(result, Is.EqualTo(false));
        }
Exemplo n.º 3
0
        public IEnumerator TopFaceOfBlockIsVisibleWhenNotFullyCovering()
        {
            Island        testCandidate    = new Island(64);
            BlockPosition blockPositionOne = new BlockPosition(0, 4, 0);
            BlockPosition blockPositionTwo = new BlockPosition(0, 5, 0);

            Block testBlock = AirBlock.GetInstance();
            Block neighbor  = RockBlock.GetInstance();

            testCandidate.PlaceBlockAt(testBlock, blockPositionOne);
            testCandidate.PlaceBlockAt(neighbor, blockPositionTwo);

            bool result = testCandidate.BlockFaceAtPositionIsHidden(BlockFaceDirections.TOP, blockPositionOne);

            yield return(null);

            Assert.That(result, Is.EqualTo(false));
        }
Exemplo n.º 4
0
        public IEnumerator TopFaceOfBlockIsHiddenWhenCovered()
        {
            Island        testCandidate    = new Island(64);
            BlockPosition blockPositionOne = new BlockPosition(0, 5, 0);
            BlockPosition blockPositionTwo = new BlockPosition(0, 4, 0);

            Block testBlock = GrassyEarthBlock.GetInstance();
            Block neighbor  = GrassyEarthBlock.GetInstance();

            testCandidate.PlaceBlockAt(testBlock, blockPositionTwo);
            testCandidate.PlaceBlockAt(neighbor, blockPositionOne);

            bool result = testCandidate.BlockFaceAtPositionIsHidden(BlockFaceDirections.TOP, blockPositionTwo);

            yield return(null);

            Assert.That(result, Is.EqualTo(true));
        }
Exemplo n.º 5
0
        public IEnumerator RightFaceOfBlockIsVisibleWhenNotCovered()
        {
            Island        testCandidate    = new Island(64);
            BlockPosition blockPositionOne = new BlockPosition(46, 0, 0);
            BlockPosition blockPositionTwo = new BlockPosition(45, 0, 0);

            Block testBlock = GrassyEarthBlock.GetInstance();
            Block neighbor  = AirBlock.GetInstance();

            testCandidate.PlaceBlockAt(testBlock, blockPositionOne);
            testCandidate.PlaceBlockAt(neighbor, blockPositionTwo);

            bool result = testCandidate.BlockFaceAtPositionIsHidden(BlockFaceDirections.RIGHT, blockPositionOne);

            yield return(null);

            Assert.That(result, Is.EqualTo(false));
        }
        private BlockVisualsBuilder BuildBlockVisualsFromBlock(Island island, BlockPosition globalPosition, int inChunkX, int inChunkZ, int currentBlockRenderIndex)
        {
            BlockPosition positionOfBlockInChunk = new BlockPosition(inChunkX, globalPosition.Y, inChunkZ);

            Block currentBlock = island.GetBlockAt(globalPosition);
            BlockVisualsBuilder blockVisualsBuilder = BlockVisualsBuilder.FromBlockType(currentBlock.GetBlockType());

            blockVisualsBuilder.SetBlockToCreateDataFrom(currentBlock)
            .SetPositionOfBlockInChunk(positionOfBlockInChunk)
            .SetIndexBufferOffsetInChunk(currentBlockRenderIndex)
            .SetFrontFaceOfBlockIsHidden(island.BlockFaceAtPositionIsHidden(BlockFaceDirections.FRONT, globalPosition))
            .SetRightFaceOfBlockIsHidden(island.BlockFaceAtPositionIsHidden(BlockFaceDirections.RIGHT, globalPosition))
            .SetBackFaceOfBlockIsHidden(island.BlockFaceAtPositionIsHidden(BlockFaceDirections.BACK, globalPosition))
            .SetLeftFaceOfBlockIsHidden(island.BlockFaceAtPositionIsHidden(BlockFaceDirections.LEFT, globalPosition))
            .SetBottomFaceOfBlockIsHidden(island.BlockFaceAtPositionIsHidden(BlockFaceDirections.BOTTOM, globalPosition))
            .SetTopFaceOfBlockIsHidden(island.BlockFaceAtPositionIsHidden(BlockFaceDirections.TOP, globalPosition))
            .Build();

            return(blockVisualsBuilder);
        }