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

Method craft

source/frontend/StarCraftingInterface.cpp:564–599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

562}
563
564void CraftingPane::craft(int count) {
565 auto& root = Root::singleton();
566
567 if (m_guiList->selectedItem() != NPos) {
568 auto recipe = recipeFromSelectedWidget();
569
570 if (!m_player->isAdmin() && !consumeIngredients(recipe, count)) {
571 stopCrafting();
572 return;
573 }
574
575 ItemDescriptor itemDescriptor = recipe.output;
576 int remainingItemCount = itemDescriptor.count() * count;
577 while (remainingItemCount > 0) {
578 auto craftedItem = root.itemDatabase()->item(itemDescriptor.singular().multiply(remainingItemCount));
579 remainingItemCount -= craftedItem->count();
580 m_player->giveItem(craftedItem);
581
582 for (auto& collectable : recipe.collectables)
583 m_player->addCollectable(collectable.first, collectable.second);
584 }
585
586 m_blueprints->markAsRead(recipe.output.singular());
587 }
588
589 updateAvailableRecipes();
590
591 m_count -= count;
592 if (m_count <= 0) {
593 m_count = 1;
594 stopCrafting();
595 }
596 countChanged();
597
598 updateCraftButtons();
599}
600
601void CraftingPane::countTextChanged() {
602 if (m_textBox) {

Callers

nothing calls this directly

Calls 11

singletonClass · 0.85
itemDatabaseMethod · 0.80
singularMethod · 0.80
giveItemMethod · 0.80
selectedItemMethod · 0.45
isAdminMethod · 0.45
countMethod · 0.45
itemMethod · 0.45
multiplyMethod · 0.45
addCollectableMethod · 0.45
markAsReadMethod · 0.45

Tested by

no test coverage detected