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

Method spendAgentTUs

game/state/battle/battleunitmission.cpp:1314–1344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1312}
1313
1314bool BattleUnitMission::spendAgentTUs(GameState &state, BattleUnit &u, int cost, bool cancel,
1315 bool ignoreKneelReserve, bool allowInterrupt)
1316{
1317 if (costPaidUpFront > 0)
1318 {
1319 if (costPaidUpFront >= cost)
1320 {
1321 costPaidUpFront -= cost;
1322 cost = 0;
1323 }
1324 else
1325 {
1326 cost -= costPaidUpFront;
1327 costPaidUpFront = 0;
1328 }
1329 }
1330
1331 if (u.spendTU(state, cost, ignoreKneelReserve, false, allowInterrupt))
1332 {
1333 return true;
1334 }
1335 if (cancel)
1336 {
1337 cancelled = true;
1338 }
1339 else
1340 {
1341 u.addMission(state, BattleUnitMission::Type::AcquireTU);
1342 }
1343 return false;
1344}
1345
1346bool BattleUnitMission::getNextDestination(GameState &state, BattleUnit &u, Vec3<float> &dest)
1347{

Callers

nothing calls this directly

Calls 2

spendTUMethod · 0.80
addMissionMethod · 0.45

Tested by

no test coverage detected