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

Method getNextDestination

game/state/battle/battleunitmission.cpp:1346–1385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1344}
1345
1346bool BattleUnitMission::getNextDestination(GameState &state, BattleUnit &u, Vec3<float> &dest)
1347{
1348 if (cancelled)
1349 {
1350 return false;
1351 }
1352 if (type != Type::Brainsuck)
1353 {
1354 // If turning or changing body state then we cannot move
1355 if (u.facing != u.goalFacing || u.current_body_state != u.target_body_state)
1356 {
1357 return false;
1358 }
1359 // If we have not yet consumed queued up body or turning change, then we cannot move
1360 if (u.facing != targetFacing || u.current_body_state != targetBodyState)
1361 {
1362 return false;
1363 }
1364 }
1365 switch (this->type)
1366 {
1367 case Type::GotoLocation:
1368 if (state.current_battle->mode == Battle::Mode::TurnBased &&
1369 ((!state.current_battle->interruptQueue.empty()) ||
1370 (u.owner == state.current_battle->currentActiveOrganisation &&
1371 !state.current_battle->interruptUnits.empty()) ||
1372 (u.owner != state.current_battle->currentActiveOrganisation &&
1373 state.current_battle->interruptUnits.find({&state, u.id}) ==
1374 state.current_battle->interruptUnits.end())))
1375 {
1376 u.addMission(state, BattleUnitMission::acquireTU(u, true));
1377 return false;
1378 }
1379 return advanceAlongPath(state, u, dest);
1380 case Type::Brainsuck:
1381 return advanceBrainsucker(state, u, dest);
1382 default:
1383 return false;
1384 }
1385}
1386
1387bool BattleUnitMission::getNextFacing(GameState &state, BattleUnit &u, Vec2<int> &dest)
1388{

Callers

nothing calls this directly

Calls 3

emptyMethod · 0.80
endMethod · 0.80
addMissionMethod · 0.45

Tested by

no test coverage detected