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

            Line data    Source code
       1              : #include "core/animations/states/LegsRollAnimationState.hpp"
       2              : 
       3              : #include "core/animations/states/LegsCrouchAnimationState.hpp"
       4              : #include "core/animations/states/LegsGetUpAnimationState.hpp"
       5              : #include "core/animations/states/LegsProneAnimationState.hpp"
       6              : #include "core/animations/states/LegsJumpAnimationState.hpp"
       7              : #include "core/animations/states/LegsStandAnimationState.hpp"
       8              : #include "core/animations/states/LegsFallAnimationState.hpp"
       9              : 
      10              : #include "core/animations/states/CommonAnimationStateTransitions.hpp"
      11              : 
      12              : #include "core/entities/Soldier.hpp"
      13              : #include "core/physics/Constants.hpp"
      14              : 
      15              : namespace Soldank
      16              : {
      17            0 : LegsRollAnimationState::LegsRollAnimationState(const AnimationDataManager& animation_data_manager)
      18            0 :     : AnimationState(animation_data_manager.Get(AnimationType::Roll))
      19            0 :     , animation_data_manager_(animation_data_manager)
      20              : {
      21            0 : }
      22              : 
      23            0 : void LegsRollAnimationState::Enter(Soldier& soldier)
      24              : {
      25            0 :     if (soldier.on_ground) {
      26            0 :         glm::vec2 particle_force = soldier.particle.GetForce();
      27            0 :         soldier.particle.SetForce(
      28            0 :           { (float)soldier.direction * 2.0F * PhysicsConstants::CROUCHRUNSPEED, particle_force.y });
      29              :     }
      30            0 : }
      31              : 
      32            0 : std::optional<std::shared_ptr<AnimationState>> LegsRollAnimationState::HandleInput(Soldier& soldier)
      33              : {
      34            0 :     if (soldier.control.prone) {
      35            0 :         return std::make_shared<LegsProneAnimationState>(animation_data_manager_);
      36              :     }
      37              : 
      38            0 :     if (GetFrame() == GetFramesCount()) {
      39              :         auto maybe_crouch_run_animation_state =
      40              :           CommonAnimationStateTransitions::TryTransitionToCrouchRunning(soldier,
      41            0 :                                                                         animation_data_manager_);
      42            0 :         if (maybe_crouch_run_animation_state.has_value()) {
      43            0 :             return *maybe_crouch_run_animation_state;
      44              :         }
      45              : 
      46              :         auto maybe_running_animation_state =
      47            0 :           CommonAnimationStateTransitions::TryTransitionToRunning(soldier, animation_data_manager_);
      48            0 :         if (maybe_running_animation_state.has_value()) {
      49            0 :             return *maybe_running_animation_state;
      50              :         }
      51              : 
      52            0 :         if (soldier.on_ground) {
      53            0 :             if (soldier.control.up) {
      54            0 :                 return std::make_shared<LegsJumpAnimationState>(animation_data_manager_);
      55              :             }
      56              : 
      57            0 :             if (soldier.control.down) {
      58            0 :                 return std::make_shared<LegsCrouchAnimationState>(animation_data_manager_);
      59              :             }
      60              : 
      61            0 :             return std::make_shared<LegsStandAnimationState>(animation_data_manager_);
      62              :         }
      63              : 
      64            0 :         return std::make_shared<LegsFallAnimationState>(animation_data_manager_);
      65            0 :     }
      66              : 
      67            0 :     return std::nullopt;
      68              : }
      69              : 
      70            0 : void LegsRollAnimationState::Update(Soldier& soldier, const PhysicsEvents& physics_events)
      71              : {
      72            0 :     soldier.stance = PhysicsConstants::STANCE_STAND;
      73              : 
      74            0 :     if (GetSpeed() > 1) {
      75            0 :         soldier.particle.velocity_.x /= (float)GetSpeed();
      76            0 :         soldier.particle.velocity_.y /= (float)GetSpeed();
      77              :     }
      78              : 
      79            0 :     if (soldier.on_ground) {
      80            0 :         glm::vec2 particle_force = soldier.particle.GetForce();
      81            0 :         soldier.particle.SetForce(
      82            0 :           { (float)soldier.direction * PhysicsConstants::ROLLSPEED, particle_force.y });
      83              :     } else {
      84            0 :         glm::vec2 particle_force = soldier.particle.GetForce();
      85            0 :         soldier.particle.SetForce(
      86            0 :           { (float)soldier.direction * 2.0F * PhysicsConstants::FLYSPEED, particle_force.y });
      87              :     }
      88            0 : }
      89              : } // namespace Soldank
        

Generated by: LCOV version 2.0-1