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