コード例 #1
0
 public override void Decorate(ChunkColumn chunk, BiomeBase biome)
 {
     /*	var trees = ExperimentalV2Generator.GetRandomNumber(3, 8);
      * var treeBasePositions = new int[trees, 2];
      *
      * for (var t = 0; t < trees; t++)
      * {
      *      var x = ExperimentalV2Generator.GetRandomNumber(1, 16);
      *      var z = ExperimentalV2Generator.GetRandomNumber(1, 16);
      *      treeBasePositions[t, 0] = x;
      *      treeBasePositions[t, 1] = z;
      * }
      * for (int y = ExperimentalV2Generator.WaterLevel; y < 256; y++)
      * {
      *      for (var pos = 0; pos < trees; pos++)
      *      {
      *              if (chunk.GetBlock(treeBasePositions[pos, 0], y, treeBasePositions[pos, 1]) == biome.TopBlock.Id)
      *              {
      *                              var meta = ExperimentalV2Generator.GetRandomNumber(0, 8);
      *                              chunk.SetBlock(treeBasePositions[pos, 0], y + 1, treeBasePositions[pos, 1],
      *                                      new Block(38) {Metadata = (ushort) meta});
      *              }
      *      }
      * }*/
 }
コード例 #2
0
ファイル: ChunkManager.cs プロジェクト: moor9140/Sisyphus
    /*
     *      Update
     *
     *      Purpose: Each tick, update the biome if neccesary, and load a new chunk if neccessary.
     */
    void Update()
    {
        position = (int)Mathf.Round(player.transform.position.x / Chunk.CHUNK_SIZE);
        if (position % 10 == 0 && position > furthestRendered)
        {
            //Update biome based on noise function.
            float result = Mathf.PerlinNoise((float)position, this.seed) % 0.01f;
            if (result < 0.0025f)
            {
                currentBiome = grass;
            }
            else if (result < 0.005f)
            {
                currentBiome = desert;
            }
            else if (result < 0.0075f)
            {
                currentBiome = hell;
            }
            else
            {
                currentBiome = snow;
            }
        }

        //Render the chunk we're at if it hasn't been already.
        if (position > furthestRendered)
        {
            RenderChunk(GenerateChunk(position, 0.05f), position);
        }
        furthestRendered = position;
    }
コード例 #3
0
ファイル: ChunkManager.cs プロジェクト: marzeverett/Sisyphus
    void Update()
    {
        position = (int)Mathf.Round(player.transform.position.x / Chunk.CHUNK_SIZE);
        if (position % 10 == 0 && position != lastPosition)
        {
            switch (Random.Range(0, 4))             //should be based on noise
            {
            case 0:
                currentBiome = grass;
                break;

            case 1:
                currentBiome = desert;
                break;

            case 2:
                currentBiome = hell;
                break;

            case 3:
                currentBiome = snow;
                break;
            }
        }

        if (lastPosition != position)
        {
            RenderChunk(GenerateChunk(position, 0.05f), position);
        }
        lastPosition = position;
    }
コード例 #4
0
 public override void Decorate(ChunkColumn chunk, BiomeBase biome)
 {
     for (var x = 0; x < 16; x++)
     {
         for (var z = 0; z < 16; z++)
         {
             //var blockbiome = chunk.BiomeId[x*16 + z];
             //if (BiomeManager.GetBiomeById(blockbiome).Temperature < 2.0f) //If the temperature is below 2.0F create lakes.
             //{
             //Check for temperature.
             for (var y = 0; y < NetherWorldProvider.WaterLevel; y++)
             {
                 //Lake generation
                 if (y < NetherWorldProvider.WaterLevel)
                 {
                     if (chunk.GetBlock(x, y + 1, z) == 0)
                     {
                         if (y < NetherWorldProvider.WaterLevel - 3)
                         {
                             chunk.SetBlock(x, y + 1, z, new BlockStationaryLava());                                     //Water
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #5
0
        private void DecorateTrees(ChunkColumn chunk, BiomeBase biome)
        {
            var trees             = StandardWorldProvider.GetRandomNumber(biome.MinTrees, biome.MaxTrees);
            var treeBasePositions = new int[trees, 2];

            for (var t = 0; t < trees; t++)
            {
                var x = new Random().Next(1, 16);
                var z = new Random().Next(1, 16);
                treeBasePositions[t, 0] = x;
                treeBasePositions[t, 1] = z;
            }

            for (var y = StandardWorldProvider.WaterLevel + 2; y < 256; y++)
            {
                for (var pos = 0; pos < trees; pos++)
                {
                    if (treeBasePositions[pos, 0] < 14 && treeBasePositions[pos, 0] > 4 && treeBasePositions[pos, 1] < 14 &&
                        treeBasePositions[pos, 1] > 4)
                    {
                        if (chunk.GetBlock(treeBasePositions[pos, 0], y + 1, treeBasePositions[pos, 1]) == biome.TopBlock.Id)
                        {
                            GenerateTree(chunk, treeBasePositions[pos, 0], y + 1, treeBasePositions[pos, 1], biome);
                        }
                    }
                }
            }
        }
コード例 #6
0
        public static Dictionary <BiomeBase, double> GetBiomes(float temp, float rain)
        {
            if (temp < -1f || temp > 2f || rain < 0f || rain > 1f)
            {
                Debug.WriteLine($"Temp: {temp} Rain: {rain}");
            }

            //return Biomes.Where(x => x.Id != 8 && x.Id != 9 && x.Id <= 39).OrderBy(x => GetSquaredDistance(x, temp, rain)).Take(3).ToArray();

            //	Debug.WriteLine($"Temp: {temp} Rain: {rain}");
            double threshold = 1000.0;
            Dictionary <BiomeBase, double> biomes = new Dictionary <BiomeBase, double>(3);

            BiomeBase closestBiome = null, secondClosestBiome = null, thirdClosestBiome = null;
            double    closestDist = 10000000, secondClosestDist = 10000000, thirdClosestDist = 10000000;

            foreach (BiomeBase biome in Biomes.Where(x => x.Id != 8 && x.Id != 9).OrderBy(x => GetSquaredDistance(x, temp, rain)).Take(3))
            {
                double dist = GetSquaredDistance(biome, temp, rain);

                if (dist < closestDist)
                {
                    thirdClosestDist  = secondClosestDist; thirdClosestBiome = secondClosestBiome;
                    secondClosestDist = closestDist; secondClosestBiome = closestBiome;
                    closestDist       = dist; closestBiome = biome;
                }

                else if (dist < secondClosestDist)
                {
                    if (dist >= threshold)
                    {
                        continue;                                        //We don't want to calculate the noise values for biomes that have almost no influence
                    }
                    thirdClosestDist  = secondClosestDist; thirdClosestBiome = secondClosestBiome;
                    secondClosestDist = dist; secondClosestBiome = biome;
                }

                else if (dist < thirdClosestDist)
                {
                    if (dist >= threshold)
                    {
                        continue;
                    }
                    thirdClosestDist = dist; thirdClosestBiome = biome;
                }
            }

            biomes.Add(closestBiome, closestDist);
            if (secondClosestBiome != null)
            {
                biomes.Add(secondClosestBiome, secondClosestDist);
            }
            if (thirdClosestBiome != null)
            {
                biomes.Add(thirdClosestBiome, thirdClosestDist);
            }

            return(biomes);
        }
コード例 #7
0
 private void GenerateTree(ChunkColumn chunk, int x, int treebase, int z, BiomeBase biome)
 {
     if (biome.TreeStructures.Length > 0)
     {
         var value = StandardWorldProvider.GetRandomNumber(0, biome.TreeStructures.Length);
         biome.TreeStructures[value].Create(chunk, x, treebase, z);
     }
 }
コード例 #8
0
        public override void Decorate(ChunkColumn chunk, BiomeBase biome)
        {
            for (var x = 0; x < 16; x++)
            {
                for (var z = 0; z < 16; z++)
                {
                    //var blockbiome = chunk.BiomeId[x*16 + z];
                    //if (BiomeManager.GetBiomeById(blockbiome).Temperature < 2.0f) //If the temperature is below 2.0F create lakes.
                    //{
                    //Check for temperature.
                    for (var y = 0; y < StandardWorldProvider.WaterLevel; y++)
                    {
                        //Lake generation
                        if (y < StandardWorldProvider.WaterLevel)
                        {
                            if (chunk.GetBlock(x, y, z) == 2 || chunk.GetBlock(x, y, z) == 3)                             //Grass or Dirt?
                            {
                                if (StandardWorldProvider.GetRandomNumber(1, 40) == 1 && y < StandardWorldProvider.WaterLevel - 4)
                                {
                                    chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(82));                                     //Clay
                                }
                                else
                                {
                                    chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(12));           //Sand
                                    chunk.BiomeId[x * 16 + z] = 16;                                   //Beach
                                }
                            }
                            if (chunk.GetBlock(x, y + 1, z) == 0)
                            {
                                if (y < StandardWorldProvider.WaterLevel - 3)
                                {
                                    chunk.SetBlock(x, y + 1, z, BlockFactory.GetBlockById(8));       //Water
                                    chunk.BiomeId[x * 16 + z] = 0;                                   //Ocean
                                }
                            }
                        }
                    }
                    //}

                    /*else //Fill up with sand
                     * {
                     *      for (var y = 0; y < ExperimentalV2Generator.WaterLevel; y++)
                     *      {
                     *              if (y < ExperimentalV2Generator.WaterLevel)
                     *              {
                     *                      if (chunk.GetBlock(x, y, z) == 2 || chunk.GetBlock(x, y, z) == 3 || chunk.GetBlock(x,y,z) == 0) //Grass or Dirt?
                     *                      {
                     *                                      chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(12)); //Sand
                     *                                      //chunk.BiomeId[x * 16 + z] = 16; //Beach
                     *                      }
                     *              }
                     *      }
                     * }*/
                }
            }
        }
コード例 #9
0
 public override void Decorate(ChunkColumn chunk, BiomeBase biome, int x, int z)
 {
     for (var y = 1; y < 6; y++)
     {
         if (StandardWorldProvider.GetRandomNumber(0, 5) == 1)
         {
             chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(7));
         }
     }
 }
コード例 #10
0
ファイル: Chunk.cs プロジェクト: DrSmCraft/RPGGame
        public void GenerateTiles()
        {
            //Voronoi biomeNiose = new Voronoi();
            //biomeNiose.Seed = Constants.Seed;

            //RidgedMulti baseNoise = new RidgedMulti();
            //baseNoise.Seed = Constants.Seed;
            //baseNoise.OctaveCount = 1;

            //Perlin topNoise = new Perlin();
            //topNoise.Seed = Constants.Seed;
            //topNoise.OctaveCount = 10;
            //topNoise.Persistence = 0.3f;
            //topNoise.Frequency = 2;
            //topNoise.Lacunarity = 1;


            //Add noise = new Add();
            //noise.Source0 = baseNoise;
            //noise.Source1 = topNoise;

            Perlin tempNoise = new Perlin();

            tempNoise.Seed = Constants.Seed;

            Perlin humidityNoise = new Perlin();

            humidityNoise.Seed = Constants.Seed + 1;

            Normalizer norm = new Normalizer(0.0f, 1.0f);

            float scale = .01f;             // 0.001f

            for (var y = 0; y < Constants.ChunkDim.Y; y++)
            {
                for (var x = 0; x < Constants.ChunkDim.X; x++)
                {
                    //Vector3 simplexLoc = new Vector3((x + (Position.X * Constants.ChunkDim.X)) * scale, (y + (Position.Y * Constants.ChunkDim.Y)) * scale, 0);
                    //double tileId = baseNoise.GetValue(simplexLoc.X, simplexLoc.Y, simplexLoc.Z);
                    //double biomeId = biomeNiose.GetValue((x + (Position.X * Constants.ChunkDim.X)) * scale, (y + (Position.Y * Constants.ChunkDim.Y)) * scale, 0);
                    //biomeId = ((biomeId + 1) / 2) * BiomeMap.BiomeDict.Count;
                    //tileId = BiomeMap.BiomeDict[(int)biomeId].GetTileAtValue(norm.Normalize((float)(tileId + 1) / 2)).Id;
                    float xValue = (x + (Position.X * Constants.ChunkDim.X)) * scale;
                    float yValue = (y + (Position.Y * Constants.ChunkDim.Y)) * scale;

                    float tempValue     = norm.Normalize((float)(tempNoise.GetValue(xValue, yValue, 0) + 1) / 2);
                    float humidityValue = norm.Normalize((float)(humidityNoise.GetValue(xValue, yValue, 0) + 1) / 2);
                    //Logger.Manager.Log(tempValue + "       " + humidityValue);
                    //BiomeBase biome = BiomeMap.BiomeDict[BiomeMap.BiomeNames["Swamp"]];
                    BiomeBase biome = BiomeMap.GetBiome(tempValue, humidityValue);

                    Tiles[y, x] = (int)biome.GetTileAtValue(x, y).Id;
                }
            }
        }
コード例 #11
0
ファイル: ChunkManager.cs プロジェクト: marzeverett/Sisyphus
 void Start()
 {
     grass        = new BiomeGrass();
     snow         = new BiomeSnow();
     desert       = new BiomeDesert();
     hell         = new BiomeHell();
     player       = GameObject.FindGameObjectWithTag("Player");
     seed         = Random.Range(0f, 1f);
     position     = 0;
     lastPosition = -1;
 }
コード例 #12
0
ファイル: GrassDecorator.cs プロジェクト: SharperMC/SharperMC
 public override void Decorate(ChunkColumn chunk, BiomeBase biome, int x, int z)
 {
     for (var y = StandardWorldProvider.WaterLevel; y < 256; y++)
     {
         if (StandardWorldProvider.GetRandomNumber(0, 10) == 5)
         {
             if (chunk.GetBlock(x, y, z) == biome.TopBlock.Id)
             {
                 chunk.SetBlock(x, y + 1, z, new Block(31)
                 {
                     Metadata = 1
                 });
             }
         }
     }
 }
コード例 #13
0
 public override void Decorate(ChunkColumn chunk, BiomeBase biome, int x, int z)
 {
     if (x < 15 && x > 3 && z < 15 && z > 3)
     {
         for (var y = StandardWorldProvider.WaterLevel; y < 256; y++)
         {
             if (StandardWorldProvider.GetRandomNumber(0, 13) == 5)
             {
                 if (chunk.GetBlock(x, y + 1, z) == biome.TopBlock.Id)
                 {
                     GenerateTree(chunk, x, y + 1, z, biome);
                 }
             }
         }
     }
 }
コード例 #14
0
ファイル: OreDecorator.cs プロジェクト: wickedlizerd/SharpMC
        public override void Decorate(ChunkColumn chunk, BiomeBase biome, int x, int z)
        {
            _chunke = chunk;
            for (var y = 1 /*No need to check first layer :p*/; y < 128 /*Nothing above this*/; y++)
            {
                if (chunk.GetBlock(x, y, z) == 1)
                {
                    if (y < 128)
                    {
                        GenerateCoal(x, y, z);
                    }

                    if (y < 64)
                    {
                        GenerateIron(x, y, z);
                    }

                    if (y < 29)
                    {
                        GenerateGold(x, y, z);
                    }

                    if (y < 23)
                    {
                        GenerateLapis(x, y, z);
                    }

                    if (y < 16)
                    {
                        if (y > 12)
                        {
                            if (StandardWorldProvider.GetRandomNumber(0, 3) == 2)
                            {
                                GenerateDiamond(x, y, z);
                            }
                        }
                        else
                        {
                            GenerateDiamond(x, y, z);
                        }
                    }
                }
            }
        }
コード例 #15
0
ファイル: LavaDecorator.cs プロジェクト: realTobby/SharpMC
 public override void Decorate(ChunkColumn chunk, BiomeBase biome)
 {
     for (var x = 0; x < 16; x++)
     {
         for (var z = 0; z < 16; z++)
         {
             for (var y = 0; y < LavaLevel; y++)
             {
                 //Lake generation
                 if (y < LavaLevel)
                 {
                     if (chunk.GetBlock(x, y + 1, z) == 0)
                     {
                         chunk.SetBlock(x, y + 1, z, BlockFactory.GetBlockById(10));                                 //Lava
                     }
                 }
             }
         }
     }
 }
コード例 #16
0
 public override void Decorate(ChunkColumn chunk, BiomeBase biome, int x, int z)
 {
     for (var y = StandardWorldProvider.WaterLevel; y < 256; y++)
     {
         if (StandardWorldProvider.GetRandomNumber(0, 15) == 5)
         {
             if (chunk.GetBlock(x, y, z) == biome.TopBlock.Id)
             {
                 //var meta = ExperimentalV2Generator.GetRandomNumber(0, 8);
                 chunk.SetBlock(x, y + 1, z, new Block(175)
                 {
                     Metadata = 0
                 });
                 chunk.SetBlock(x, y + 2, z, new Block(175)
                 {
                     Metadata = 1
                 });
             }
         }
     }
 }
コード例 #17
0
        private void Callback(object state)
        {
            if (Api == null)
            {
                return;
            }
            foreach (var player in Api.PlayerManager.GetPlayers())
            {
                if (!player.IsSpawned)
                {
                    continue;
                }

                var pos   = player.KnownPosition.GetCoordinates3D();
                var chunk = player.Level.GetChunk(pos, true);

                if (chunk == null)
                {
                    continue;
                }

                var       biome  = chunk.GetBiome(pos.X - (chunk.X * 16), pos.Z - (chunk.Z * 16));
                BiomeBase result = null;
                if (player.Level.WorldProvider is DebugWorldProvider debugWorldProvider)
                {
                    if (debugWorldProvider.Generator is OverworldGeneratorV2 gen)
                    {
                        result = gen.BiomeProvider.GetBiome(biome);
                    }
                }

                if (result == null)
                {
                    result = BiomeUtils.GetBiomeById(biome);
                }

                player.SendTitle($"Biome: {result.Name}, Temperature: {result.Temperature}, Downfall: {result.Downfall}", TitleType.ActionBar, 0, 0, 25);
            }
        }
コード例 #18
0
ファイル: ChunkManager.cs プロジェクト: deschafer/Sisyphus
    /*
     *      Update
     *
     *      Purpose: Each tick, update the biome if neccesary, and load a new chunk if neccessary. Additionally, do the stress test.
     */
    void Update()
    {
        position = (int)Mathf.Round(player.transform.position.x / Chunk.CHUNK_SIZE);
        if (position % 10 == 0 && position > furthestRendered)
        {
            //Update biome based on noise function.
            float result = Mathf.PerlinNoise((float)position, this.seed) % 0.01f;
            if (result < 0.0025f)
            {
                currentBiome = grass;
            }
            else if (result < 0.005f)
            {
                currentBiome = desert;
            }
            else if (result < 0.0075f)
            {
                currentBiome = hell;
            }
            else
            {
                currentBiome = snow;
            }
        }

        //Render the chunk we're at if it hasn't been already.
        if (position > furthestRendered)
        {
            RenderChunk(GenerateChunk(position, 0.05f), position);
        }
        furthestRendered = position;

        // fps += 1f / Time.deltaTime;
        // fps /= 2f;
        // if(fps < minFps)
        //  Debug.Log("Stress test failed.");
        // else
        //  Debug.Log("Stress test passed.");
    }
コード例 #19
0
 private void DecorateTrees(ChunkColumn chunk, BiomeBase biome)
 {
     for (var x = 0; x < 16; x++)
     {
         for (var z = 0; z < 16; z++)
         {
             for (var y = StandardWorldProvider.WaterLevel; y < 256; y++)
             {
                 if (StandardWorldProvider.GetRandomNumber(0, 13) == 5)
                 {
                     //The if is so we don't have 'f****d up' trees xD
                     if (x < 15 && x > 3 && z < 15 && z > 3)
                     {
                         if (chunk.GetBlock(x, y + 1, z) == biome.TopBlock.Id)
                         {
                             GenerateTree(chunk, x, y + 1, z, biome);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #20
0
ファイル: WaterDecorator.cs プロジェクト: SharperMC/SharperMC
 public override void Decorate(ChunkColumn chunk, BiomeBase biome)
 {
     for (var x = 0; x < 16; x++)
     {
         for (var z = 0; z < 16; z++)
         {
             //Check for temperature.
             for (var y = 0; y < StandardWorldProvider.WaterLevel; y++)
             {
                 //Lake generation
                 if (y < StandardWorldProvider.WaterLevel)
                 {
                     if (chunk.GetBlock(x, y, z) == 2 || chunk.GetBlock(x, y, z) == 3)                             //Grass or Dirt?
                     {
                         if (StandardWorldProvider.GetRandomNumber(1, 40) == 1 && y < StandardWorldProvider.WaterLevel - 4)
                         {
                             chunk.SetBlock(x, y, z, BlockFactory.GetBlockById(82));                                     //Clay
                         }
                         else
                         {
                             chunk.SetBlock(x, y, z, new BlockSand());                         //Sand
                             chunk.BiomeId[x * 16 + z] = 16;                                   //Beach
                         }
                     }
                     if (chunk.GetBlock(x, y + 1, z) == 0)
                     {
                         if (y < StandardWorldProvider.WaterLevel - 3)
                         {
                             chunk.SetBlock(x, y + 1, z, new BlockFlowingWater());            //Water
                             chunk.BiomeId[x * 16 + z] = 0;                                   //Ocean
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #21
0
        public async Task <BiomeBase[]> CalculateBiomes(float[] baseHeight, int chunkX, int chunkZ)
        {
            // chunkX *= 16;
            //
            // chunkZ *= 16;
            return(await Task.Run(() =>
            {
                int minX = (chunkX * 16);
                int minZ = (chunkZ * 16);
                var maxX = ((chunkX + 1) << 4);
                var maxZ = ((chunkZ + 1) << 4);



                BiomeBase[] rb = new BiomeBase[16 * 16];

                for (int x = 0; x < 16; x++)
                {
                    float rx = MathUtils.Lerp(minX, maxX, (1f / 16f) * x);
                    for (int z = 0; z < 16; z++)
                    {
                        var rz = MathUtils.Lerp(minZ, maxZ, (1f / 16f) * z);
                        var idx = GetIndex(x, z);

                        var biome = GetBiome(rx, rz, baseHeight[idx]);

                        //  var min = MathUtils.ConvertRange(-2f, 2f, 0f, 128f, biome.MinHeight);
                        // var max = MathUtils.ConvertRange(-2f, 2f, 0f, 128f, biome.MaxHeight);

                        rb[idx] = biome;
                    }
                }

                return rb;
            }));
        }
コード例 #22
0
 public override void Decorate(ChunkColumn chunk, BiomeBase biome)
 {
     for (var x = 0; x < 16; x++)
     {
         for (var z = 0; z < 16; z++)
         {
             //Check for temperature.
             for (var y = 0; y < NetherWorldProvider.WaterLevel; y++)
             {
                 //Lake generation
                 if (y < NetherWorldProvider.WaterLevel)
                 {
                     if (chunk.GetBlock(x, y + 1, z) == 0)
                     {
                         if (y < NetherWorldProvider.WaterLevel - 3)
                         {
                             chunk.SetBlock(x, y + 1, z, new BlockStationaryLava());                                     //Water
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #23
0
 public abstract void Decorate(ChunkColumn column, int chunkX, int chunkZ, BiomeBase biome, float[] thresholdMap, int x, int y, int z, bool surface, bool isBelowMaxHeight);
コード例 #24
0
        private void FixBiomes(ChunkColumn column,
                               ChunkLandscape landscape, int[] neighboring)
        {
            var orginalBiomes = landscape.Biome.ToArray();

            ISimplexData2D jitterData = SimplexData2D.NewDisk();

            BiomeBase[] jitteredBiomes = new BiomeBase[256];
            BiomeBase   jitterbiome, actualbiome;

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    int x = (column.X * 16) + i;
                    int z = (column.Z * 16) + j;
                    this.SimplexInstance(0).GetValue(x, z, jitterData);
                    int pX = (int)Math.Round(x + jitterData.GetDeltaX() * BlendRadius);
                    int pZ = (int)Math.Round(z + jitterData.GetDeltaY() * BlendRadius);
                    actualbiome = landscape.Biome[(x & 15) * 16 + (z & 15)];
                    jitterbiome = landscape.Biome[(pX & 15) * 16 + (pZ & 15)];
                    jitteredBiomes[i * 16 + j] = (actualbiome.Config.SurfaceBlendIn && jitterbiome.Config.SurfaceBlendOut) ? jitterbiome : actualbiome;
                }
            }


            BiomeBase realisticBiome;
            int       realisticBiomeId;


            var noise = landscape.Noise;
            var riverStrength = landscape.River;

            // currently just stuffs the genLayer into the jitter;
            for (int i = 0; i < MAX_BIOMES; i++)
            {
                realisticBiome = orginalBiomes[i];

                bool canBeRiver = riverStrength[i] > 0.7;

                if (noise[i] > 61.5)
                {
                    // replace
                    jitteredBiomes[i] = realisticBiome;
                }
                else
                {
                    // check for river
                    if (canBeRiver && (realisticBiome.Type & BiomeType.Ocean) == 0 && (realisticBiome.Type & BiomeType.Swamp) == 0)
                    {
                        // make river
                        jitteredBiomes[i] = BiomeProvider.GetBiome(realisticBiome.GetRiverBiome());
                    }
                    else
                    {
                        // replace
                        jitteredBiomes[i] = realisticBiome;
                    }
                }
            }

            //  SmoothingSearchStatus beachSearch = new SmoothingSearchStatus(BeachBiome);
            SmoothingSearchStatus landSearch = new SmoothingSearchStatus(LandBiome);

            /*  beachSearch.SetNotHunted();
             * beachSearch.SetAbsent();
             *
             * landSearch.SetNotHunted();
             * landSearch.SetAbsent();*/
            // beachSearch.Hunt(neighboring);
            landSearch.Hunt(neighboring);

            float beachTop = 64.5f;

            for (int i = 0; i < MAX_BIOMES; i++)
            {
                float beachBottom = 61.5f;

                if (noise[i] < beachBottom || noise[i] > RiverAdjusted(beachTop, riverStrength[i]))
                {
                    continue;// this block isn't beach level
                }

                if ((jitteredBiomes[i].Type & BiomeType.Swamp) != 0)
                {
                    continue;
                }

                /* if (beachSearch.IsNotHunted())
                 * {
                 *   beachSearch.Hunt(neighboring);
                 *   landSearch.Hunt(neighboring);
                 * }*/

                //   int foundBiome = beachSearch.Biomes[i];
                // if (foundBiome != -1) {
                int nearestLandBiome = landSearch.Biomes[i];

                if (nearestLandBiome > -1)
                {
                    var foundBiome = BiomeProvider.GetBiome(nearestLandBiome).GetBeachBiome();
                    var biome      = BiomeProvider.GetBiome(foundBiome);

                    if (biome != null && biome.Terrain != null && biome.Surface != null)
                    {
                        jitteredBiomes[i] = biome;
                    }
                }

                //
                // }
            }

            landscape.Biome = jitteredBiomes;
        }
コード例 #25
0
 public abstract void Decorate(int chunkX, int chunkZ, int[] blocks, int[] metadata, BiomeBase biome, float[] thresholdMap, int x, int y, int z, bool surface, bool isBelowMaxHeight);
コード例 #26
0
        public override void Decorate(int chunkX, int chunkZ, int[] blocks, int[] metadata, BiomeBase biome, float[] thresholdMap, int x, int y, int z, bool surface, bool isBelowMaxHeight)
        {
            if (y > OverworldGenerator.WaterLevel && y > 32)
            {
                return;
            }

            //var density = thresholdMap[x + 16*(y + 256*z)];

            /*var bid = column.GetBlock(x, y, z);
             * if (bid == 0 /* || density < 0) //If this block is supposed to be air.
             * {
             *  if (surface && biome.Temperature <= 0f)
             *  {
             *      column.SetBlock(x, y, z, 79);
             *  }
             *  else
             *  {
             *      column.SetBlock(x, y, z, 8);
             *  }
             * }
             * else if (surface)
             * {
             *  column.SetBlock(x,y,z, 12);
             * }*/

            //	if (y >= SurvivalWorldProvider.WaterLevel) return;

            var block = blocks[OverworldGenerator.GetIndex(x, y, z)];

            if (surface)
            {
                blocks[OverworldGenerator.GetIndex(x, y, z)] = 12;
                //column.SetBlock(x, y, z, 12); //Sand
            }
            else if (y <= OverworldGenerator.WaterLevel && block == 0)
            {
                if (biome.Temperature <= 0f && y == OverworldGenerator.WaterLevel)
                {
                    blocks[OverworldGenerator.GetIndex(x, y, z)] = 79;
                    // column.SetBlock(x, y, z, 79); //Ice
                }
                else
                {
                    blocks[OverworldGenerator.GetIndex(x, y, z)] = 8;
                    //column.SetBlock(x, y, z, 8); //Water
                }
            }
        }
コード例 #27
0
 public override void Decorate(ChunkColumn chunk, BiomeBase biome)
 {
 }
コード例 #28
0
        public override void Decorate(ChunkColumn column, int chunkX, int chunkZ, BiomeBase biome, float[] thresholdMap, int x, int y, int z, bool surface,
                                      bool isBelowMaxHeight)
        {
            try
            {
                var currentTemperature = biome.Temperature;
                if (y > 64)
                {
                    int distanceToSeaLevel = y - 64;
                    currentTemperature = biome.Temperature - (0.00166667f * distanceToSeaLevel);
                }

                int rx = chunkX * 16 + x;
                int rz = chunkZ * 16 + z;

                bool generated = false;
                if (surface && y >= Preset.SeaLevel)
                {
                    var noise = Simplex.Noise(rx, rz, Math.Min(biome.Downfall * 0.32f, 0.03f), 0.5, true);
                    if (x >= 3 && x <= 13 && z >= 3 && z <= 13)
                    {
                        Structure tree = null;
                        //if (biome.Config.)
                        if (biome.Downfall <= 0f && biome.Temperature >= 2f)
                        {
                            if (GetRandom(32) == 16)
                            {
                                var randValue = GetRandom(18);
                                if (randValue >= 0 && randValue <= 2)                                 //3 tall cactus
                                {
                                    tree = new CactusStructure(3);
                                }
                                else if (randValue > 2 && randValue <= 5)                                 // 2 tall cactus
                                {
                                    tree = new CactusStructure(2);
                                }
                                else if (randValue > 5 && randValue <= 11)                                 // 1 tall cactus
                                {
                                    tree = new CactusStructure(1);
                                }
                            }
                        }

                        if (tree == null && biome.Downfall >= 0 && (noise > (0.5f + (y / 512f))))
                        {
                            if (currentTemperature >= 1f && biome.Downfall >= 0.4f)
                            {
                                if (GetRandom(8) == 4)
                                {
                                    tree = new LargeJungleTree();
                                }
                                else
                                {
                                    tree = new SmallJungleTree();
                                }
                            }

                            /*	else if (currentTemperature >= 0.7F && biome.Downfall >= 0.2f)
                             *      {
                             *              tree = new OakTree(true);
                             *      }*/
                            else if (currentTemperature >= 0.7F && biome.Downfall < 0.2f)
                            {
                                tree = new AcaciaTree();
                            }
                            else if (currentTemperature > 0.25f && biome.Downfall > 0f)
                            {
                                if (biome.Name.Contains("Birch") || GetRandom(16) == 8)
                                {
                                    tree = new BirchTree();
                                }
                                else
                                {
                                    tree = new OakTree();
                                }
                            }
                            else if (currentTemperature <= 0.25f && biome.Downfall > 0f)
                            {
                                tree = new PineTree();
                            }
                        }

                        if (tree != null)
                        {
                            if (y + 1 < 254)
                            {
                                tree.Create(column, x, y + 1, z);
                            }
                            generated = true;
                        }
                    }

                    if (!generated)
                    {
                        if (noise > 0.5)                         //Threshold 1
                        {
                            /*if (currentTemperature > 0.3f && currentTemperature < 1.5f && biome.Downfall >= 0.85f)
                             * {
                             *      column.SetBlock(x, y + 1, z, 18); //Leaves
                             *      column.SetMetadata(x, y + 1, z, 3); //Jungle Leaves
                             * }
                             * else*/
                            if (currentTemperature > 0.3f && currentTemperature < 1.5f && biome.Downfall > 0)
                            {
                                var blockBeneath = column.GetBlockId(x, y, z);                                // column.GetBlock(x, y, z);

                                var sugarPosibility = GetRandom(18);
                                if (/*sugarPosibility <= 11*/ noise > 0.75f &&
                                    (blockBeneath == 3 || blockBeneath == 2 || blockBeneath == 12) &&
                                    IsValidSugarCaneLocation(column, x, y, z))
                                {
                                    int height = 1;
                                    if (sugarPosibility <= 2)
                                    {
                                        height = 3;
                                    }
                                    else if (sugarPosibility <= 5)
                                    {
                                        height = 2;
                                    }

                                    //var growth = Rnd.Next(0x1, 0x15);
                                    for (int mY = y + 1; mY < y + 1 + height; mY++)
                                    {
                                        //column.SetBlock(x, mY, z, 83); //SugarCane
                                        //blocks[OverworldGenerator.GetIndex(x, mY, z)] = 83;

                                        if (mY == y + 1 + height)
                                        {
                                            //metadata[OverworldGenerator.GetIndex(x, mY, z)] = (byte) Rnd.Next(0, 15);
                                            //column.SetMetadata(x, mY, z, (byte) Rnd.Next(0, 15));
                                        }
                                        else
                                        {
                                            //metadata[OverworldGenerator.GetIndex(x, mY, z)] = (byte) 0;
                                            //column.SetMetadata(x, mY, z, 0);
                                        }
                                    }
                                }
                                else if (noise > 0.8 && blockBeneath == 3 || blockBeneath == 2)                                 //If above 0.8, we generate flowers :)
                                {
                                    if (Simplex.Noise(rx, rz, 0.5f, 0.5f, true) > 0.5)
                                    {
                                        column.SetBlock(x, y + 1, z, new RedFlower()
                                        {
                                            FlowerType = FlowerTypes[GetRandom(FlowerTypes.Length - 1)]
                                        });
                                        //blocks[OverworldGenerator.GetIndex(x, y + 1, z)] = 38;
                                        //metadata[OverworldGenerator.GetIndex(x, y + 1, z)] = (byte) GetRandom(8);
                                        //column.SetBlock(x, y + 1, z, 38); //Poppy
                                        //column.SetMetadata(x, y + 1, z, (byte) GetRandom(8));
                                    }
                                    else
                                    {
                                        //	blocks[OverworldGenerator.GetIndex(x, y + 1, z)] = 37;
                                        //	column.SetBlock(x, y + 1, z, new Dan());
                                        //	column.SetBlock(x, y + 1, z, 37); //Dandelion
                                    }
                                }
                                else if (blockBeneath == 3 || blockBeneath == 2)
                                {
                                    column.SetBlock(x, y + 1, z, new Tallgrass());
                                    //blocks[OverworldGenerator.GetIndex(x, y + 1, z)] = 31;
                                    //metadata[OverworldGenerator.GetIndex(x, y + 1, z)] = (byte) 1;
                                    //column.SetBlock(x, y + 1, z, 31); //Grass
                                    //column.SetMetadata(x, y + 1, z, 1);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
コード例 #29
0
        public override void Decorate(ChunkColumn chunk, BiomeBase biome)
        {
            /*for (int x = 0; x < 16; x++)
             * {
             *      for (int z = 0; z < 16; z++)
             *      {
             *              for (int y = 0; y < 256; y++)
             *              {
             *                      if (chunk.GetBlock(x, y, z) == chunk.Biome.TopBlock.Id)
             *                      {
             *                              if (ExperimentalV2Generator.GetRandomNumber(0, 5) == 2)
             *                              {
             *                                      if (ExperimentalV2Generator.GetRandomNumber(0, 50) == 10)
             *                                      {
             *                                              chunk.SetBlock(x, y + 1, z, new Block(175) {Metadata = 2});
             *                                              chunk.SetBlock(x, y + 2, z, new Block(175) {Metadata = 2});
             *                                      }
             *                                      else
             *                                      {
             *                                              chunk.SetBlock(x, y + 1, z, new Block(31) {Metadata = 1});
             *                                      }
             *                              }
             *                      }
             *              }
             *      }
             * var trees = ExperimentalV2Generator.GetRandomNumber(10, 30);
             * var treeBasePositions = new int[trees, 2];
             *
             * for (var t = 0; t < trees; t++)
             * {
             *      var x = ExperimentalV2Generator.GetRandomNumber(1, 16);
             *      var z = ExperimentalV2Generator.GetRandomNumber(1, 16);
             *      treeBasePositions[t, 0] = x;
             *      treeBasePositions[t, 1] = z;
             * }
             * for (int y = ExperimentalV2Generator.WaterLevel; y < 256; y++)
             * {
             *      for (var pos = 0; pos < trees; pos++)
             *      {
             *              if (chunk.GetBlock(treeBasePositions[pos, 0], y, treeBasePositions[pos, 1]) == biome.TopBlock.Id)
             *              {
             *                      if (ExperimentalV2Generator.GetRandomNumber(0, 5) == 2)
             *                      {
             *                              //if (ExperimentalV2Generator.GetRandomNumber(0, 50) == 10)
             *                              //{
             *                              //	chunk.SetBlock(treeBasePositions[pos, 0], y + 1, treeBasePositions[pos, 1], new Block(175) { Metadata = 2 });
             *                              //	chunk.SetBlock(treeBasePositions[pos, 0], y + 2, treeBasePositions[pos, 1], new Block(175) { Metadata = 2 });
             *                              //}
             *                              //else
             *                              //{
             *                                      chunk.SetBlock(treeBasePositions[pos, 0], y + 1, treeBasePositions[pos, 1], new Block(31) { Metadata = 1 });
             *                              //}
             *                      }
             *              }
             *      }
             * }
             */

            //for (int y = ExperimentalV2Generator.WaterLevel; y < 256; y++)
            //{
            //	if (chunk.GetBlock(x, y, z) == biome.TopBlock.Id)
            //	{
            //	}
            //}
        }
コード例 #30
0
ファイル: Chunk.cs プロジェクト: marzeverett/Sisyphus
 public Chunk(int[,] grid, BiomeBase biome)
 {
     this.grid  = grid;
     this.biome = biome;
 }