Entity* MicroAspect::getEnemyAttackingThisUnit(std::set<Entity*> &enemies){ for(set<Entity*>::iterator i = enemies.begin(); i!= enemies.end();i++){ Weapon* weapon = static_cast<Weapon*>((*i)->getAspect(WEAPON)); if(weapon->getTarget()->entity == this->unit){ return *i; } } return NULL; }
bool MicroAspect::isBeingTarget(Entity* u, std::set<Entity*> &enemies){ for(set<Entity*>::iterator i = enemies.begin(); i!= enemies.end();i++){ Weapon* weapon = static_cast<Weapon*>((*i)->getAspect(WEAPON)); if(weapon->getTarget()->entity == this->unit){ return true; } } return false; }
//return int MicroAspect::getNumberOfAttackers(Entity* u){ int count = 0; set<Entity*> units = this->squad->getSquadUnits(); for (set<Entity*>::iterator i = units.begin();i!= units.end();i++){ Weapon* weapon = static_cast<Weapon*>((*i)->getAspect(WEAPON)); if(weapon->getTarget()->entity == u){ count ++; } } return count; }