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

            Line data    Source code
       1              : #include "core/animations/states/BodyChangeAnimationState.hpp"
       2              : 
       3              : #include "core/animations/states/BodyAimAnimationState.hpp"
       4              : #include "core/animations/states/BodyProneAnimationState.hpp"
       5              : #include "core/animations/states/BodyRollAnimationState.hpp"
       6              : #include "core/animations/states/BodyRollBackAnimationState.hpp"
       7              : #include "core/animations/states/BodyStandAnimationState.hpp"
       8              : 
       9              : #include "core/animations/states/CommonAnimationStateTransitions.hpp"
      10              : 
      11              : #include "core/animations/AnimationData.hpp"
      12              : #include "core/entities/Soldier.hpp"
      13              : #include "core/physics/PhysicsEvents.hpp"
      14              : #include "core/physics/Constants.hpp"
      15              : 
      16              : namespace Soldank
      17              : {
      18            0 : BodyChangeAnimationState::BodyChangeAnimationState(
      19            0 :   const AnimationDataManager& animation_data_manager)
      20            0 :     : AnimationState(animation_data_manager.Get(AnimationType::Change))
      21            0 :     , animation_data_manager_(animation_data_manager)
      22              : {
      23            0 : }
      24              : 
      25            0 : std::optional<std::shared_ptr<AnimationState>> BodyChangeAnimationState::HandleInput(
      26              :   Soldier& soldier)
      27              : {
      28            0 :     if (GetFrame() == 2) {
      29              :         // TODO: play sound
      30              : 
      31              :         // Apparently soldat skips this frame
      32            0 :         SetNextFrame();
      33              :     }
      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            0 :     if (GetFrame() == GetFramesCount()) {
      44            0 :         if (soldier.stance == PhysicsConstants::STANCE_CROUCH) {
      45            0 :             return std::make_shared<BodyAimAnimationState>(animation_data_manager_);
      46              :         }
      47              : 
      48            0 :         if (soldier.stance == PhysicsConstants::STANCE_PRONE) {
      49              :             auto prone_animation_state =
      50            0 :               std::make_shared<BodyProneAnimationState>(animation_data_manager_);
      51            0 :             prone_animation_state->SetFrame(26);
      52            0 :             return prone_animation_state;
      53            0 :         }
      54              : 
      55            0 :         if (soldier.stance == PhysicsConstants::STANCE_STAND) {
      56            0 :             return std::make_shared<BodyStandAnimationState>(animation_data_manager_);
      57              :         }
      58              :     }
      59              : 
      60            0 :     return std::nullopt;
      61              : }
      62              : 
      63            0 : void BodyChangeAnimationState::Update(Soldier& soldier, const PhysicsEvents& physics_events)
      64              : {
      65            0 :     if (GetFrame() == 25) {
      66            0 :         physics_events.soldier_switches_weapon.Notify(soldier);
      67              :     }
      68            0 : }
      69              : 
      70            0 : bool BodyChangeAnimationState::IsSoldierShootingPossible(const Soldier& soldier) const
      71              : {
      72            0 :     return soldier.weapons[soldier.active_weapon].GetWeaponParameters().kind ==
      73            0 :            WeaponType::Chainsaw;
      74              : }
      75              : } // namespace Soldank
        

Generated by: LCOV version 2.0-1