void CityServiceWorkersHire::_hireByType( const BuildingType type ) { CityHelper hlp( _city ); WorkingBuildings buildings = hlp.getBuildings< WorkingBuilding >( type ); for( WorkingBuildings::iterator it = buildings.begin(); it != buildings.end(); ++it ) { WorkingBuildingPtr wb = *it; if( _haveHr( wb ) ) continue; if( wb.isValid() && wb->getAccessRoads().size() > 0 && wb->getWorkers() < wb->getMaxWorkers() ) { WorkersHunterPtr hr = WorkersHunter::create( _city ); hr->setMaxDistance( 20 ); hr->send2City( wb, wb->getMaxWorkers() - wb->getWorkers()); } } }
foreach( WorkingBuildingPtr building, buildings ) { ret.currentWorkers += building->getWorkers(); ret.needWorkers += building->getMaxWorkers(); }