コード例 #1
0
ファイル: FlatlandGeneratorr.cs プロジェクト: wqd1019dqw/Alex
        public IChunkColumn GenerateChunkColumn(ChunkCoordinates chunkCoordinates)
        {
            ChunkColumn column = new ChunkColumn();

            column.X = chunkCoordinates.X;
            column.Z = chunkCoordinates.Z;

            for (int x = 0; x < 16; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    column.SetBlockState(x, 0, z, Bedrock);
                    column.SetBlockState(x, 1, z, Dirt);
                    column.SetBlockState(x, 2, z, Dirt);
                    column.SetBlockState(x, 3, z, Grass);

                    column.SetSkyLight(x, 0, z, 15);
                    column.SetSkyLight(x, 1, z, 15);
                    column.SetSkyLight(x, 2, z, 15);
                    column.SetSkyLight(x, 3, z, 15);
                    column.SetSkyLight(x, 4, z, 15);
                }
            }

            return(column);
        }
コード例 #2
0
        public ChunkColumn GenerateChunkColumn(ChunkCoordinates chunkCoordinates)
        {
            int cc = 0;

            ChunkColumn chunk = new ChunkColumn();

            chunk.X = chunkCoordinates.X;
            chunk.Z = chunkCoordinates.Z;

            for (int x = 0; x < 16; ++x)
            {
                for (int z = 0; z < 16; ++z)
                {
                    int rx = chunkCoordinates.X * 16 + x;
                    int rz = chunkCoordinates.Z * 16 + z;

                    BlockState iblockstate = GetBlockStateFor(rx, rz);

                    if (iblockstate != null)
                    {
                        chunk.SetBlockState(x, 70, z, iblockstate);
                        chunk.Height[((z << 4) + (x))] = 70;
                    }

                    chunk.SetSkyLight(x, 70, z, 15);
                    chunk.SetSkyLight(x, 71, z, 15);
                    chunk.SetSkyLight(x, 69, z, 15);
                }
            }

            chunk.CalculateHeight();
            return(chunk);
        }
コード例 #3
0
ファイル: DebugWorldGenerator.cs プロジェクト: lvyitian1/Alex
        public ChunkColumn GenerateChunkColumn(ChunkCoordinates chunkCoordinates)
        {
            return(_cache.GetOrAdd(
                       chunkCoordinates, (cc) =>
            {
                ChunkColumn chunk = new ChunkColumn(chunkCoordinates.X, chunkCoordinates.Z);
                for (int x = 0; x < 16; x++)
                {
                    for (int z = 0; z < 16; z++)
                    {
                        int rx = (chunkCoordinates.X * 16) + x;
                        int rz = (chunkCoordinates.Z * 16) + z;

                        BlockState iblockstate = GetBlockStateFor(rx, rz);

                        if (iblockstate != null)
                        {
                            chunk.SetBlockState(x, 1, z, iblockstate);
                            //chunk.Height[((z << 4) + (x))] = 70;
                        }

                        chunk.SetSkyLight(x, 2, z, 15);
                        //  chunk.SetSkyLight(x, 71, z, 15);
                        //  chunk.SetSkyLight(x, 69, z, 15);
                    }
                }

                //chunk.CalculateHeight();
                return chunk;
            }));
        }
コード例 #4
0
        public ChunkColumn GenerateChunkColumn(ChunkCoordinates chunkCoordinates)
        {
            ChunkColumn column = new ChunkColumn();

            column.X = chunkCoordinates.X;
            column.Z = chunkCoordinates.Z;

            for (int x = 0; x < 16; x++)
            {
                for (int z = 0; z < 16; z++)
                {
                    column.SetBlockState(x, 0, z, Bedrock);
                    if (column.X == 1 && column.Z == 1)
                    {
                        for (int y = 1; y < 2; y++)
                        {
                            column.SetBlockState(x, y, z, Water.WithProperty("level", "8"));
                        }
                        column.SetBlockState(x, 3, z, Water.WithProperty("level", "3"));
                    }
                    else
                    {
                        column.SetBlockState(x, 1, z, Dirt);
                        column.SetBlockState(x, 2, z, Dirt);
                        column.SetBlockState(x, 3, z, Grass);

                        if (x == 8 && z == 8)
                        {
                            column.SetBlockState(x, 5, z, Slab.WithProperty("type", "bottom"));
                        }
                        else if (x == 8 && z == 7)
                        {
                            column.SetBlockState(x, 5, z, Slab.WithProperty("type", "top"));
                        }
                    }

                    column.SetSkyLight(x, 0, z, 15);
                    column.SetSkyLight(x, 1, z, 15);
                    column.SetSkyLight(x, 2, z, 15);
                    column.SetSkyLight(x, 3, z, 15);
                    column.SetSkyLight(x, 4, z, 15);
                }
            }

            return(column);
        }
コード例 #5
0
        public IChunkColumn GenerateChunkColumn(ChunkCoordinates chunkCoordinates)
        {
            IChunkColumn c = new ChunkColumn()
            {
                X = chunkCoordinates.X,
                Z = chunkCoordinates.Z
            };

            for (int x = 0; x < ChunkColumn.ChunkWidth; x++)
            {
                for (int z = 0; z < ChunkColumn.ChunkDepth; z++)
                {
                    for (int y = 0; y < ChunkColumn.ChunkHeight; y++)
                    {
                        if (c.X == 0 && c.Z == 0)
                        {
                            IBlockState block;
                            switch (y >> 4)
                            {
                            case 0:
                                block = _dirt;
                                break;

                            case 1:
                                block = _stone;
                                break;

                            case 2:
                                block = _cobble;
                                break;

                            case 3:
                                block = _grass;
                                break;

                            //case 4:
                            //    break;
                            default:
                                continue;
                            }

                            c.SetBlockState(x, y, z, block);
                        }
                        else
                        {
                            //c.SetBlockState(x, y, z, _air);
                        }

                        c.SetSkyLight(x, y, z, 15);
                    }
                    c.SetHeight(x, z, 0);
                }
            }
            return(c);
        }
コード例 #6
0
        public EmptyWorldGenerator()
        {
            _sharedChunk = new ChunkColumn();
            //_sharedChunk.IsAllAir = true;
            for (int x = 0; x < ChunkColumn.ChunkWidth; x++)
            {
                for (int z = 0; z < ChunkColumn.ChunkDepth; z++)
                {
                    for (int y = 0; y < ChunkColumn.ChunkHeight; y++)
                    {
                        //	_sharedChunk.SetBlockState(x, y, z, new Air());
                        _sharedChunk.SetSkyLight(x, y, z, 15);
                    }

                    _sharedChunk.SetHeight(x, z, 0);
                }
            }
        }
コード例 #7
0
ファイル: SkyLightBlockAccess.cs プロジェクト: lvyitian/Alex
        public void SetSkyLight(BlockCoordinates coordinates, byte skyLight)
        {
            ChunkColumn chunk = GetChunk(coordinates, true);

            chunk?.SetSkyLight(coordinates.X & 0x0f, coordinates.Y & 0xff, coordinates.Z & 0x0f, skyLight);
        }
コード例 #8
0
        public void SetSkyLight(Block block)
        {
            ChunkColumn chunk = GetChunk(block.Coordinates);

            chunk.SetSkyLight(block.Coordinates.X & 0x0f, block.Coordinates.Y & 0xff, block.Coordinates.Z & 0x0f, block.SkyLight);
        }
コード例 #9
0
        private void Spread(ConcurrentQueue <LightingItem> queue, ChunkColumn chunk, BlockFace face, int x, int y, int z, int lightLevel)
        {
            if (lightLevel <= 0)
            {
                return;
            }

            var chunkCoordinates = new ChunkCoordinates(x >> 4, z >> 4);

            if (chunkCoordinates.X != chunk.X || chunkCoordinates.Z != chunk.Z)
            {
                Enqueue(face, x, y, z, lightLevel);
                return;
            }

            //if (!ChunkManager.TryGetChunk(chunkCoordinates, out var chunk))
            //{
            //	Enqueue(face, x, y, z, lightLevel);
            //	return;
            //}

            //var self = World.GetBlockState(x, y, z).Block;
            var self = chunk.GetBlockState(x & 0xf, y & 0xff, z & 0xf).Block;

            if (self.BlockMaterial.BlocksLight)
            {
                return;
            }

            lightLevel -= self.LightOpacity;

            if (lightLevel < 0)
            {
                lightLevel = 0;
            }

            if (lightLevel < chunk.GetSkylight(x & 0xf, y & 0xff, z & 0xf))
            {
                return;
            }

            chunk.SetSkyLight(x & 0xf, y & 0xff, z & 0xf, (byte)lightLevel);

            if (lightLevel <= 0)
            {
                return;
            }

            //lightLevel--;

            if (face != BlockFace.East)
            {
                Enqueue(queue, BlockFace.West, x - 1, y, z, lightLevel);
            }

            if (face != BlockFace.West)
            {
                Enqueue(queue, BlockFace.East, x + 1, y, z, lightLevel);
            }

            if (face != BlockFace.South)
            {
                Enqueue(queue,
                        BlockFace.North, x, y, z - 1, lightLevel);
            }

            if (face != BlockFace.North)
            {
                Enqueue(queue, BlockFace.South, x, y, z + 1, lightLevel);
            }

            if (face != BlockFace.Up && y > 0)
            {
                Enqueue(queue, BlockFace.Down, x, y - 1, z, lightLevel);
            }

            if (face != BlockFace.Down && y < 256)
            {
                Enqueue(queue, BlockFace.Up, x, y + 1, z, lightLevel);
            }
        }