Line data Source code
1 : #include "core/animations/states/BodyRollBackAnimationState.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 : BodyRollBackAnimationState::BodyRollBackAnimationState(
16 0 : const AnimationDataManager& animation_data_manager)
17 0 : : AnimationState(animation_data_manager.Get(AnimationType::RollBack))
18 0 : , animation_data_manager_(animation_data_manager)
19 : {
20 0 : }
21 :
22 0 : std::optional<std::shared_ptr<AnimationState>> BodyRollBackAnimationState::HandleInput(
23 : Soldier& soldier)
24 : {
25 0 : if (soldier.control.prone) {
26 0 : return std::make_shared<BodyProneAnimationState>(animation_data_manager_);
27 : }
28 :
29 0 : if (GetFrame() == GetFramesCount()) {
30 0 : if (soldier.stance == PhysicsConstants::STANCE_STAND) {
31 0 : return std::make_shared<BodyStandAnimationState>(animation_data_manager_);
32 : }
33 :
34 0 : if (soldier.stance == PhysicsConstants::STANCE_CROUCH) {
35 0 : return std::make_shared<BodyAimAnimationState>(animation_data_manager_);
36 : }
37 :
38 0 : if (soldier.stance == PhysicsConstants::STANCE_PRONE) {
39 0 : return std::make_shared<BodyProneAnimationState>(animation_data_manager_);
40 : }
41 : }
42 :
43 0 : return std::nullopt;
44 : }
45 :
46 0 : bool BodyRollBackAnimationState::IsSoldierShootingPossible(const Soldier& soldier) const
47 : {
48 0 : return soldier.weapons[soldier.active_weapon].GetWeaponParameters().kind ==
49 0 : WeaponType::Chainsaw;
50 : }
51 : } // namespace Soldank
|