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

Method recipeForMaterials

source/game/objects/StarContainerObject.cpp:438–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436}
437
438ItemRecipe ContainerObject::recipeForMaterials(List<ItemPtr> const& inputItems) {
439 auto& root = Root::singleton();
440 auto itemDatabase = root.itemDatabase();
441
442 Json recipeGroup = configValue("recipeGroup");
443 if (!recipeGroup.isNull())
444 return itemDatabase->getPreciseRecipeForMaterials(recipeGroup.toString(), inputItems, {});
445
446 Maybe<Json> result = m_scriptComponent.invoke<Json>("craftingRecipe", inputItems.filtered([](ItemPtr const& item) {
447 return (bool)item;
448 }).transformed([](ItemPtr const& item) {
449 return item->descriptor().toJson();
450 }));
451 if (!result || result->isNull())
452 return ItemRecipe();
453 return itemDatabase->parseRecipe(*result);
454}
455
456void ContainerObject::tickCrafting(float dt) {
457 if (!m_crafting.get())

Callers

nothing calls this directly

Calls 11

singletonClass · 0.85
ItemRecipeClass · 0.85
itemDatabaseMethod · 0.80
parseRecipeMethod · 0.80
isNullMethod · 0.45
toStringMethod · 0.45
transformedMethod · 0.45
filteredMethod · 0.45
toJsonMethod · 0.45
descriptorMethod · 0.45

Tested by

no test coverage detected