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

Method processControls

source/game/StarPlayer.cpp:1701–1796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1699}
1700
1701void Player::processControls() {
1702 bool run = !m_shifting && !m_statusController->statPositive("encumberance");
1703
1704 bool useMoveVector = m_moveVector.x() != 0.0f;
1705 if (useMoveVector) {
1706 for (auto move : m_pendingMoves) {
1707 if (move == MoveControlType::Left || move == MoveControlType::Right) {
1708 useMoveVector = false;
1709 break;
1710 }
1711 }
1712 }
1713
1714 if (useMoveVector) {
1715 m_pendingMoves.insert(m_moveVector.x() < 0.0f ? MoveControlType::Left : MoveControlType::Right);
1716 m_movementController->setMoveSpeedMultiplier(clamp(abs(m_moveVector.x()), 0.0f, 1.0f));
1717 }
1718 else
1719 m_movementController->setMoveSpeedMultiplier(1.0f);
1720
1721 if (auto fireableMain = as<FireableItem>(m_tools->primaryHandItem())) {
1722 if (fireableMain->inUse() && fireableMain->walkWhileFiring())
1723 run = false;
1724 }
1725
1726 if (auto fireableAlt = as<FireableItem>(m_tools->altHandItem())) {
1727 if (fireableAlt->inUse() && fireableAlt->walkWhileFiring())
1728 run = false;
1729 }
1730
1731 bool move = true;
1732
1733 if (auto fireableMain = as<FireableItem>(m_tools->primaryHandItem())) {
1734 if (fireableMain->inUse() && fireableMain->stopWhileFiring())
1735 move = false;
1736 }
1737
1738 if (auto fireableAlt = as<FireableItem>(m_tools->altHandItem())) {
1739 if (fireableAlt->inUse() && fireableAlt->stopWhileFiring())
1740 move = false;
1741 }
1742
1743 auto loungeAnchor = as<LoungeAnchor>(m_movementController->entityAnchor());
1744 if (loungeAnchor && loungeAnchor->controllable) {
1745 auto anchorState = m_movementController->anchorState();
1746 if (auto loungeableEntity = world()->get<LoungeableEntity>(anchorState->entityId)) {
1747 for (auto move : m_pendingMoves) {
1748 if (move == MoveControlType::Up)
1749 loungeableEntity->loungeControl(anchorState->positionIndex, LoungeControl::Up);
1750 else if (move == MoveControlType::Down)
1751 loungeableEntity->loungeControl(anchorState->positionIndex, LoungeControl::Down);
1752 else if (move == MoveControlType::Left)
1753 loungeableEntity->loungeControl(anchorState->positionIndex, LoungeControl::Left);
1754 else if (move == MoveControlType::Right)
1755 loungeableEntity->loungeControl(anchorState->positionIndex, LoungeControl::Right);
1756 else if (move == MoveControlType::Jump)
1757 loungeableEntity->loungeControl(anchorState->positionIndex, LoungeControl::Jump);
1758 }

Callers

nothing calls this directly

Calls 15

clampFunction · 0.85
xMethod · 0.80
inUseMethod · 0.80
walkWhileFiringMethod · 0.80
stopWhileFiringMethod · 0.80
entityAnchorMethod · 0.80
anchorStateMethod · 0.80
firingPrimaryMethod · 0.80
firingAltMethod · 0.80
setShouldRunMethod · 0.80
statPositiveMethod · 0.45

Tested by

no test coverage detected