MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / updateCheckBeginFalling

Method updateCheckBeginFalling

game/state/battle/battleunit.cpp:2603–2660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2601}
2602
2603void BattleUnit::updateCheckBeginFalling(GameState &state)
2604{
2605 if (retreated)
2606 {
2607 return;
2608 }
2609 if (current_movement_state == MovementState::Brainsuck)
2610 {
2611 return;
2612 }
2613 if (!falling)
2614 {
2615 // Check if should fall or start flying
2616 if (!canFly() || current_body_state != BodyState::Flying)
2617 {
2618 bool hasSupport = false;
2619 bool fullySupported = true;
2620 if (tileObject->getOwningTile()->getCanStand(isLarge()))
2621 {
2622 hasSupport = true;
2623 }
2624 else
2625 {
2626 fullySupported = false;
2627 }
2628 if (!atGoal)
2629 {
2630 if (tileObject->map.getTile(goalPosition)->getCanStand(isLarge()))
2631 {
2632 hasSupport = true;
2633 }
2634 else
2635 {
2636 fullySupported = false;
2637 }
2638 }
2639 // If not flying and has no support - fall!
2640 if (!hasSupport && !canFly())
2641 {
2642 startFalling(state);
2643 }
2644 // If flying and not supported both on current and goal locations - start flying
2645 // Note: Throwing units can "hover" in standing body state
2646 if (!fullySupported && canFly() &&
2647 (missions.empty() || missions.front()->type != BattleUnitMission::Type::ThrowItem))
2648 {
2649 if (current_body_state == target_body_state)
2650 {
2651 setBodyState(state, BodyState::Flying);
2652 if (!missions.empty())
2653 {
2654 missions.front()->targetBodyState = current_body_state;
2655 }
2656 }
2657 }
2658 }
2659 }
2660}

Callers 1

enterBattleMethod · 0.80

Calls 4

getCanStandMethod · 0.80
getOwningTileMethod · 0.80
getTileMethod · 0.80
emptyMethod · 0.80

Tested by

no test coverage detected