MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / getReachableAttackableObjects

Method getReachableAttackableObjects

source/entities/Creature.cpp:1667–1687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1665}
1666
1667std::vector<GameEntity*> Creature::getReachableAttackableObjects(const std::vector<GameEntity*>& objectsToCheck)
1668{
1669 std::vector<GameEntity*> tempVector;
1670 Tile* myTile = getPositionTile();
1671
1672 // Loop over the vector of objects we are supposed to check.
1673 for (unsigned int i = 0; i < objectsToCheck.size(); ++i)
1674 {
1675 // Try to find a valid path from the tile this creature is in to the nearest tile where the current target object is.
1676 GameEntity* entity = objectsToCheck[i];
1677 // We only consider alive objects
1678 if(entity->getHP(nullptr) <= 0)
1679 continue;
1680
1681 Tile* objectTile = entity->getCoveredTile(0);
1682 if (getGameMap()->pathExists(this, myTile, objectTile))
1683 tempVector.push_back(objectsToCheck[i]);
1684 }
1685
1686 return tempVector;
1687}
1688
1689std::vector<GameEntity*> Creature::getCreaturesFromList(const std::vector<GameEntity*> &objectsToCheck, bool workersOnly)
1690{

Callers

nothing calls this directly

Calls 3

pathExistsMethod · 0.80
getHPMethod · 0.45
getCoveredTileMethod · 0.45

Tested by

no test coverage detected