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

Method orderMove

game/ui/tileview/battleview.cpp:2469–2519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2467}
2468
2469void BattleView::orderMove(Vec3<int> target, bool strafe, bool demandGiveWay)
2470{
2471 if (battle.battleViewSelectedUnits.empty())
2472 {
2473 return;
2474 }
2475
2476 // Check if ordered to exit
2477 bool runAway = map.getTile(target)->getHasExit();
2478
2479 auto u = battle.battleViewSelectedUnits.front();
2480 BattleUnit temp;
2481 temp.agent = u->agent;
2482 temp.position = u->position;
2483 int facingDelta = strafe ? BattleUnitMission::getFacingDelta(
2484 u->facing, BattleUnitMission::getFacing(temp, target))
2485 : 0;
2486
2487 if (battle.battleViewGroupMove && battle.battleViewSelectedUnits.size() > 1 && !runAway)
2488 {
2489 battle.groupMove(*state, battle.battleViewSelectedUnits, target, facingDelta,
2490 demandGiveWay);
2491 }
2492 else
2493 {
2494 for (auto &unit : battle.battleViewSelectedUnits)
2495 {
2496 BattleUnitMission *mission;
2497 if (runAway)
2498 {
2499 // Running away units are impatient!
2500 mission = BattleUnitMission::gotoLocation(*unit, target, facingDelta, demandGiveWay,
2501 true, 1, true);
2502 }
2503 else // not running away
2504 {
2505 mission =
2506 BattleUnitMission::gotoLocation(*unit, target, facingDelta, demandGiveWay);
2507 }
2508
2509 if (unit->setMission(*state, mission))
2510 {
2511 LogInfo("BattleUnit \"%s\" going to location %s", unit->agent->name, target);
2512 }
2513 else
2514 {
2515 LogInfo("BattleUnit \"%s\" could not receive order to move", unit->agent->name);
2516 }
2517 }
2518 }
2519}
2520
2521void BattleView::orderTurn(Vec3<int> target)
2522{

Callers

nothing calls this directly

Calls 6

emptyMethod · 0.80
getHasExitMethod · 0.80
getTileMethod · 0.80
groupMoveMethod · 0.80
sizeMethod · 0.45
setMissionMethod · 0.45

Tested by

no test coverage detected