示例#1
0
文件: BiomeOcean.cs 项目: gaeqs/CMine
        public override int GetColumnHeight(int x, int z)
        {
            var normalized = (float)_heightGenerator.Noise(1, 1, true, x, z) + 1;

            normalized /= 2;
            return((int)Math.Floor(normalized * (_maxHeight - _minHeight) + _minHeight));
        }
示例#2
0
        public override BlockSnapshot GetBlockSnapshot(Vector3i position, int columnHeight, Rgba32I grassColor)
        {
            var y = position.Y;

            if (y > columnHeight)
            {
                return(y > 60 ? BlockSnapshotAir.Instance : (BlockSnapshot) new BlockSnapshotWater(8));
            }

            if (y == columnHeight)
            {
                if (y > 59)
                {
                    var generateTree = _treeOctaveGenerator.Noise(100, 10, true,
                                                                  position.X, y, position.Z) > 0.7;
                    if (generateTree)
                    {
                        _treeGenerator.TryToGenerate(position + new Vector3i(0, 1, 0), _world);
                    }

                    return(new BlockSnapshotGrass(grassColor));
                }

                return(BlockSnapshotDirt.Instance);
            }

            if (y > columnHeight - 4)
            {
                return(BlockSnapshotDirt.Instance);
            }

            return(BlockSnapshotStone.Instance);
        }
示例#3
0
        public override BlockSnapshot GetBlockSnapshot(Vector3i position, int columnHeight, Rgba32I grassColor)
        {
            var y    = position.Y;
            var cave = _caveGenerator.Noise(1, 10, true, position.X, position.Y, position.Z) > 0.5;

            if (cave)
            {
                return(BlockSnapshotAir.Instance);
            }
            if (y > columnHeight)
            {
                return(y > 60 ? BlockSnapshotAir.Instance : (BlockSnapshot) new BlockSnapshotWater(8));
            }

            if (y == columnHeight)
            {
                if (y > 59)
                {
                    if (_random.NextDouble() > 0.9995)
                    {
                        _treeGenerator.TryToGenerate(position + new Vector3i(0, 1, 0), _world);
                    }

                    else if (_random.NextDouble() > 0.96)
                    {
                        _world.UnloadedChunkGenerationManager.AddBlock(position + new Vector3i(0, 1, 0),
                                                                       new BlockSnapshotTallGrass(grassColor), false);
                    }

                    return(new BlockSnapshotGrass(grassColor));
                }

                return(BlockSnapshotDirt.Instance);
            }

            if (y > columnHeight - 4)
            {
                return(BlockSnapshotDirt.Instance);
            }

            return(BlockSnapshotStone.Instance);
        }
示例#4
0
文件: BiomeGrid.cs 项目: gaeqs/CMine
        public virtual Biome GetBiome(int x, int z)
        {
            var tNoise = _temperatureGenerator.Noise(1, 4, true, x, z);

            var temperature = BiomeTemperature.Cold;

            if (tNoise > 0.333)
            {
                temperature = BiomeTemperature.Hot;
            }
            else if (tNoise > -0.333)
            {
                temperature = BiomeTemperature.Normal;
            }

            var biomes = _biomes[(int)temperature];
            var bNoise = (float)_biomeGenerator.Noise(1, 500, true, x, z);

            return(biomes.GetBiome(bNoise / 2 + 0.5f));
        }
示例#5
0
        public override BlockSnapshot GetBlockSnapshot(Vector3i position, int columnHeight, Rgba32I grassColor)
        {
            var y = position.Y;

            if (y > columnHeight)
            {
                return(y > 60 ? BlockSnapshotAir.Instance : (BlockSnapshot) new BlockSnapshotWater(8));
            }

            if (y == columnHeight)
            {
                if (y > 59)
                {
                    var generateTreeGrass = _treeOctaveGenerator.Noise(100, 100, true,
                                                                       position.X, y, position.Z);
                    if (generateTreeGrass > 0.99)
                    {
                        _treeGenerator.TryToGenerate(position + new Vector3i(0, 1, 0), _world);
                    }

                    else if (generateTreeGrass > 0.5)
                    {
                        _world.UnloadedChunkGenerationManager.AddBlock(position + new Vector3i(0, 1, 0),
                                                                       new BlockSnapshotTallGrass(grassColor), false);
                    }

                    return(new BlockSnapshotGrass(grassColor));
                }

                return(BlockSnapshotDirt.Instance);
            }

            if (y > columnHeight - 4)
            {
                return(BlockSnapshotDirt.Instance);
            }

            return(BlockSnapshotStone.Instance);
        }