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

Method setupTechModules

source/game/StarTechController.cpp:408–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406}
407
408void 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
440void TechController::unloadModule(TechModule& techModule) {
441 techModule.scriptComponent.uninit();

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
techDatabaseMethod · 0.80
emplaceAppendMethod · 0.80
techMethod · 0.80
setScriptsMethod · 0.80
setScriptStorageMethod · 0.80
getBoolMethod · 0.80
iterateObjectMethod · 0.80
setPartTagMethod · 0.80
clearMethod · 0.45
clearNetElementsMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected