| 4294 | } |
| 4295 | |
| 4296 | void BattleUnit::executeAIMovement(GameState &state, AIMovement &movement) |
| 4297 | { |
| 4298 | if (movement.inProgress(*this)) |
| 4299 | { |
| 4300 | return; |
| 4301 | } |
| 4302 | |
| 4303 | // FIXME: USE teleporter to move? |
| 4304 | // Or maybe this is done in AI? |
| 4305 | |
| 4306 | // Stance change |
| 4307 | switch (movement.type) |
| 4308 | { |
| 4309 | case AIMovement::Type::Stop: |
| 4310 | case AIMovement::Type::Turn: |
| 4311 | break; |
| 4312 | default: |
| 4313 | setKneelingMode(movement.kneelingMode); |
| 4314 | if (movement_mode != movement.movementMode) |
| 4315 | { |
| 4316 | setMovementMode(movement.movementMode); |
| 4317 | } |
| 4318 | break; |
| 4319 | } |
| 4320 | |
| 4321 | // Do movement |
| 4322 | switch (movement.type) |
| 4323 | { |
| 4324 | case AIMovement::Type::Stop: |
| 4325 | for (auto &m : missions) |
| 4326 | { |
| 4327 | if (m->type == BattleUnitMission::Type::GotoLocation) |
| 4328 | { |
| 4329 | // Soft cancel |
| 4330 | m->targetLocation = goalPosition; |
| 4331 | m->currentPlannedPath.clear(); |
| 4332 | } |
| 4333 | } |
| 4334 | aiList.reportExecuted(movement); |
| 4335 | break; |
| 4336 | case AIMovement::Type::Advance: |
| 4337 | case AIMovement::Type::GetInRange: |
| 4338 | case AIMovement::Type::TakeCover: |
| 4339 | case AIMovement::Type::Patrol: |
| 4340 | case AIMovement::Type::Pursue: |
| 4341 | if (setMission(state, BattleUnitMission::gotoLocation(*this, movement.targetLocation))) |
| 4342 | { |
| 4343 | aiList.reportExecuted(movement); |
| 4344 | } |
| 4345 | break; |
| 4346 | case AIMovement::Type::Retreat: |
| 4347 | if (setMission(state, BattleUnitMission::gotoLocation(*this, movement.targetLocation, 0, |
| 4348 | true, true, 1, true))) |
| 4349 | { |
| 4350 | aiList.reportExecuted(movement); |
| 4351 | } |
| 4352 | break; |
| 4353 | case AIMovement::Type::Turn: |
no test coverage detected