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

Method getNextBodyState

game/state/battle/battleunitmission.cpp:1441–1481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1439}
1440
1441bool BattleUnitMission::getNextBodyState(GameState &state, BattleUnit &u, BodyState &dest)
1442{
1443 if (cancelled)
1444 {
1445 return false;
1446 }
1447 // If we are throwing and ready to do so then body state change must wait until we turn
1448 if (this->type == Type::ThrowItem && u.current_body_state == BodyState::Standing)
1449 {
1450 if (u.facing != u.goalFacing || u.facing != targetFacing)
1451 {
1452 return false;
1453 }
1454 }
1455
1456 switch (this->type)
1457 {
1458 case Type::Turn:
1459 case Type::ThrowItem:
1460 case Type::ChangeBodyState:
1461 case Type::GotoLocation:
1462 case Type::ReachGoal:
1463 case Type::Jump:
1464 case Type::Brainsuck:
1465 if (!u.agent->isBodyStateAllowed(targetBodyState))
1466 {
1467 if (targetBodyState == BodyState::Flying)
1468 {
1469 targetBodyState = BodyState::Standing;
1470 }
1471 else
1472 {
1473 LogError("Unit %s (%s) (%s) lost capability to attain bodyState %d?", u.id,
1474 u.agent->name, u.agent->type->id, (int)targetBodyState);
1475 }
1476 }
1477 return advanceBodyState(state, u, targetBodyState, dest);
1478 default:
1479 return false;
1480 }
1481}
1482
1483MovementState BattleUnitMission::getNextMovementState(GameState &, BattleUnit &u)
1484{

Callers

nothing calls this directly

Calls 1

isBodyStateAllowedMethod · 0.80

Tested by

no test coverage detected