| 4376 | void BattleUnit::notifyHit(Vec3<int> position) { aiList.notifyHit(position); } |
| 4377 | |
| 4378 | void BattleUnit::tryToRiseUp(GameState &state) |
| 4379 | { |
| 4380 | // Do not rise up if unit is standing on us |
| 4381 | if (tileObject->getOwningTile()->getUnitIfPresent(true, true, false, tileObject)) |
| 4382 | return; |
| 4383 | |
| 4384 | // Find state we can rise into (with animation) |
| 4385 | auto targetState = BodyState::Standing; |
| 4386 | while (agent->getAnimationPack()->getFrameCountBody(displayedItem, current_body_state, |
| 4387 | targetState, current_hand_state, |
| 4388 | current_movement_state, facing) == 0) |
| 4389 | { |
| 4390 | switch (targetState) |
| 4391 | { |
| 4392 | case BodyState::Standing: |
| 4393 | if (agent->isBodyStateAllowed(BodyState::Flying)) |
| 4394 | { |
| 4395 | targetState = BodyState::Flying; |
| 4396 | continue; |
| 4397 | } |
| 4398 | // Intentional fall-through |
| 4399 | case BodyState::Flying: |
| 4400 | if (agent->isBodyStateAllowed(BodyState::Kneeling)) |
| 4401 | { |
| 4402 | targetState = BodyState::Kneeling; |
| 4403 | continue; |
| 4404 | } |
| 4405 | // Intentional fall-through |
| 4406 | case BodyState::Kneeling: |
| 4407 | if (canProne(position, facing)) |
| 4408 | { |
| 4409 | targetState = BodyState::Prone; |
| 4410 | continue; |
| 4411 | } |
| 4412 | // Intentional fall-through |
| 4413 | case BodyState::Prone: |
| 4414 | // If we arrived here then we have no animation for standing up |
| 4415 | targetState = BodyState::Downed; |
| 4416 | break; |
| 4417 | case BodyState::Downed: |
| 4418 | case BodyState::Dead: |
| 4419 | case BodyState::Jumping: |
| 4420 | case BodyState::Throwing: |
| 4421 | LogError("Not possible to reach this?"); |
| 4422 | break; |
| 4423 | } |
| 4424 | break; |
| 4425 | } |
| 4426 | // Find state we can rise into (with no animation) |
| 4427 | if (targetState == BodyState::Downed) |
| 4428 | { |
| 4429 | if (agent->isBodyStateAllowed(BodyState::Standing)) |
| 4430 | { |
| 4431 | targetState = BodyState::Standing; |
| 4432 | } |
| 4433 | else if (agent->isBodyStateAllowed(BodyState::Flying)) |
| 4434 | { |
| 4435 | targetState = BodyState::Flying; |
nothing calls this directly
no test coverage detected