| 5289 | } |
| 5290 | |
| 5291 | void BattleUnit::setMovementState(MovementState state) |
| 5292 | { |
| 5293 | if (!agent->isMovementStateAllowed(state)) |
| 5294 | { |
| 5295 | LogError("WTF? Where the hell you're going?"); |
| 5296 | return; |
| 5297 | } |
| 5298 | |
| 5299 | if (current_movement_state == state) |
| 5300 | { |
| 5301 | return; |
| 5302 | } |
| 5303 | |
| 5304 | switch (state) |
| 5305 | { |
| 5306 | case MovementState::None: |
| 5307 | movement_ticks_passed = 0; |
| 5308 | movement_sounds_played = 0; |
| 5309 | ticksUntillNextTargetCheck = 0; |
| 5310 | break; |
| 5311 | case MovementState::Running: |
| 5312 | if (current_hand_state != HandState::AtEase || target_hand_state != HandState::AtEase) |
| 5313 | { |
| 5314 | setHandState(HandState::AtEase); |
| 5315 | } |
| 5316 | break; |
| 5317 | case MovementState::Strafing: |
| 5318 | // Nothing TBD |
| 5319 | break; |
| 5320 | default: |
| 5321 | break; |
| 5322 | } |
| 5323 | |
| 5324 | // Ensure we have frames in this state |
| 5325 | if (agent->getAnimationPack()->getFrameCountBody(displayedItem, current_body_state, |
| 5326 | target_body_state, current_hand_state, state, |
| 5327 | facing) == 0) |
| 5328 | { |
| 5329 | // No animation for target state -> Try without aiming |
| 5330 | if (current_hand_state != HandState::AtEase && |
| 5331 | agent->getAnimationPack()->getFrameCountBody(displayedItem, current_body_state, |
| 5332 | target_body_state, HandState::AtEase, |
| 5333 | state, facing) != 0) |
| 5334 | { |
| 5335 | setHandState(HandState::AtEase); |
| 5336 | } |
| 5337 | else |
| 5338 | { |
| 5339 | LogError("setMovementState %d incompatible with current body states %d to %d", |
| 5340 | (int)state, (int)current_body_state, (int)target_body_state); |
| 5341 | return; |
| 5342 | } |
| 5343 | } |
| 5344 | |
| 5345 | current_movement_state = state; |
| 5346 | } |
| 5347 | |
| 5348 | void BattleUnit::setMovementMode(MovementMode mode) |
no test coverage detected