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

            Line data    Source code
       1              : #include "core/animations/states/LegsProneMoveAnimationState.hpp"
       2              : 
       3              : #include "core/animations/states/LegsGetUpAnimationState.hpp"
       4              : #include "core/animations/states/LegsProneAnimationState.hpp"
       5              : 
       6              : #include "core/animations/states/CommonAnimationStateTransitions.hpp"
       7              : 
       8              : #include "core/entities/Soldier.hpp"
       9              : #include "core/physics/Constants.hpp"
      10              : 
      11              : namespace Soldank
      12              : {
      13            0 : LegsProneMoveAnimationState::LegsProneMoveAnimationState(
      14            0 :   const AnimationDataManager& animation_data_manager)
      15            0 :     : AnimationState(animation_data_manager.Get(AnimationType::ProneMove))
      16            0 :     , animation_data_manager_(animation_data_manager)
      17              : {
      18            0 : }
      19              : 
      20            0 : std::optional<std::shared_ptr<AnimationState>> LegsProneMoveAnimationState::HandleInput(
      21              :   Soldier& soldier)
      22              : {
      23            0 :     if (!soldier.control.left && !soldier.control.right) {
      24            0 :         auto new_state = std::make_shared<LegsProneAnimationState>(animation_data_manager_);
      25            0 :         new_state->SetFrame(26);
      26            0 :         return new_state;
      27            0 :     }
      28              : 
      29            0 :     if (soldier.on_ground) {
      30              :         auto maybe_rolling_animation_state =
      31            0 :           CommonAnimationStateTransitions::TryTransitionToRolling(soldier, animation_data_manager_);
      32            0 :         if (maybe_rolling_animation_state.has_value()) {
      33            0 :             return *maybe_rolling_animation_state;
      34              :         }
      35            0 :     }
      36              : 
      37            0 :     if (soldier.control.prone || soldier.direction != soldier.old_direction) {
      38            0 :         auto new_state = std::make_shared<LegsGetUpAnimationState>(animation_data_manager_);
      39            0 :         new_state->SetFrame(9);
      40            0 :         return new_state;
      41            0 :     }
      42              : 
      43            0 :     return std::nullopt;
      44              : }
      45              : 
      46            0 : void LegsProneMoveAnimationState::Update(Soldier& soldier, const PhysicsEvents& physics_events)
      47              : {
      48            0 :     soldier.stance = PhysicsConstants::STANCE_PRONE;
      49              : 
      50            0 :     if (GetSpeed() > 2) {
      51            0 :         soldier.particle.velocity_.x /= (float)GetSpeed();
      52            0 :         soldier.particle.velocity_.y /= (float)GetSpeed();
      53              :     }
      54              : 
      55            0 :     if ((GetFrame() < 4) || (GetFrame() > 14)) {
      56            0 :         if (soldier.on_ground) {
      57            0 :             if (soldier.control.left) {
      58            0 :                 glm::vec2 particle_force = soldier.particle.GetForce();
      59            0 :                 particle_force.x = -PhysicsConstants::PRONESPEED;
      60            0 :                 soldier.particle.SetForce(particle_force);
      61              :             } else {
      62            0 :                 glm::vec2 particle_force = soldier.particle.GetForce();
      63            0 :                 particle_force.x = PhysicsConstants::PRONESPEED;
      64            0 :                 soldier.particle.SetForce(particle_force);
      65              :             }
      66              :         }
      67              :     }
      68            0 : }
      69              : } // namespace Soldank
        

Generated by: LCOV version 2.0-1