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

Method processStateChanges

source/game/StarPlayer.cpp:1798–1910  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1796}
1797
1798void Player::processStateChanges(float dt) {
1799 if (isMaster()) {
1800
1801 // Set the current player state based on what movement controller tells us
1802 // we're doing and do some state transition logic
1803 State oldState = m_state;
1804
1805 if (m_movementController->zeroG()) {
1806 if (m_movementController->flying())
1807 m_state = State::Swim;
1808 else if (m_state != State::Lounge)
1809 m_state = State::SwimIdle;
1810 } else if (m_movementController->groundMovement()) {
1811 if (m_movementController->running()) {
1812 m_state = State::Run;
1813 } else if (m_movementController->walking()) {
1814 m_state = State::Walk;
1815 } else if (m_movementController->crouching()) {
1816 m_state = State::Crouch;
1817 } else {
1818 if (m_state != State::Lounge)
1819 m_state = State::Idle;
1820 }
1821 } else if (m_movementController->liquidMovement()) {
1822 if (m_movementController->jumping()) {
1823 m_state = State::Swim;
1824 } else {
1825 if (m_state != State::Lounge)
1826 m_state = State::SwimIdle;
1827 }
1828 } else {
1829 if (m_movementController->jumping()) {
1830 m_state = State::Jump;
1831 } else {
1832 if (m_movementController->falling()) {
1833 m_state = State::Fall;
1834 }
1835 if (m_movementController->velocity()[1] > 0) {
1836 if (m_state != State::Lounge)
1837 m_state = State::Jump;
1838 }
1839 }
1840 }
1841
1842 if (m_moveVector.x() != 0.0f && (m_state == State::Run))
1843 m_state = abs(m_moveVector.x()) > 0.5f ? State::Run : State::Walk;
1844
1845 if (m_state == State::Jump && (oldState == State::Idle || oldState == State::Run || oldState == State::Walk || oldState == State::Crouch))
1846 m_effectsAnimator->burstParticleEmitter("jump");
1847
1848 if (!m_movementController->isNullColliding()) {
1849 if (oldState == State::Fall && oldState != m_state && m_state != State::Swim && m_state != State::SwimIdle
1850 && m_state != State::Jump) {
1851 m_effectsAnimator->burstParticleEmitter("landing");
1852 m_landedNetState.trigger();
1853 m_landingNoisePending = true;
1854 }
1855 }

Callers

nothing calls this directly

Calls 15

zeroGMethod · 0.80
groundMovementMethod · 0.80
walkingMethod · 0.80
crouchingMethod · 0.80
liquidMovementMethod · 0.80
jumpingMethod · 0.80
fallingMethod · 0.80
xMethod · 0.80
burstParticleEmitterMethod · 0.80
isNullCollidingMethod · 0.80
animateMethod · 0.80
parentStateMethod · 0.80

Tested by

no test coverage detected