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

Method setCustomBarSecondarySlot

source/game/StarPlayerInventory.cpp:678–697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

676}
677
678void PlayerInventory::setCustomBarSecondarySlot(CustomBarIndex customBarIndex, Maybe<InventorySlot> slot) {
679 auto& cbl = m_customBar.at(m_customBarGroup, customBarIndex);
680 // The secondary slot is not allowed to point to an empty item or a two
681 // handed item.
682 if (slot) {
683 if (!itemsAt(*slot) || itemSafeTwoHanded(itemsAt(*slot)))
684 slot = {};
685 }
686
687 if (cbl.first && cbl.first == slot && !itemSafeTwoHanded(itemsAt(*cbl.first))) {
688 // If we match the primary slot and the primary slot is not a two handed
689 // item, then just swap the two slots.
690 swap(cbl.first, cbl.second);
691 } else {
692 cbl.second = slot;
693 // If the primary slot was two handed, it is no longer valid so clear it.
694 if (cbl.first && itemSafeTwoHanded(itemsAt(*cbl.first)))
695 cbl.first = {};
696 }
697}
698
699void PlayerInventory::addToCustomBar(InventorySlot slot) {
700 for (size_t j = 0; j < m_customBar.size(1); ++j) {

Callers 3

makePlayerCallbacksMethod · 0.80
customBarClickMethod · 0.80
customBarClickRightMethod · 0.80

Calls 2

itemSafeTwoHandedFunction · 0.85
atMethod · 0.45

Tested by

no test coverage detected