コード例 #1
0
        private void RefreshMetaData(Vector3I worldPosition, byte newBlockValue)
        {
            //From World Coordinate to Chunk Coordinate
            int arrayX = MathHelper.Mod(worldPosition.X, AbstractChunk.ChunkSize.X);
            int arrayZ = MathHelper.Mod(worldPosition.Z, AbstractChunk.ChunkSize.Z);
            //Compute 2D index of ColumnInfo and update ColumnInfo
            int index2D = arrayX * AbstractChunk.ChunkSize.Z + arrayZ;

            if (newBlockValue != WorldConfiguration.CubeId.Air)
            {
                //Change being made above surface !
                if (ColumnsInfo[index2D].MaxHeight < worldPosition.Y)
                {
                    ColumnsInfo[index2D].MaxHeight = (byte)worldPosition.Y;
                    ChunkMetaData.setChunkMaxHeightBuilt((byte)worldPosition.Y);
                    if (ColumnsInfo[index2D].IsWild)
                    {
                        ColumnsInfo[index2D].IsWild = false;
                        ChunkMetaData.setChunkWildStatus(ColumnsInfo);
                    }
                }
            }
            else
            {
                //Change being made at the surface (Block removed)
                if (ColumnsInfo[index2D].MaxHeight <= worldPosition.Y)
                {
                    int yPosi = worldPosition.Y - 1;
                    int index = ChunkCubes.Index(worldPosition.X, yPosi, worldPosition.Z);
                    while (ChunkCubes.Cubes[index].Id == WorldConfiguration.CubeId.Air && yPosi > 0)
                    {
                        index = ChunkCubes.FastIndex(index, yPosi, SingleArrayChunkContainer.IdxRelativeMove.Y_Minus1, false);
                        yPosi--;
                    }
                    ChunkMetaData.setChunkMaxHeightBuilt((byte)yPosi);
                    if (ColumnsInfo[index2D].IsWild)
                    {
                        ColumnsInfo[index2D].IsWild = false;
                        ChunkMetaData.setChunkWildStatus(ColumnsInfo);
                    }
                }
            }
        }
コード例 #2
0
        private void RefreshMetaData(ref Vector3I inChunkPosition, byte newBlockValue)
        {
            int indexColumn = inChunkPosition.X * _chunkSize.Z + inChunkPosition.Z;

            if (newBlockValue != WorldConfiguration.CubeId.Air)
            {
                //Change being made above surface !
                if (ColumnsInfo[indexColumn].MaxHeight < inChunkPosition.Y)
                {
                    ColumnsInfo[indexColumn].MaxHeight = (byte)inChunkPosition.Y;
                    ChunkMetaData.setChunkMaxHeightBuilt((byte)inChunkPosition.Y);
                    if (ColumnsInfo[indexColumn].IsWild)
                    {
                        ColumnsInfo[indexColumn].IsWild = false;
                        ChunkMetaData.setChunkWildStatus(ColumnsInfo);
                    }
                }
            }
            else
            {
                //Change being made at the surface (Block removed)
                if (ColumnsInfo[indexColumn].MaxHeight <= inChunkPosition.Y)
                {
                    int yPosi = inChunkPosition.Y - 1;
                    while (yPosi > 0 && GetBlock(inChunkPosition.X, yPosi, inChunkPosition.Z) == WorldConfiguration.CubeId.Air)
                    {
                        yPosi--;
                    }
                    ChunkMetaData.setChunkMaxHeightBuilt((byte)yPosi);
                    if (ColumnsInfo[indexColumn].IsWild)
                    {
                        ColumnsInfo[indexColumn].IsWild = false;
                        ChunkMetaData.setChunkWildStatus(ColumnsInfo);
                    }
                }
            }
        }