LCOV - code coverage report
Current view: top level - core/animations/states - BodyProneAnimationState.cpp (source / functions) Coverage Total Hit
Test: coverage-src.info Lines: 0.0 % 34 0
Test Date: 2025-05-27 23:26:07 Functions: 0.0 % 2 0

            Line data    Source code
       1              : #include "core/animations/states/BodyProneAnimationState.hpp"
       2              : 
       3              : #include "core/animations/states/BodyChangeAnimationState.hpp"
       4              : #include "core/animations/states/BodyGetUpAnimationState.hpp"
       5              : #include "core/animations/states/BodyProneMoveAnimationState.hpp"
       6              : #include "core/animations/states/BodyPunchAnimationState.hpp"
       7              : #include "core/animations/states/BodyRollAnimationState.hpp"
       8              : #include "core/animations/states/BodyRollBackAnimationState.hpp"
       9              : #include "core/animations/states/BodyThrowWeaponAnimationState.hpp"
      10              : 
      11              : #include "core/animations/states/CommonAnimationStateTransitions.hpp"
      12              : 
      13              : #include "core/animations/AnimationData.hpp"
      14              : #include "core/entities/Soldier.hpp"
      15              : #include "core/physics/Constants.hpp"
      16              : 
      17              : namespace Soldank
      18              : {
      19            0 : BodyProneAnimationState::BodyProneAnimationState(const AnimationDataManager& animation_data_manager)
      20            0 :     : AnimationState(animation_data_manager.Get(AnimationType::Prone))
      21            0 :     , animation_data_manager_(animation_data_manager)
      22              : {
      23            0 : }
      24              : 
      25            0 : std::optional<std::shared_ptr<AnimationState>> BodyProneAnimationState::HandleInput(
      26              :   Soldier& soldier)
      27              : {
      28              : 
      29            0 :     if (GetFrame() >= 23 && soldier.on_ground) {
      30            0 :         if (soldier.control.down && (soldier.control.left || soldier.control.right)) {
      31            0 :             if (soldier.legs_animation->GetType() == AnimationType::Roll) {
      32            0 :                 return std::make_shared<BodyRollAnimationState>(animation_data_manager_);
      33              :             }
      34              : 
      35            0 :             if (soldier.legs_animation->GetType() == AnimationType::RollBack) {
      36            0 :                 return std::make_shared<BodyRollBackAnimationState>(animation_data_manager_);
      37              :             }
      38              :         }
      39              :     }
      40              : 
      41            0 :     if (soldier.control.change) {
      42            0 :         return std::make_shared<BodyChangeAnimationState>(animation_data_manager_);
      43              :     }
      44              : 
      45            0 :     if (soldier.control.drop &&
      46            0 :         soldier.weapons[0].GetWeaponParameters().kind != WeaponType::NoWeapon) {
      47            0 :         return std::make_shared<BodyThrowWeaponAnimationState>(animation_data_manager_);
      48              :     }
      49              : 
      50              :     auto maybe_throw_grenade_animation_state =
      51              :       CommonAnimationStateTransitions::TryTransitionToThrowingGrenade(soldier,
      52            0 :                                                                       animation_data_manager_);
      53            0 :     if (maybe_throw_grenade_animation_state.has_value()) {
      54            0 :         return *maybe_throw_grenade_animation_state;
      55              :     }
      56              : 
      57            0 :     if (soldier.stance == PhysicsConstants::STANCE_STAND) {
      58            0 :         auto new_state = std::make_shared<BodyGetUpAnimationState>(animation_data_manager_);
      59            0 :         new_state->SetFrame(9);
      60            0 :         return new_state;
      61            0 :     }
      62              : 
      63            0 :     if (soldier.legs_animation->GetType() == AnimationType::ProneMove && soldier.on_ground) {
      64            0 :         if (soldier.control.left || soldier.control.right) {
      65            0 :             return std::make_shared<BodyProneMoveAnimationState>(animation_data_manager_);
      66              :         }
      67              :     }
      68              : 
      69            0 :     if (soldier.control.fire &&
      70            0 :         (soldier.weapons[soldier.active_weapon].GetWeaponParameters().kind ==
      71            0 :            WeaponType::NoWeapon ||
      72            0 :          soldier.weapons[soldier.active_weapon].GetWeaponParameters().kind == WeaponType::Knife)) {
      73            0 :         return std::make_shared<BodyPunchAnimationState>(animation_data_manager_);
      74              :     }
      75              : 
      76            0 :     return std::nullopt;
      77            0 : }
      78              : } // namespace Soldank
        

Generated by: LCOV version 2.0-1