public void SetBiome(Biome b) { biome = b; }
public void FillBiomeMap(int biomeBlendCount, BiomeData biomeData) { bool is3DBiomes = false; bool is3DTerrain = biomeData.terrain3D != null; Biome[] nearestBiomes = new Biome[biomeBlendCount]; //TODO: biome blend count > 1 management //TODO: biomeData.datas3D null check if (biomeData.air3D != null || biomeData.wind3D != null || biomeData.wetness3D != null || biomeData.temperature3D != null) { is3DBiomes = true; } if (biomeData.terrainRef == null) { return; } int terrainSize = (is3DTerrain) ? biomeData.terrain3D.size : biomeData.terrain.size; float terrainStep = (is3DTerrain) ? biomeData.terrain3D.step : biomeData.terrain.step; if (is3DBiomes) { biomeData.biomeIds3D = new BiomeMap3D(terrainSize, terrainStep); } else { biomeData.biomeIds = new BiomeMap2D(terrainSize, terrainStep); } if (is3DBiomes) { //TODO } else { for (int x = 0; x < terrainSize; x++) { for (int y = 0; y < terrainSize; y++) { bool water = (biomeData.isWaterless) ? false : biomeData.waterHeight[x, y] > 0; float temp = (biomeData.temperature != null) ? biomeData.temperature[x, y] : 0; float wet = (biomeData.wetness != null) ? biomeData.wetness[x, y] : 0; // Debug.Log("map [" + x + "/" + y + "] = " + biomeData.terrain[x, y]); //TODO: 3D terrain management float height = (is3DTerrain) ? 0 : biomeData.terrain[x, y]; BiomeSwitchNode current = root; while (true) { nextChild: if (current.biome != null) { break; } int childCount = current.GetChildCount(); for (int i = 0; i < childCount; i++) { var child = current.GetChildAt(i); switch (child.biomeSwitchMode) { case BiomeSwitchMode.Water: if (child.value == water) { current = child; goto nextChild; } break; case BiomeSwitchMode.Height: if (height > child.min && height <= child.max) { current = child; goto nextChild; } break; case BiomeSwitchMode.Temperature: if (temp > child.min && temp <= child.max) { current = child; goto nextChild; } break; case BiomeSwitchMode.Wetness: if (wet > child.min && wet <= child.max) { current = child; goto nextChild; } break; } } //if flow reach this part, values are missing in the biome graph so biome can't be chosen. break; } //TODO: blending with second biome if (current.biome != null) { biomeData.biomeIds.SetFirstBiomeId(x, y, current.biome.id); } else { //FIXME!!!! biomeData.biomeIds.SetFirstBiomeId(x, y, -1); // PWUtils.LogWarningMax("Can't choose biome with water:" + water + ", temp: " + temp + ", wet: " + wet + ", height: " + height, 200); PWUtils.LogWarningMax("Can't choose biome with water:" + water + ", temp: " + temp + ", wet: " + wet + ", height: " + height, 300); continue; } } } } }