MCPcopy Create free account
hub / github.com/bwapi/bwapi / getClosestUnit

Method getClosestUnit

bwapi/BWAPILIB/Source/Unit.cpp:31–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 }
30
31 Unit UnitInterface::getClosestUnit(const UnitFilter &pred, int radius) const
32 {
33 // Return if this unit does not exist
34 if ( !this->exists() )
35 return nullptr;
36
37 return Broodwar->getClosestUnitInRectangle(this->getPosition(),
38 [&](Unit u){ return this != u && this->getDistance(u) <= radius && (!pred.isValid() || pred(u)); },
39 this->getLeft() - radius,
40 this->getTop() - radius,
41 this->getRight() + radius,
42 this->getBottom() + radius);
43 }
44 //--------------------------------------------- GET UNITS IN WEAPON RANGE ----------------------------------
45 Unitset UnitInterface::getUnitsInWeaponRange(WeaponType weapon, const UnitFilter &pred) const
46 {

Callers

nothing calls this directly

Calls 9

getDistanceMethod · 0.95
getLeftMethod · 0.95
getTopMethod · 0.95
getRightMethod · 0.95
getBottomMethod · 0.95
existsMethod · 0.45
getPositionMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected