Address movement type issues

This commit is contained in:
David Markowitz 2022-12-21 02:00:46 -08:00
parent e53e31021f
commit 9be2ab03b6
2 changed files with 20 additions and 13 deletions

View File

@ -18,42 +18,47 @@ void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream*
Game::logger->Log("MovementSwitchBehavior", "Unable to read movementType from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); Game::logger->Log("MovementSwitchBehavior", "Unable to read movementType from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
return; return;
}; };
Game::logger->LogDebug("MovementSwitchBehavior", "Movement type %i", movementType);
switch (movementType) { switch (movementType) {
case 1: case 1:
case 3:
this->m_groundAction->Handle(context, bitStream, branch); this->m_groundAction->Handle(context, bitStream, branch);
break; break;
case 2: case 2:
this->m_jumpAction->Handle(context, bitStream, branch); this->m_jumpAction->Handle(context, bitStream, branch);
break; break;
case 3:
this->m_fallingAction->Handle(context, bitStream, branch);
break;
case 4: case 4:
this->m_doubleJumpAction->Handle(context, bitStream, branch); this->m_doubleJumpAction->Handle(context, bitStream, branch);
break; break;
case 5: case 5:
this->m_airAction->Handle(context, bitStream, branch); this->m_fallingAction->Handle(context, bitStream, branch);
break; break;
case 6: case 6:
this->m_jetpackAction->Handle(context, bitStream, branch); this->m_jetpackAction->Handle(context, bitStream, branch);
break; break;
default: default:
Game::logger->Log("MovementSwitchBehavior", "Invalid movement behavior type (%i)!", movementType); this->m_groundAction->Handle(context, bitStream, branch);
break;
} }
} }
void MovementSwitchBehavior::Load() { void MovementSwitchBehavior::Load() {
this->m_airAction = GetAction("air_action");
this->m_doubleJumpAction = GetAction("double_jump_action");
this->m_fallingAction = GetAction("falling_action");
this->m_groundAction = GetAction("ground_action"); this->m_groundAction = GetAction("ground_action");
this->m_airAction = GetAction("air_action");
if (!this->m_airAction) this->m_airAction = this->m_groundAction;
this->m_doubleJumpAction = GetAction("double_jump_action");
if (!this->m_doubleJumpAction) this->m_airAction = this->m_groundAction;
this->m_fallingAction = GetAction("falling_action");
if (!this->m_fallingAction) this->m_airAction = this->m_groundAction;
this->m_jetpackAction = GetAction("jetpack_action"); this->m_jetpackAction = GetAction("jetpack_action");
if (!this->m_jetpackAction) this->m_airAction = this->m_groundAction;
this->m_jumpAction = GetAction("jump_action"); this->m_jumpAction = GetAction("jump_action");
if (!this->m_jumpAction) this->m_airAction = this->m_groundAction;
this->m_movingAction = GetAction("moving_action");
if (!this->m_movingAction) this->m_airAction = this->m_groundAction;
} }

View File

@ -19,6 +19,8 @@ public:
Behavior* m_jumpAction; Behavior* m_jumpAction;
Behavior* m_movingAction;
/* /*
* Inherited * Inherited
*/ */