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

Method update

source/frontend/StarCraftingInterface.cpp:232–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232void CraftingPane::update(float dt) {
233 // shut down if we can't reach the table anymore.
234 if (m_sourceEntityId != NullEntityId) {
235 auto sourceEntity = as<TileEntity>(m_worldClient->entity(m_sourceEntityId));
236 if (!sourceEntity || !m_worldClient->playerCanReachEntity(m_sourceEntityId) || !sourceEntity->isInteractive()) {
237 dismiss();
238 return;
239 }
240 }
241
242 // similarly if the player is dead
243 if (m_player->isDead()) {
244 dismiss();
245 return;
246 }
247
248 // has the selected recipe changed ?
249 bool changedHighlight = (m_displayedRecipe != m_guiList->selectedItem());
250
251 if (changedHighlight) {
252 stopCrafting(); // TODO: allow viewing other recipes without interrupting crafting
253
254 m_displayedRecipe = m_guiList->selectedItem();
255 countTextChanged();
256
257 auto recipe = recipeFromSelectedWidget();
258
259 if (recipe.isNull()) {
260 fetchChild<Widget>("description")->removeAllChildren();
261 } else {
262 auto description = fetchChild<Widget>("description");
263 description->removeAllChildren();
264
265 auto item = Root::singleton().itemDatabase()->itemShared(recipe.output);
266 ItemTooltipBuilder::buildItemDescription(description, item);
267 }
268 }
269
270 // crafters gonna craft
271 while (m_crafting && m_craftTimer.wrapTick()) {
272 craft(min(m_count, (int)m_settings.getInt("craftCount", 1)));
273 }
274
275 // update crafting icon, progress and buttons
276 if (auto currentRecipeIcon = fetchChild<ItemSlotWidget>("currentRecipeIcon")) {
277 auto recipe = recipeFromSelectedWidget();
278 if (recipe.isNull()) {
279 currentRecipeIcon->setItem(nullptr);
280 } else {
281 auto single = recipe.output.singular();
282 ItemPtr item = m_itemCache[single];
283 currentRecipeIcon->setItem(item);
284
285 if (m_crafting)
286 currentRecipeIcon->setProgress(1.0f - m_craftTimer.percent());
287 else
288 currentRecipeIcon->setProgress(1.0f);
289 }

Callers

nothing calls this directly

Calls 15

singletonClass · 0.85
toStringFunction · 0.85
playerCanReachEntityMethod · 0.80
isDeadMethod · 0.80
removeAllChildrenMethod · 0.80
itemSharedMethod · 0.80
itemDatabaseMethod · 0.80
wrapTickMethod · 0.80
getIntMethod · 0.80
singularMethod · 0.80
percentMethod · 0.80
entityMethod · 0.45

Tested by

no test coverage detected