Line data Source code
1 : #include "core/animations/states/BodyRollAnimationState.hpp"
2 :
3 : #include "core/animations/states/BodyProneAnimationState.hpp"
4 : #include "core/animations/states/BodyAimAnimationState.hpp"
5 : #include "core/animations/states/BodyStandAnimationState.hpp"
6 :
7 : #include "core/animations/states/CommonAnimationStateTransitions.hpp"
8 :
9 : #include "core/animations/AnimationData.hpp"
10 : #include "core/entities/Soldier.hpp"
11 : #include "core/physics/Constants.hpp"
12 :
13 : namespace Soldank
14 : {
15 0 : BodyRollAnimationState::BodyRollAnimationState(const AnimationDataManager& animation_data_manager)
16 0 : : AnimationState(animation_data_manager.Get(AnimationType::Roll))
17 0 : , animation_data_manager_(animation_data_manager)
18 : {
19 0 : }
20 :
21 0 : std::optional<std::shared_ptr<AnimationState>> BodyRollAnimationState::HandleInput(Soldier& soldier)
22 : {
23 0 : if (soldier.control.prone) {
24 0 : return std::make_shared<BodyProneAnimationState>(animation_data_manager_);
25 : }
26 :
27 0 : if (GetFrame() == GetFramesCount()) {
28 0 : if (soldier.stance == PhysicsConstants::STANCE_STAND) {
29 0 : return std::make_shared<BodyStandAnimationState>(animation_data_manager_);
30 : }
31 :
32 0 : if (soldier.stance == PhysicsConstants::STANCE_CROUCH) {
33 0 : return std::make_shared<BodyAimAnimationState>(animation_data_manager_);
34 : }
35 :
36 0 : if (soldier.stance == PhysicsConstants::STANCE_PRONE) {
37 0 : return std::make_shared<BodyProneAnimationState>(animation_data_manager_);
38 : }
39 : }
40 :
41 0 : return std::nullopt;
42 : }
43 :
44 0 : bool BodyRollAnimationState::IsSoldierShootingPossible(const Soldier& soldier) const
45 : {
46 0 : return soldier.weapons[soldier.active_weapon].GetWeaponParameters().kind ==
47 0 : WeaponType::Chainsaw;
48 : }
49 : } // namespace Soldank
|