| 725 | } |
| 726 | |
| 727 | void Monster::MoveToTarget( const float time_delta_s ) |
| 728 | { |
| 729 | if( !target_.have_position ) |
| 730 | return; |
| 731 | |
| 732 | const m_Vec2 vec_to_target= target_.position.xy() - pos_.xy(); |
| 733 | const float vec_to_target_length= vec_to_target.Length(); |
| 734 | |
| 735 | // Nothing to do, we are on target |
| 736 | if( vec_to_target_length == 0.0f ) |
| 737 | return; |
| 738 | |
| 739 | const GameResources::MonsterDescription& monster_description= game_resources_->monsters_description[ monster_id_ ]; |
| 740 | |
| 741 | const float distance_delta= time_delta_s * float( monster_description.speed ) / 10.0f; |
| 742 | |
| 743 | if( distance_delta >= vec_to_target_length ) |
| 744 | target_.have_position= false; // Reached |
| 745 | |
| 746 | pos_.x+= std::cos(angle_) * distance_delta; |
| 747 | pos_.y+= std::sin(angle_) * distance_delta; |
| 748 | |
| 749 | RotateToTarget( time_delta_s ); |
| 750 | } |
| 751 | |
| 752 | void Monster::RotateToTarget( float time_delta_s ) |
| 753 | { |
nothing calls this directly
no outgoing calls
no test coverage detected