Line data Source code
1 : #include "core/animations/states/BodyPunchAnimationState.hpp"
2 :
3 : #include "core/animations/states/BodyAimAnimationState.hpp"
4 : #include "core/animations/states/BodyChangeAnimationState.hpp"
5 : #include "core/animations/states/BodyProneAnimationState.hpp"
6 : #include "core/animations/states/BodyGetUpAnimationState.hpp"
7 : #include "core/animations/states/BodyProneMoveAnimationState.hpp"
8 : #include "core/animations/states/BodyRollAnimationState.hpp"
9 : #include "core/animations/states/BodyRollBackAnimationState.hpp"
10 : #include "core/animations/states/BodyStandAnimationState.hpp"
11 :
12 : #include "core/animations/states/CommonAnimationStateTransitions.hpp"
13 :
14 : #include "core/animations/AnimationData.hpp"
15 : #include "core/entities/Soldier.hpp"
16 : #include "core/physics/Constants.hpp"
17 :
18 : namespace Soldank
19 : {
20 0 : BodyPunchAnimationState::BodyPunchAnimationState(const AnimationDataManager& animation_data_manager)
21 0 : : AnimationState(animation_data_manager.Get(AnimationType::Punch))
22 0 : , animation_data_manager_(animation_data_manager)
23 : {
24 0 : }
25 :
26 0 : std::optional<std::shared_ptr<AnimationState>> BodyPunchAnimationState::HandleInput(
27 : Soldier& soldier)
28 : {
29 0 : if (soldier.legs_animation->GetType() == AnimationType::Roll) {
30 0 : return std::make_shared<BodyRollAnimationState>(animation_data_manager_);
31 : }
32 :
33 0 : if (soldier.legs_animation->GetType() == AnimationType::RollBack) {
34 0 : return std::make_shared<BodyRollBackAnimationState>(animation_data_manager_);
35 : }
36 :
37 0 : if (soldier.legs_animation->GetType() == AnimationType::ProneMove) {
38 0 : return std::make_shared<BodyProneMoveAnimationState>(animation_data_manager_);
39 : }
40 :
41 : // Prone cancelling
42 0 : if (soldier.legs_animation->GetType() == AnimationType::GetUp) {
43 0 : auto new_state = std::make_shared<BodyGetUpAnimationState>(animation_data_manager_);
44 0 : new_state->SetFrame(9);
45 0 : return new_state;
46 0 : }
47 :
48 0 : if (soldier.control.change) {
49 0 : return std::make_shared<BodyChangeAnimationState>(animation_data_manager_);
50 : }
51 :
52 0 : if (GetFrame() == GetFramesCount()) {
53 0 : if (soldier.stance == PhysicsConstants::STANCE_CROUCH) {
54 0 : return std::make_shared<BodyAimAnimationState>(animation_data_manager_);
55 : }
56 :
57 0 : if (soldier.stance == PhysicsConstants::STANCE_PRONE) {
58 : auto prone_animation_state =
59 0 : std::make_shared<BodyProneAnimationState>(animation_data_manager_);
60 0 : prone_animation_state->SetFrame(26);
61 0 : return prone_animation_state;
62 0 : }
63 :
64 0 : if (soldier.stance == PhysicsConstants::STANCE_STAND) {
65 0 : return std::make_shared<BodyStandAnimationState>(animation_data_manager_);
66 : }
67 : }
68 0 : return std::nullopt;
69 : }
70 :
71 0 : void BodyPunchAnimationState::Update(Soldier& soldier, const PhysicsEvents& physics_events) {}
72 : } // namespace Soldank
|