UnitGroup TrainTask::getFinishedUnits() { UnitGroup returnUnits; if(mProductionBuilding) returnUnits.insert(mProductionBuilding); if(mProducedUnit) returnUnits.insert(mProducedUnit); return returnUnits; }
UnitGroup ConstructionTask::getFinishedUnits() { UnitGroup returnUnits; if(mBuilder && finishedWithBuilder()) returnUnits.insert(mBuilder); if(mProducedUnit && mProducedUnit->exists() && isCompleted()) returnUnits.insert(mProducedUnit); return returnUnits; }
UnitGroup GatherTask::getFinishedUnits() { UnitGroup returnUnits; if(mWorkerOne) returnUnits.insert(mWorkerOne); if(mWorkerTwo) returnUnits.insert(mWorkerTwo); if(mWorkerThree) returnUnits.insert(mWorkerThree); return returnUnits; }
UnitGroup ObserverScoutTask::getFinishedUnits() { UnitGroup returnUnits; returnUnits.insert(mUnit); return returnUnits; }
void UnitGroupManager::onUnitDiscover(BWAPI::Unit* unit) { unitOwner[unit]=unit->getPlayer(); unitType[unit]=unit->getType(); data[unit->getPlayer()][unit->getType()].insert(unit); allOwnedUnits[unit->getPlayer()].insert(unit); allUnits.insert(unit); }
UnitGroup RequirementGroup::getUnits() const { UnitGroup units; for(std::vector<Requirement>::const_iterator requirement = mUnitRequirements.begin(); requirement != mUnitRequirements.end(); ++requirement) units.insert(requirement->getUnit()); return units; }
UnitGroup TechTask::getFinishedUnits() { UnitGroup returnUnits; if(mUnit) returnUnits.insert(mUnit); return returnUnits; }
std::vector<UnitGroup> UnitHelper::getClusters(const UnitGroup &units, int distance, int minSize) { std::vector<UnitGroup> clusters; for each(Unit unit in units) { std::vector<size_t> clustersInRange; for(size_t i = 0; i < clusters.size(); ++i) { for each(Unit clusterUnit in clusters[i]) { if(unit->getPosition().getApproxDistance(clusterUnit->getPosition()) <= distance) { clustersInRange.push_back(i); break; } } } if(clustersInRange.empty()) { UnitGroup newCluster; newCluster.insert(unit); clusters.push_back(newCluster); } else { clusters[clustersInRange[0]].insert(unit); for(size_t i = 1; i < clustersInRange.size(); ++i) { for each(Unit clusterUnit in clusters[clustersInRange[i]]) { clusters[clustersInRange[0]].insert(clusterUnit); } clusters[clustersInRange[i]].clear(); } }