| 436 | } |
| 437 | |
| 438 | ItemRecipe 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 | |
| 456 | void ContainerObject::tickCrafting(float dt) { |
| 457 | if (!m_crafting.get()) |
nothing calls this directly
no test coverage detected