| 264 | } |
| 265 | |
| 266 | Vec3<float> BattleUnit::getVelocity() const |
| 267 | { |
| 268 | Vec3<float> targetVelocity = velocity; |
| 269 | // If moving instead use movement speed |
| 270 | if (!atGoal && isMoving()) |
| 271 | { |
| 272 | // Normalized Vector towards target position |
| 273 | targetVelocity = goalPosition - position; |
| 274 | if (targetVelocity.x != 0.0f || targetVelocity.y != 0.0f || targetVelocity.z != 0.0f) |
| 275 | { |
| 276 | targetVelocity = glm::normalize(targetVelocity); |
| 277 | // Account for unit speed and movement state |
| 278 | float speedMult = agent->modified_stats.getMovementSpeed(); |
| 279 | if (current_movement_state == MovementState::Running) |
| 280 | { |
| 281 | speedMult *= 2.0f; |
| 282 | } |
| 283 | else if (current_body_state == BodyState::Prone) |
| 284 | { |
| 285 | speedMult *= 0.666f; |
| 286 | } |
| 287 | targetVelocity *= speedMult; |
| 288 | targetVelocity *= (float)TICK_SCALE / (float)TICKS_PER_UNIT_TRAVELLED_BATTLEUNIT; |
| 289 | } |
| 290 | } |
| 291 | return targetVelocity; |
| 292 | } |
| 293 | |
| 294 | void BattleUnit::refreshUnitVisibility(GameState &state) |
| 295 | { |
no test coverage detected