| 405 | } |
| 406 | |
| 407 | ObjectConfigPtr ObjectDatabase::readConfig(String const& path) { |
| 408 | try { |
| 409 | auto assets = Root::singleton().assets(); |
| 410 | |
| 411 | Json config = assets->json(path); |
| 412 | |
| 413 | auto objectConfig = make_shared<ObjectConfig>(); |
| 414 | objectConfig->path = path; |
| 415 | objectConfig->config = config; |
| 416 | |
| 417 | objectConfig->name = config.getString("objectName"); |
| 418 | objectConfig->type = config.getString("objectType", "object"); |
| 419 | objectConfig->race = config.getString("race", "generic"); |
| 420 | objectConfig->category = config.getString("category", "other"); |
| 421 | objectConfig->colonyTags = jsonToStringList(config.get("colonyTags", JsonArray())); |
| 422 | |
| 423 | objectConfig->scripts = jsonToStringList(config.get("scripts", JsonArray())).transformed(bind(AssetPath::relativeTo, path, _1)); |
| 424 | objectConfig->animationScripts = jsonToStringList(config.get("animationScripts", JsonArray())).transformed(bind(AssetPath::relativeTo, path, _1)); |
| 425 | |
| 426 | objectConfig->price = config.getInt("price", 0); |
| 427 | if (objectConfig->price == 0) |
| 428 | objectConfig->price = 1; |
| 429 | |
| 430 | objectConfig->hasObjectItem = config.getBool("hasObjectItem", true); |
| 431 | |
| 432 | objectConfig->scannable = config.getBool("scannable", true); |
| 433 | objectConfig->printable = objectConfig->hasObjectItem && config.getBool("printable", objectConfig->scannable); |
| 434 | |
| 435 | objectConfig->retainObjectParametersInItem = config.getBool("retainObjectParametersInItem", false); |
| 436 | |
| 437 | if (config.contains("breakDropPool")) |
| 438 | objectConfig->breakDropPool = config.getString("breakDropPool"); |
| 439 | |
| 440 | if (config.contains("breakDropOptions")) { |
| 441 | for (auto dropChoiceGroups : config.get("breakDropOptions").iterateArray()) { |
| 442 | List<ItemDescriptor> group; |
| 443 | for (auto dropChoiceEntry : dropChoiceGroups.iterateArray()) |
| 444 | group.append( |
| 445 | {dropChoiceEntry.getString(0), (size_t)dropChoiceEntry.getUInt(1), dropChoiceEntry.getObject(2)}); |
| 446 | objectConfig->breakDropOptions.append(group); |
| 447 | } |
| 448 | // If breakDropOptions is set but empty, then the object should always |
| 449 | // drop nothing. |
| 450 | if (objectConfig->breakDropOptions.empty()) |
| 451 | objectConfig->breakDropOptions.append({}); |
| 452 | } |
| 453 | |
| 454 | if (config.contains("smashDropPool")) |
| 455 | objectConfig->smashDropPool = config.getString("smashDropPool"); |
| 456 | |
| 457 | for (auto dropChoiceGroups : config.get("smashDropOptions", JsonArray()).iterateArray()) { |
| 458 | List<ItemDescriptor> group; |
| 459 | for (auto dropChoiceEntry : dropChoiceGroups.iterateArray()) |
| 460 | group.append(ItemDescriptor(dropChoiceEntry)); |
| 461 | objectConfig->smashDropOptions.append(group); |
| 462 | } |
| 463 | |
| 464 | for (auto& sound : config.get("smashSounds", JsonArray()).iterateArray()) |
nothing calls this directly
no test coverage detected