Exemplo n.º 1
0
        public static Queue <BlockMod> MakeTree(Vector3 position, int minTrunkHeight, int maxTrunkHeight)
        {
            Queue <BlockMod> queue = new Queue <BlockMod>();
            int height             = (int)(maxTrunkHeight * Terrian.TreeGeneration(new Vector2(position.x, position.z), 250f, 3f));

            if (height < minTrunkHeight)
            {
                height = minTrunkHeight;
            }
            for (int i = 1; i < height; i++)
            {
                queue.Enqueue(new BlockMod(new Vector3(position.x, position.y + i, position.z), 6));
            }
            for (int x = -2; x < 3; x++)
            {
                for (int y = 0; y < 5; y++)
                {
                    for (int z = -2; z < 3; z++)
                    {
                        queue.Enqueue(new BlockMod(new Vector3(position.x + x, position.y + height + y, position.z + z), 11));
                    }
                }
            }
            return(queue);
        }
Exemplo n.º 2
0
        public byte GetBlock(Vector3 pos)
        {
            // IMMUTABLE PASS
            int yPos = Mathf.FloorToInt(pos.y);

            if (!IsBlockInWorld(pos))
            {
                return(0);
            }
            if (yPos <= 3)
            {
                return(1);
            }
            // BASIC TERRAIN PASS
            int  terrainHeight = Terrian.GenerateHeight(new Vector2(pos.x, pos.z), biome.solidGroundHeight, biome.terrainHeightFromSoild, biome.terrainOffset, biome.terrainSmooth, biome.terrainOctaves, biome.terrainScale);
            byte blockValue;

            if (yPos == terrainHeight)
            {
                blockValue = 3; //Grass
            }
            else if (yPos <= terrainHeight && yPos > terrainHeight - 4)
            {
                blockValue = 5; // Dirt
            }
            else if (yPos > terrainHeight)
            {
                return(0); // Air
            }
            else
            {
                blockValue = 2; //Stone
            }

            // ORE TERRAIN PASS
            if (blockValue == 2)
            {
                foreach (Lode lode in biome.lodes)
                {
                    if (yPos >= lode.minHeight && yPos <= lode.maxHeight)
                    {
                        if (Terrian.FBM3D(pos.x, pos.y, pos.z, lode.offset, lode.octaves, (int)lode.persistance, lode.scale, lode.threshold))
                        {
                            blockValue = lode.BlockID;
                        }
                    }
                }
            }


            // TREE TERRAIN PASS
            if (yPos == terrainHeight)
            {
                if (Terrian.TreeGeneration(new Vector2(pos.x, pos.z), 0, biome.treeZoneScale) > biome.treeZoneThreshold)
                {
                    if (Terrian.TreeGeneration(new Vector2(pos.x, pos.z), 0, biome.treePlacementScale) > biome.treeZonePlacementThreshold)
                    {
                        modifications.Enqueue(Structure.MakeTree(pos, biome.minTreeHeight, biome.maxTreeHeight));
                    }
                }
            }
            return(blockValue);
        }