MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / buildBushVariant

Method buildBushVariant

source/game/StarPlantDatabase.cpp:303–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303BushVariant 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
341PlantPtr PlantDatabase::createPlant(TreeVariant const& treeVariant, uint64_t seed) const {
342 try {

Callers 1

createItemMethod · 0.80

Calls 15

strfFunction · 0.85
jsonToStringListFunction · 0.85
toArrayMethod · 0.80
toObjectMethod · 0.80
getBoolMethod · 0.80
iterateObjectMethod · 0.80
getStringMethod · 0.80
getFloatMethod · 0.80
containsMethod · 0.45
getMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected