| 301 | } |
| 302 | |
| 303 | BushVariant PlantDatabase::buildBushVariant(String const& bushName, float baseHueShift, String const& modName, float modHueShift) const { |
| 304 | if (!m_bushConfigs.contains(bushName)) |
| 305 | throw PlantDatabaseException(strf("bush '{}' not found in plant database", bushName)); |
| 306 | |
| 307 | BushVariant bushVariant; |
| 308 | auto config = m_bushConfigs.get(bushName); |
| 309 | |
| 310 | bushVariant.bushName = bushName; |
| 311 | bushVariant.modName = modName; |
| 312 | bushVariant.directory = config.directory; |
| 313 | auto shapes = config.settings.get("shapes").toArray(); |
| 314 | for (auto shapeVar : shapes) { |
| 315 | auto shapeMap = shapeVar.toObject(); |
| 316 | auto base = shapeMap.get("base").toString(); |
| 317 | StringList mods; |
| 318 | if (!modName.empty()) |
| 319 | mods = jsonToStringList(shapeMap.get("mods").get(modName, JsonArray())); |
| 320 | bushVariant.shapes.push_back({base, mods}); |
| 321 | } |
| 322 | bushVariant.baseHueShift = baseHueShift; |
| 323 | bushVariant.modHueShift = modHueShift; |
| 324 | bushVariant.ceiling = config.settings.getBool("ceiling", false); |
| 325 | |
| 326 | JsonObject descriptions; |
| 327 | for (auto const& entry : config.settings.iterateObject()) { |
| 328 | if (entry.first.endsWith("Description")) |
| 329 | descriptions[entry.first] = entry.second; |
| 330 | } |
| 331 | descriptions["description"] = config.settings.getString("description", bushName + " with " + modName); |
| 332 | bushVariant.descriptions = descriptions; |
| 333 | |
| 334 | bushVariant.ephemeral = config.settings.getBool("ephemeral", true); |
| 335 | bushVariant.tileDamageParameters = TileDamageParameters( |
| 336 | config.settings.get("damageTable", "/plants/bushDamage.config"), |
| 337 | config.settings.getFloat("health", 1.0f)); |
| 338 | return bushVariant; |
| 339 | } |
| 340 | |
| 341 | PlantPtr PlantDatabase::createPlant(TreeVariant const& treeVariant, uint64_t seed) const { |
| 342 | try { |
no test coverage detected