* This will increment the walking phase. * @param tileBelowMe Pointer to tile currently below the unit. * @param cache Refresh the unit cache. */
| 457 | * @param cache Refresh the unit cache. |
| 458 | */ |
| 459 | void BattleUnit::keepWalking(Tile *tileBelowMe, bool cache) |
| 460 | { |
| 461 | int middle, end; |
| 462 | if (_verticalDirection) |
| 463 | { |
| 464 | middle = 4; |
| 465 | end = 8; |
| 466 | } |
| 467 | else |
| 468 | { |
| 469 | // diagonal walking takes double the steps |
| 470 | middle = 4 + 4 * (_direction % 2); |
| 471 | end = 8 + 8 * (_direction % 2); |
| 472 | if (_armor->getSize() > 1) |
| 473 | { |
| 474 | if (_direction < 1 || _direction > 5) |
| 475 | middle = end; |
| 476 | else if (_direction == 5) |
| 477 | middle = 12; |
| 478 | else if (_direction == 1) |
| 479 | middle = 5; |
| 480 | else |
| 481 | middle = 1; |
| 482 | } |
| 483 | } |
| 484 | if (!cache) |
| 485 | { |
| 486 | _pos = _destination; |
| 487 | end = 2; |
| 488 | } |
| 489 | |
| 490 | _walkPhase++; |
| 491 | |
| 492 | |
| 493 | if (_walkPhase == middle) |
| 494 | { |
| 495 | // we assume we reached our destination tile |
| 496 | // this is actually a drawing hack, so soldiers are not overlapped by floortiles |
| 497 | _pos = _destination; |
| 498 | } |
| 499 | |
| 500 | if (_walkPhase >= end) |
| 501 | { |
| 502 | if (_floating && !_tile->hasNoFloor(tileBelowMe)) |
| 503 | { |
| 504 | _floating = false; |
| 505 | } |
| 506 | // we officially reached our destination tile |
| 507 | _status = STATUS_STANDING; |
| 508 | _walkPhase = 0; |
| 509 | _verticalDirection = 0; |
| 510 | if (_faceDirection >= 0) { |
| 511 | // Finish strafing move facing the correct way. |
| 512 | _direction = _faceDirection; |
| 513 | _faceDirection = -1; |
| 514 | } |
| 515 | |
| 516 | // motion points calculation for the motion scanner blips |
no test coverage detected