static CitiesEngine() { CitiesEngine.CityBiomes = new List <CityBiome>(); CitiesEngine.SecondaryCityBiomes = new List <SecondaryCityBiome>(); foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type t in a.GetTypes()) { if (typeof(CityBiome).IsAssignableFrom(t) && !t.IsAbstract) { CitiesEngine.CityBiomes.Add(CitiesEngine.NewCity(t)); } } } foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type t in a.GetTypes()) { if (typeof(SecondaryCityBiome).IsAssignableFrom(t) && !t.IsAbstract) { CitiesEngine.CityBiomes.Add(CitiesEngine.NewSecondary(t)); } } } }
public override Dictionary <int, LayerColor> GetLayerColors() { return(CitiesEngine.GetCityBiomeBrushes()); }
protected override int[] GenerateDataImpl(long x, long y, long z, long width, long height, long depth) { if (this.Parents.Length < 6 || this.Parents[0] == null || this.Parents[1] == null || this.Parents[2] == null || this.Parents[3] == null || this.Parents[4] == null || this.Parents[5] == null) { return(new int[width * height * depth]); } int[] citybiomes = this.Parents[0].GenerateData(x, y, z, width, height, depth); int[] biome = this.Parents[1].GenerateData(x, y, width, height); int[] soilfertility = this.Parents[2].GenerateData(x, y, width, height); int[] animaldensity = this.Parents[3].GenerateData(x, y, width, height); int[] oredensity = this.Parents[4].GenerateData(x, y, width, height); int[] rareoredensity = this.Parents[5].GenerateData(x, y, width, height); int[] data = new int[width * height * depth]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { for (int k = 0; k < depth; k++) { data[i + j * width + k * width * height] = citybiomes[i + j * width + k * width * height]; } } } // Write out the city biomes. for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { try { data[i + j * width] = 0; if (biome[i + j * width] != 0) { bool endloop = false; int citybiomecount = 0; while (endloop == false) { int k = 0; if (citybiomes[i + j * width + k * width * height] == 1) { citybiomecount++; k++; } else if (citybiomes[i + j * width + k * width * height] == -1) { endloop = true; } } // Normalize values. // int nbiome = biome[i + j * width]; double nsoilfertility = (soilfertility[i + j * width] - this.MinSoilFertility) / (double)(this.MaxSoilFertility - this.MinSoilFertility); double nanimaldensity = (animaldensity[i + j * width] - this.MinAnimalDensity) / (double)(this.MaxAnimalDensity - this.MinAnimalDensity); double noredensity = (oredensity[i + j * width] - this.MinOreDensity) / (double)(this.MaxOreDensity - this.MinOreDensity); double nrareoredensity = (rareoredensity[i + j * width] - this.MinRareOreDensity) / (double)(this.MaxRareOreDensity - this.MinRareOreDensity); // Store result. endloop = false; int citybiome = 0; while (endloop == false) { int temp = CitiesEngine.AddCityBiomeForCell(nsoilfertility, nanimaldensity, noredensity, nrareoredensity, citybiome, citybiomecount); if (temp != 0) { data[i + j * width + citybiome + 1 * width * height] = temp; citybiome++; data[i + j * width] = 1; } else { data[i + j * width + citybiome + 1 * width * height] = temp; endloop = true; } } } } catch (Exception) { // In case of overflow, underflow or divide by zero. data[i + j * width] = 0; } } } return(data); }
protected override int[] GenerateDataImpl(long x, long y, long z, long width, long height, long depth) { if (this.Parents.Length < 5 || this.Parents[0] == null || this.Parents[1] == null || this.Parents[2] == null || this.Parents[3] == null || this.Parents[4] == null) { return(new int[width * height * depth]); } int[] biome = this.Parents[0].GenerateData(x, y, width, height); int[] soilfertility = this.Parents[1].GenerateData(x, y, width, height); int[] animaldensity = this.Parents[2].GenerateData(x, y, width, height); int[] oredensity = this.Parents[3].GenerateData(x, y, width, height); int[] rareoredensity = this.Parents[4].GenerateData(x, y, width, height); int[] data = new int[width * height * depth]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { for (int k = 0; k < depth; k++) { data[i + j * width + k * width * height] = -1; } } } // Write out the city biomes. for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { try { data[i + j * width] = 0; // Have to remember to change this possibly for 3d placement (assuming that we are going to end up having different biomes at different z levels) if (biome[i + j * width] != 0) { // Normalize values. // int nbiome = biome[i + j * width]; double nsoilfertility = (soilfertility[i + j * width] - this.MinSoilFertility) / (double)(this.MaxSoilFertility - this.MinSoilFertility); double nanimaldensity = (animaldensity[i + j * width] - this.MinAnimalDensity) / (double)(this.MaxAnimalDensity - this.MinAnimalDensity); double noredensity = (oredensity[i + j * width] - this.MinOreDensity) / (double)(this.MaxOreDensity - this.MinOreDensity); double nrareoredensity = (rareoredensity[i + j * width] - this.MinRareOreDensity) / (double)(this.MaxRareOreDensity - this.MinRareOreDensity); // Store result. bool endloop = false; int citybiome = 0; while (endloop == false) { int temp = CitiesEngine.GetCityBiomeForCell(nsoilfertility, nanimaldensity, noredensity, nrareoredensity, citybiome); if (temp != 0) { data[i + j * width + citybiome + 1 * width * height] = temp; citybiome++; data[i + j * width] = 1; } else { data[i + j * width + citybiome + 1 * width * height] = temp; endloop = true; } } } } catch (Exception) { // In case of overflow, underflow or divide by zero. data[i + j * width] = 0; } } } return(data); }
protected override int[] GenerateDataImpl(long x, long y, long z, long width, long height, long depth) { if (this.Parents.Length < 1 || this.Parents[0] == null) { return(new int[width * height * depth]); } int[] citybiome = this.Parents[0].GenerateData(x, y, width, height); int[] data = new int[width * height * depth]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { for (int k = 0; k < depth; k++) { data[i + j * width + k * width * height] = -1; } } } // Write out the city biomes. for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { try { data[i + j * width] = 0; if (citybiome[i + j * width] != 0) { // Store result. bool endloop = false; int citybiomecount = 0; while (endloop == false) { if (citybiome[i + j * width + citybiomecount * width * height] == 1) { citybiomecount++; } else if (citybiome[i + j * width + citybiomecount * width * height] == 0) { endloop = true; } } int citybiomenumber = 0; endloop = false; while (endloop == false) { int temp = CitiesEngine.GetSecondaryCityBiomeForCell(citybiomenumber, citybiomecount); if (temp != 0) { data[i + j * width + citybiomenumber + 1 * width * height] = temp; citybiomenumber++; data[i + j * width] = 1; } else { data[i + j * width + citybiomenumber + 1 * width * height] = temp; endloop = true; } } } } catch (Exception) { // In case of overflow, underflow or divide by zero. data[i + j * width] = 0; } } } return(data); }