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

Method getUnits

game/state/tilemap/tile.cpp:525–575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523}
524
525std::list<sp<BattleUnit>> Tile::getUnits(bool onlyConscious, bool mustOccupy, bool mustBeStatic,
526 sp<TileObjectBattleUnit> exceptThis, bool onlyLarge,
527 bool checkLargeSpace) const
528{
529 std::list<sp<BattleUnit>> result;
530 if (checkLargeSpace)
531 {
532 for (int x = -1; x <= 0; x++)
533 {
534 for (int y = -1; y <= 0; y++)
535 {
536 for (int z = 0; z <= 1; z++)
537 {
538 if (x == 0 && y == 0 && z == 0)
539 {
540 continue;
541 }
542 if (position.x + x < 0 || position.y + y < 0 || position.z + z >= map.size.z)
543 {
544 continue;
545 }
546 auto uts = map.getTile(position.x + x, position.y + y, position.z + z)
547 ->getUnits(onlyConscious, mustOccupy, mustBeStatic, exceptThis,
548 onlyLarge, false);
549 for (auto &u : uts)
550 {
551 result.push_back(u);
552 }
553 }
554 }
555 }
556 }
557
558 for (auto &o : intersectingObjects)
559 {
560 if (o->getType() == TileObject::Type::Unit)
561 {
562 auto unitTileObject = std::static_pointer_cast<TileObjectBattleUnit>(o);
563 auto unit = unitTileObject->getUnit();
564 if ((onlyConscious && !unit->isConscious()) || (exceptThis == unitTileObject) ||
565 (mustOccupy && unitTileObject->occupiedTiles.find(position) ==
566 unitTileObject->occupiedTiles.end()) ||
567 (mustBeStatic && !unit->isStatic()) || (onlyLarge && !unit->isLarge()))
568 {
569 continue;
570 }
571 result.push_back(unitTileObject->getUnit());
572 }
573 }
574 return result;
575}
576
577std::list<sp<BattleItem>> Tile::getItems()
578{

Callers 2

advanceAlongPathMethod · 0.80
handleMouseDownMethod · 0.80

Calls 7

getTileMethod · 0.80
getUnitMethod · 0.80
isConsciousMethod · 0.80
endMethod · 0.80
isStaticMethod · 0.80
isLargeMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected