| 406 | } |
| 407 | |
| 408 | void TechController::setupTechModules(List<tuple<String, JsonObject>> const& moduleInits) { |
| 409 | for (auto& techModule : m_techModules) |
| 410 | unloadModule(techModule); |
| 411 | |
| 412 | m_techModules.clear(); |
| 413 | m_techAnimators.clearNetElements(); |
| 414 | |
| 415 | auto techDatabase = Root::singleton().techDatabase(); |
| 416 | |
| 417 | for (auto const& moduleInit : moduleInits) { |
| 418 | if (techDatabase->contains(get<0>(moduleInit))) { |
| 419 | auto& module = m_techModules.emplaceAppend(); |
| 420 | |
| 421 | module.config = techDatabase->tech(get<0>(moduleInit)); |
| 422 | |
| 423 | module.scriptComponent.setScripts(module.config.scripts); |
| 424 | module.scriptComponent.setScriptStorage(get<1>(moduleInit)); |
| 425 | |
| 426 | module.visible = module.config.parameters.getBool("visible", true); |
| 427 | |
| 428 | module.toolUsageSuppressed = false; |
| 429 | |
| 430 | auto moduleAnimator = make_shared<TechAnimator>(module.config.animationConfig); |
| 431 | for (auto const& pair : module.config.parameters.get("animationParts", JsonObject()).iterateObject()) |
| 432 | moduleAnimator->animator.setPartTag(pair.first, "partImage", pair.second.toString()); |
| 433 | module.animatorId = m_techAnimators.addNetElement(moduleAnimator); |
| 434 | } else { |
| 435 | Logger::warn("Tech module '{}' not found in tech database", get<0>(moduleInit)); |
| 436 | } |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | void TechController::unloadModule(TechModule& techModule) { |
| 441 | techModule.scriptComponent.uninit(); |
nothing calls this directly
no test coverage detected