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

Method update

source/frontend/StarMainInterface.cpp:543–834  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

541}
542
543void MainInterface::update(float dt) {
544 m_paneManager.update(dt);
545 m_cursor.update(dt);
546
547 m_questLogInterface->pollDialog(&m_paneManager);
548
549 if (!m_paneManager.topPane({PaneLayer::ModalWindow}) && m_codexInterface->showNewCodex())
550 m_paneManager.displayRegisteredPane(MainInterfacePanes::Codex);
551
552 auto player = m_client->mainPlayer();
553 auto cursorWorldPos = cursorWorldPosition();
554 if (player->wireToolInUse()) {
555 m_paneManager.displayRegisteredPane(MainInterfacePanes::WireInterface);
556 player->setWireConnector(m_wireInterface.get());
557 } else {
558 m_paneManager.dismissRegisteredPane(MainInterfacePanes::WireInterface);
559 }
560
561 // update inventory pane items, to know if item slots changed
562 m_inventoryWindow->updateItems();
563
564 // update mouseover target
565 EntityId newMouseOverTarget = NullEntityId;
566 m_stickyTargetingTimer.tick(dt);
567 auto mouseoverEntities = m_client->worldClient()->query<DamageBarEntity>(RectF::withCenter(cursorWorldPos, Vec2F(1, 1)), [=](shared_ptr<DamageBarEntity> const& entity) {
568 return entity != player
569 && entity->damageBar() == DamageBarType::Default
570 && (entity->getTeam().type == TeamType::Enemy || entity->getTeam().type == TeamType::PVP)
571 && m_client->worldClient()->lightLevel(entity->position()) > 0;
572 });
573 sortByComputedValue(mouseoverEntities, [&](DamageBarEntityPtr const& a) {
574 return m_client->worldClient()->geometry().diff(a->position(), cursorWorldPos).magnitude();
575 });
576 if (mouseoverEntities.size() > 0) {
577 newMouseOverTarget = mouseoverEntities[0]->entityId();
578 } else if (m_lastMouseoverTarget == NullEntityId && player->lastDamagedTarget() != NullEntityId && player->timeSinceLastGaveDamage() < m_stickyTargetingTimer.time / 2) {
579 if (auto targetEntity = as<DamageBarEntity>(m_client->worldClient()->entity(player->lastDamagedTarget()))) {
580 if (targetEntity->damageBar() == DamageBarType::Default && (targetEntity->getTeam().type == TeamType::Enemy || targetEntity->getTeam().type == TeamType::PVP)) {
581 newMouseOverTarget = targetEntity->entityId();
582 }
583 }
584 }
585 if (newMouseOverTarget != NullEntityId && newMouseOverTarget != m_lastMouseoverTarget) {
586 m_lastMouseoverTarget = newMouseOverTarget;
587 m_portraitScale = 0;
588 m_stickyTargetingTimer.reset();
589 }
590
591 if (m_stickyTargetingTimer.ready())
592 m_lastMouseoverTarget = NullEntityId;
593
594 // special damage bar entity
595 if (m_specialDamageBarTarget != NullEntityId) {
596 auto damageBarEntity = as<DamageBarEntity>(m_client->worldClient()->entity(m_specialDamageBarTarget));
597 if (damageBarEntity && damageBarEntity->damageBar() == DamageBarType::Special) {
598 float targetHealth = damageBarEntity->health() / damageBarEntity->maxHealth();
599 float fillSpeed = 1.0f / Root::singleton().assets()->json("/interface.config:specialDamageBar.fillTime").toFloat();
600 if (abs(targetHealth - m_specialDamageBarValue) < fillSpeed * dt)

Callers

nothing calls this directly

Calls 15

sortByComputedValueFunction · 0.85
singletonClass · 0.85
stripEscapeCodesFunction · 0.85
toStringFunction · 0.85
strfFunction · 0.85
ChatReceivedMessageClass · 0.85
pollDialogMethod · 0.80
topPaneMethod · 0.80
showNewCodexMethod · 0.80
displayRegisteredPaneMethod · 0.80
mainPlayerMethod · 0.80
wireToolInUseMethod · 0.80

Tested by

no test coverage detected