protected IBiome ChooseBiome(float value, out IBiome secondBiome)
        {

            secondBiome = null;
            bool betweenPossible = false;
            for (int i = 0; i < SubBiomes.Count; i++)
            {
                if (betweenPossible && value < SubBiomes[i].MinValue)
                {
                    secondBiome = SubBiomes[i];
                    return SubBiomes[i - 1];
                }
                else if (SubBiomes[i].MaxValue >= value && SubBiomes[i].MinValue <= value)
                    return SubBiomes[i];
                betweenPossible = (value > SubBiomes[i].MaxValue);
            }
            return null;
        }
 protected float CalculateInterpolationValue(float region, IBiome biome1, IBiome biome2)
 {
     if (biome2 != null)
     {
         float diff = biome2.MinValue - biome1.MaxValue;
         region -= biome1.MaxValue;
         region /= diff;
         return CurveFunction(region);
     }
     else if (biome1 != null)
     {
         return 0f;
     }
     return 0f;
 }
        protected float CalculateInterpolationValue(float region, out IBiome biome1, out IBiome biome2)
        {
            biome1 = ChooseBiome(region, out biome2);

            return CalculateInterpolationValue(region, biome1, biome2);
        }
 BiomeElement GetBiomeElement(Chunk chunk, IBiome biome, int x, int z)
 {
     var absoluteX = chunk.GetAbsoluteBlockPositionX(x);
     var absoluteZ = chunk.GetAbsoluteBlockPositionZ(z);
     return biome.GetBiomeElement(absoluteX, absoluteZ);
 }
Beispiel #5
0
        public void GetRandomBiome(ref IBiome biome){

            if (r.Next(Utility.RANDOM_VALUE_MAX) < Utility.RANDOM_VALUE_MAX / Utility.NUMBER_OF_BIOMES)
                biome = new FlatlandBiome(this, r);
            else
                biome = new HillsBiome(this, r);
        }