Ejemplo n.º 1
0
 static BiomeEngine()
 {
     BiomeEngine.SecondaryBiomes = new List <SecondaryBiome>();
     BiomeEngine.TertiaryBiomes  = new List <TertiaryBiome>();
     foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
     {
         foreach (Type t in a.GetTypes())
         {
             if (typeof(SecondaryBiome).IsAssignableFrom(t) && !t.IsAbstract)
             {
                 BiomeEngine.SecondaryBiomes.Add(BiomeEngine.NewSB(t));
             }
         }
     }
     foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
     {
         foreach (Type t in a.GetTypes())
         {
             if (typeof(TertiaryBiome).IsAssignableFrom(t) && !t.IsAbstract)
             {
                 BiomeEngine.TertiaryBiomes.Add(BiomeEngine.NewTB(t));
             }
         }
     }
 }
Ejemplo n.º 2
0
        protected override int[] GenerateDataImpl(long x, long y, long width, long height)
        {
            if (this.Parents.Length < 4 || this.Parents[0] == null || this.Parents[1] == null || this.Parents[2] == null || this.Parents[3] == null)
            {
                return(new int[width * height]);
            }

            int[] biome       = this.Parents[0].GenerateData(x, y, width, height);
            int[] rainfall    = this.Parents[1].GenerateData(x, y, width, height);
            int[] temperature = this.Parents[2].GenerateData(x, y, width, height);
            int[] terrain     = this.Parents[3].GenerateData(x, y, width, height);
            int[] data        = new int[width * height];

            // Write out the secondary biomes.
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    try
                    {
                        // Normalize values.
                        int    nbiome   = biome[i + j * width];
                        double nrain    = (rainfall[i + j * width] - this.MinRainfall) / (double)(this.MaxRainfall - this.MinRainfall);
                        double ntemp    = (temperature[i + j * width] - this.MinTemperature) / (double)(this.MaxTemperature - this.MinTemperature);
                        double nterrain = (terrain[i + j * width] - this.MinTerrain) / (double)(this.MaxTerrain - this.MinTerrain);

                        // Store result.
                        data[i + j * width] = BiomeEngine.GetSecondaryBiomeForCell(nbiome, nrain, ntemp, nterrain);
                    }
                    catch (Exception)
                    {
                        // In case of overflow, underflow or divide by zero.
                        data[i + j * width] = 0;
                    }
                }
            }

            return(data);
        }
Ejemplo n.º 3
0
 public override Dictionary <int, LayerColor> GetLayerColors()
 {
     return(BiomeEngine.GetSecondaryBiomeBrushes());
 }